0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-09 23:08:41 +00:00
phpv8/tests/generators_from_v8_010.phpt

39 lines
584 B
Plaintext
Raw Permalink Normal View History

--TEST--
Test V8::executeString() : Generators V8 -> PHP (properties)
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
if (!class_exists('V8Generator')) {
die("skip Installed V8 version doesn't support generators");
}
?>
--FILE--
<?php
$js = <<<EOJS
function* TheGen() {
yield 23;
yield PHP.getValue();
}
var gen = TheGen();
gen.foo = 23;
gen.bar = function() { var_dump("Hello World"); };
gen;
EOJS;
$v8 = new V8Js();
$gen = $v8->executeString($js);
var_dump($gen->foo);
$gen->bar();
?>
===EOF===
--EXPECT--
int(23)
string(11) "Hello World"
===EOF===