0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 08:11:52 +00:00

Make sure all tests and samples use the new exception class name V8JsScriptException.

This commit is contained in:
Simon Best 2013-04-14 00:36:31 +01:00
parent 8d8c671aa0
commit 7e90439cdf
23 changed files with 39 additions and 39 deletions

View File

@ -43,7 +43,7 @@ API
public mixed V8Js::executeString( string script [, string identifier [, int flags = V8Js::FLAG_NONE]]) public mixed V8Js::executeString( string script [, string identifier [, int flags = V8Js::FLAG_NONE]])
// Returns uncaught pending exception or null if there is no pending exception. // Returns uncaught pending exception or null if there is no pending exception.
public V8JsException V8Js::getPendingException( void ) public V8JsScriptException V8Js::getPendingException( void )
/** Static methods **/ /** Static methods **/
@ -56,7 +56,7 @@ API
public static array V8Js::getExtensions( void ) public static array V8Js::getExtensions( void )
} }
final class V8JsException extends Exception final class V8JsScriptException extends Exception
{ {
/* Properties */ /* Properties */
protected string JsFileName = NULL; protected string JsFileName = NULL;

View File

@ -69,6 +69,6 @@ try {
$blaa->executeString('PHP.obj.foo(1,2,3);', "call_test1 #8.js"); $blaa->executeString('PHP.obj.foo(1,2,3);', "call_test1 #8.js");
echo "------------\n"; echo "------------\n";
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }

View File

@ -6,6 +6,6 @@ $a->func = function ($a) { echo "Closure..\n"; };
try { try {
$a->executeString("print(PHP.func); PHP.func(1);", "closure_test.js"); $a->executeString("print(PHP.func); PHP.func(1);", "closure_test.js");
$a->executeString("print(PHP.func); PHP.func(1);", "closure_test.js"); $a->executeString("print(PHP.func); PHP.func(1);", "closure_test.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }

View File

@ -4,6 +4,6 @@ $a = new V8Js();
try { try {
var_dump($a->executeString("date = new Date('September 8, 1975 09:00:00'); print(date + '\\n'); date;", "test.js")); var_dump($a->executeString("date = new Date('September 8, 1975 09:00:00'); print(date + '\\n'); date;", "test.js"));
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }

View File

@ -54,6 +54,6 @@ try {
$a->executeString("var patt1=/[^a-h]/g; var_dump(patt1);", "call_test5.js"); $a->executeString("var patt1=/[^a-h]/g; var_dump(patt1);", "call_test5.js");
$a->executeString("var_dump(Math.PI, Infinity, null, undefined);", "call_test6.js"); $a->executeString("var_dump(Math.PI, Infinity, null, undefined);", "call_test6.js");
// $a->executeString($JS); // $a->executeString($JS);
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }

View File

@ -19,7 +19,7 @@
try { try {
$foo = new Foo(); $foo = new Foo();
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo "PHP Exception: ", $e->getMessage(), "\n"; //var_dump($e); echo "PHP Exception: ", $e->getMessage(), "\n"; //var_dump($e);
} }

View File

@ -27,7 +27,7 @@
try { try {
$foo = new Foo(); $foo = new Foo();
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo "PHP Exception: ", $e->getMessage(), "\n"; echo "PHP Exception: ", $e->getMessage(), "\n";
} }

View File

@ -18,6 +18,6 @@ echo $a;
try { try {
$a->executeString("PHP.mytest(PHP.foo, PHP.my_private, PHP.my_protected);", "test7.js"); $a->executeString("PHP.mytest(PHP.foo, PHP.my_private, PHP.my_protected);", "test7.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }

View File

@ -23,13 +23,13 @@ $a->executeString("PHP.myobj.mytest(3.14, 42, null);", "test3.js");
// Invalid parameters // Invalid parameters
try { try {
$a->executeString("PHP.myobj.mytest();", "test4.js"); $a->executeString("PHP.myobj.mytest();", "test4.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
try { try {
$a->executeString("PHP.myobj.mytest('arg1', 'arg2', 'arg3', 'extra_arg');", "test5.js"); $a->executeString("PHP.myobj.mytest('arg1', 'arg2', 'arg3', 'extra_arg');", "test5.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
@ -37,12 +37,12 @@ try {
try { try {
// date_default_timezone_set("UTC"); // date_default_timezone_set("UTC");
$a->executeString("date = new Date('September 8, 1975 09:00:00'); PHP.print(date); PHP.myobj.mytest(date, PHP.myobj, new Array(1,2,3));", "test6.js"); $a->executeString("date = new Date('September 8, 1975 09:00:00'); PHP.print(date); PHP.myobj.mytest(date, PHP.myobj, new Array(1,2,3));", "test6.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
try { try {
$a->executeString("PHP.myobj.mytest(PHP.myobj, new Array(1,2,3), new Array('foo', 'bar', PHP.myobj));", "test7.js"); $a->executeString("PHP.myobj.mytest(PHP.myobj, new Array(1,2,3), new Array('foo', 'bar', PHP.myobj));", "test7.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }

View File

@ -139,7 +139,7 @@ $a->executeString("bigarray()", "test1.js");
try { try {
echo($a->executeString($jstparser, "test2.js")), "\n"; echo($a->executeString($jstparser, "test2.js")), "\n";
var_dump($a->executeString($jsontemplate, "test1.js")); var_dump($a->executeString($jsontemplate, "test1.js"));
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(); echo $e->getMessage();
} }
@ -168,6 +168,6 @@ var_dump($b->executeString("print('foobar\\n');"));
try { try {
$b->executeString("foobar; foo();", "extest.js"); $b->executeString("foobar; foo();", "extest.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e, $e->getJsFileName(), $e->getJsLineNumber(), $e->getJsSourceLine(), $e->getJsTrace()); var_dump($e, $e->getJsFileName(), $e->getJsLineNumber(), $e->getJsSourceLine(), $e->getJsTrace());
} }

View File

@ -14,7 +14,7 @@ $v8 = new V8Js();
try { try {
var_dump($v8->executeString($JS, 'basic.js')); var_dump($v8->executeString($JS, 'basic.js'));
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
?> ?>

View File

@ -10,7 +10,7 @@ $a->func = function ($arg) { echo "Hello {$arg}, I'm Closure!\n"; };
try { try {
$a->executeString('print(PHP.func + "\n"); PHP.func("foobar");', "closure_test.js"); $a->executeString('print(PHP.func + "\n"); PHP.func("foobar");', "closure_test.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
?> ?>

View File

@ -19,7 +19,7 @@ $a->func = function ($arg) use ($b) { return call_user_func($b, $arg); };
try { try {
$a->executeString('print(PHP.func + "\n"); print(PHP.func("world") + "\n");', "closure_test.js"); $a->executeString('print(PHP.func + "\n"); print(PHP.func("world") + "\n");', "closure_test.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
?> ?>

View File

@ -14,7 +14,7 @@ $v8->__construct();
try { try {
$v8->executeString($JS, 'basic.js'); $v8->executeString($JS, 'basic.js');
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
?> ?>

View File

@ -27,7 +27,7 @@ $a->ctx = '#1';
try { try {
echo '1. '; echo '1. ';
$a->executeString($JS_set, 'set.js'); $a->executeString($JS_set, 'set.js');
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
@ -38,7 +38,7 @@ $b->ctx = '#2';
try { try {
echo '2. '; echo '2. ';
$b->executeString($JS_change, 'change.js'); $b->executeString($JS_change, 'change.js');
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
@ -46,7 +46,7 @@ try {
try { try {
echo '3. '; echo '3. ';
$a->executeString($JS_read, 'read.js'); $a->executeString($JS_read, 'read.js');
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
@ -54,7 +54,7 @@ try {
try { try {
echo '4. '; echo '4. ';
$a->executeString($JS_change, 'change.js'); $a->executeString($JS_change, 'change.js');
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
@ -62,7 +62,7 @@ try {
try { try {
echo '5. '; echo '5. ';
$a->executeString($JS_read, 'read.js'); $a->executeString($JS_read, 'read.js');
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
?> ?>

View File

@ -14,7 +14,7 @@ $a->foo = 'from first.js';
try { try {
$a->executeString($JS, 'first.js'); $a->executeString($JS, 'first.js');
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
@ -25,7 +25,7 @@ $b->foo = 'from second.js';
try { try {
$b->executeString($JS, 'second.js'); $b->executeString($JS, 'second.js');
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }

View File

@ -1,5 +1,5 @@
--TEST-- --TEST--
Test V8::executeString() : V8JsException Test V8::executeString() : V8JsScriptException
--SKIPIF-- --SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE-- --FILE--
@ -13,13 +13,13 @@ $v8 = new V8Js();
try { try {
$v8->executeString($JS, 'exception.js'); $v8->executeString($JS, 'exception.js');
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
?> ?>
===EOF=== ===EOF===
--EXPECTF-- --EXPECTF--
object(V8JsException)#2 (11) { object(V8JsScriptException)#2 (11) {
["message":protected]=> ["message":protected]=>
string(75) "exception.js:1: ReferenceError: this_function_does_not_exist is not defined" string(75) "exception.js:1: ReferenceError: this_function_does_not_exist is not defined"
["string":"Exception":private]=> ["string":"Exception":private]=>

View File

@ -27,7 +27,7 @@ class Foo {
try { try {
$foo = new Foo(); $foo = new Foo();
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo "PHP Exception: ", $e->getMessage(), "\n"; //var_dump($e); echo "PHP Exception: ", $e->getMessage(), "\n"; //var_dump($e);
} }
?> ?>

View File

@ -27,13 +27,13 @@ class Foo {
try { try {
$foo = new Foo(); $foo = new Foo();
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo "PHP Exception: ", $e->getMessage(), "\n"; //var_dump($e); echo "PHP Exception: ", $e->getMessage(), "\n"; //var_dump($e);
} }
?> ?>
===EOF=== ===EOF===
--EXPECTF-- --EXPECTF--
object(V8JsException)#3 (11) { object(V8JsScriptException)#3 (11) {
["message":protected]=> ["message":protected]=>
string(49) "throw_0:1: ReferenceError: fooobar is not defined" string(49) "throw_0:1: ReferenceError: fooobar is not defined"
["string":"Exception":private]=> ["string":"Exception":private]=>

View File

@ -26,7 +26,7 @@ class Foo {
try { try {
$foo = new Foo(); $foo = new Foo();
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo "PHP Exception: ", $e->getMessage(), "\n"; echo "PHP Exception: ", $e->getMessage(), "\n";
} }
?> ?>

View File

@ -15,7 +15,7 @@ try {
var_dump($v8->executeString($js, 'assoc_no_flags.js')); var_dump($v8->executeString($js, 'assoc_no_flags.js'));
echo "---\n"; echo "---\n";
var_dump($v8->executeString($js, 'assoc_force_to_array.js', V8Js::FLAG_FORCE_ARRAY)); var_dump($v8->executeString($js, 'assoc_force_to_array.js', V8Js::FLAG_FORCE_ARRAY));
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
?> ?>

View File

@ -17,7 +17,7 @@ try {
$v8->executeString($js, 'no_flags.js'); $v8->executeString($js, 'no_flags.js');
echo "---\n"; echo "---\n";
$v8->executeString($js, 'force_to_array.js', V8Js::FLAG_FORCE_ARRAY); $v8->executeString($js, 'force_to_array.js', V8Js::FLAG_FORCE_ARRAY);
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }
?> ?>

View File

@ -36,13 +36,13 @@ $a->executeString("PHP.myobj.mytest(3.14, 42, null);", "test3.js");
// Invalid parameters // Invalid parameters
try { try {
$a->executeString("PHP.myobj.mytest();", "test4.js"); $a->executeString("PHP.myobj.mytest();", "test4.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
try { try {
$a->executeString("PHP.myobj.mytest('arg1', 'arg2', 'arg3', 'extra_arg');", "test5.js"); $a->executeString("PHP.myobj.mytest('arg1', 'arg2', 'arg3', 'extra_arg');", "test5.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
@ -50,14 +50,14 @@ try {
echo "\nTEST: Javascript Date -> PHP DateTime\n"; echo "\nTEST: Javascript Date -> PHP DateTime\n";
echo "======================================\n"; echo "======================================\n";
$a->executeString("date = new Date('September 8, 1975 09:00:00 GMT'); print(date.toUTCString() + '\\n'); PHP.myobj.mydatetest(date, 'foo');", "test6.js"); $a->executeString("date = new Date('September 8, 1975 09:00:00 GMT'); print(date.toUTCString() + '\\n'); PHP.myobj.mydatetest(date, 'foo');", "test6.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
// Array / Object // Array / Object
try { try {
$a->executeString("PHP.myobj.mytest(PHP.myobj, new Array(1,2,3), new Array('foo', 'bar', PHP.myobj));", "test7.js"); $a->executeString("PHP.myobj.mytest(PHP.myobj, new Array(1,2,3), new Array('foo', 'bar', PHP.myobj));", "test7.js");
} catch (V8JsException $e) { } catch (V8JsScriptException $e) {
var_dump($e); var_dump($e);
} }