0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-14 03:48:41 +00:00
phpv8/tests/exception_propagation_1.phpt
2012-04-27 16:26:15 +00:00

38 lines
920 B
PHP

--TEST--
Test V8::executeString() : Exception propagation test 1
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
class Foo {
private $v8 = NULL;
public function __construct()
{
$this->v8 = new V8Js();
$this->v8->foo = $this;
$this->v8->executeString('fooobar', 'throw_0');
var_dump($this->v8->getPendingException());
$this->v8->executeString('try { PHP.foo.bar(); } catch (e) { print(e + " caught!\n"); }', 'trycatch1');
$this->v8->executeString('try { PHP.foo.bar(); } catch (e) { print(e + " caught!\n"); }', 'trycatch2');
}
public function bar()
{
echo "To Bar!\n";
$this->v8->executeString('throw new Error();', 'throw_1');
}
}
try {
$foo = new Foo();
} catch (V8JsException $e) {
echo "PHP Exception: ", $e->getMessage(), "\n"; //var_dump($e);
}
?>
===EOF===
--EXPECTF--
PHP Exception: throw_0:1: ReferenceError: fooobar is not defined
===EOF===