php_exceptions_basic.phpt 828 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Test V8::executeString() : PHP Exception handling (basic)
  3. --SKIPIF--
  4. <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. class Foo {
  8. function throwException() {
  9. throw new \Exception("Test-Exception");
  10. }
  11. }
  12. $v8 = new V8Js();
  13. $v8->foo = new \Foo();
  14. $JS = <<< EOT
  15. try {
  16. PHP.foo.throwException();
  17. // the exception should abort further execution,
  18. // hence the print must not pop up
  19. print("after throwException\\n");
  20. } catch(e) {
  21. // JS should not catch in default mode
  22. print("JS caught exception");
  23. }
  24. EOT;
  25. try {
  26. $v8->executeString($JS);
  27. } catch (Exception $e) {
  28. var_dump($e->getMessage());
  29. var_dump($e->getFile());
  30. var_dump($e->getLine());
  31. }
  32. ?>
  33. ===EOF===
  34. --EXPECTF--
  35. string(14) "Test-Exception"
  36. string(%d) "%sphp_exceptions_basic.php"
  37. int(5)
  38. ===EOF===