0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-14 17:38:42 +00:00
phpv8/tests/generators_from_v8_003.phpt

48 lines
712 B
Plaintext
Raw Normal View History

2016-01-07 21:48:01 +00:00
--TEST--
Test V8::executeString() : Generators V8 -> PHP (rewind)
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
if (!class_exists('V8Generator')) {
die("skip Installed V8 version doesn't support generators");
}
?>
2016-01-07 21:48:01 +00:00
--FILE--
<?php
$js = <<<EOJS
function* TheGen() {
for(var i = 0; i < 4; i ++) {
yield i;
}
}
TheGen();
EOJS;
$v8 = new V8Js();
$gen = $v8->executeString($js);
foreach($gen as $a) {
var_dump($a);
}
foreach($gen as $a) {
var_dump($a);
}
?>
===EOF===
--EXPECTF--
int(0)
int(1)
int(2)
int(3)
Fatal error: Uncaught V8JsException: V8Generator::rewind not supported by ES6 in %s
Stack trace:
#0 %s: V8Generator->rewind()
#1 {main}
thrown in %s on line 20