mirror of
https://github.com/phpv8/v8js.git
synced 2024-11-10 02:38:42 +00:00
Add test on PHP exceptions thrown by JS generators
This commit is contained in:
parent
479d14b5b0
commit
46fba810af
38
tests/generators_from_v8_008.phpt
Normal file
38
tests/generators_from_v8_008.phpt
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
--TEST--
|
||||||
|
Test V8::executeString() : Generators V8 -> PHP (throw PHP)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$js = <<<EOJS
|
||||||
|
function* TheGen() {
|
||||||
|
yield 23;
|
||||||
|
yield PHP.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
TheGen();
|
||||||
|
EOJS;
|
||||||
|
|
||||||
|
$v8 = new V8Js();
|
||||||
|
$v8->getValue = function() {
|
||||||
|
throw new \Exception('this shall not work');
|
||||||
|
};
|
||||||
|
$gen = $v8->executeString($js);
|
||||||
|
|
||||||
|
foreach($gen as $a) {
|
||||||
|
var_dump($a);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
===EOF===
|
||||||
|
--EXPECTF--
|
||||||
|
int(23)
|
||||||
|
|
||||||
|
Fatal error: Uncaught Exception: this shall not work in %s
|
||||||
|
Stack trace:
|
||||||
|
#0 [internal function]: {closure}()
|
||||||
|
#1 [internal function]: Closure->__invoke()
|
||||||
|
#2 %s: V8Generator->next()
|
||||||
|
#3 {main}
|
||||||
|
thrown in %s
|
Loading…
Reference in New Issue
Block a user