mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-23 04:51:53 +00:00
42 lines
517 B
Plaintext
42 lines
517 B
Plaintext
|
--TEST--
|
||
|
Test V8::executeString() : Generators V8 -> PHP (yield from)
|
||
|
--SKIPIF--
|
||
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||
|
--FILE--
|
||
|
<?php
|
||
|
|
||
|
function PhpGen() {
|
||
|
yield 23;
|
||
|
|
||
|
$js = <<<EOJS
|
||
|
function* TheGen() {
|
||
|
for(var i = 0; i < 4; i ++) {
|
||
|
yield i;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
TheGen();
|
||
|
EOJS;
|
||
|
|
||
|
$v8 = new V8Js();
|
||
|
$jsGen = $v8->executeString($js);
|
||
|
|
||
|
yield from $jsGen;
|
||
|
}
|
||
|
|
||
|
$gen = PhpGen();
|
||
|
|
||
|
foreach($gen as $a) {
|
||
|
var_dump($a);
|
||
|
}
|
||
|
|
||
|
?>
|
||
|
===EOF===
|
||
|
--EXPECTF--
|
||
|
int(23)
|
||
|
int(0)
|
||
|
int(1)
|
||
|
int(2)
|
||
|
int(3)
|
||
|
===EOF===
|