exception_propagation_1.phpt 920 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. Test V8::executeString() : Exception propagation test 1
  3. --SKIPIF--
  4. <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. class Foo {
  8. private $v8 = NULL;
  9. public function __construct()
  10. {
  11. $this->v8 = new V8Js();
  12. $this->v8->foo = $this;
  13. $this->v8->executeString('fooobar', 'throw_0');
  14. var_dump($this->v8->getPendingException());
  15. $this->v8->executeString('try { PHP.foo.bar(); } catch (e) { print(e + " caught!\n"); }', 'trycatch1');
  16. $this->v8->executeString('try { PHP.foo.bar(); } catch (e) { print(e + " caught!\n"); }', 'trycatch2');
  17. }
  18. public function bar()
  19. {
  20. echo "To Bar!\n";
  21. $this->v8->executeString('throw new Error();', 'throw_1');
  22. }
  23. }
  24. try {
  25. $foo = new Foo();
  26. } catch (V8JsException $e) {
  27. echo "PHP Exception: ", $e->getMessage(), "\n"; //var_dump($e);
  28. }
  29. ?>
  30. ===EOF===
  31. --EXPECTF--
  32. PHP Exception: throw_0:1: ReferenceError: fooobar is not defined
  33. ===EOF===