mirror of
https://github.com/phpv8/v8js.git
synced 2025-03-11 22:18:44 +00:00
Test yield from JS generators
This commit is contained in:
parent
f97a25b69c
commit
6fa6f9316e
41
tests/generators_from_v8_006.phpt
Normal file
41
tests/generators_from_v8_006.phpt
Normal file
@ -0,0 +1,41 @@
|
||||
--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===
|
Loading…
x
Reference in New Issue
Block a user