From 916728fa8a735a2ccd2871b85ae83cd5b476267f Mon Sep 17 00:00:00 2001 From: Simon Best Date: Sun, 14 Apr 2013 12:31:35 +0100 Subject: [PATCH] Added simple tests for time limit and memory limit. --- tests/memory_limit.phpt | 72 +++++++++++++++++++++++++++++++++++++++++ tests/time_limit.phpt | 69 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 tests/memory_limit.phpt create mode 100644 tests/time_limit.phpt diff --git a/tests/memory_limit.phpt b/tests/memory_limit.phpt new file mode 100644 index 0000000..85263e0 --- /dev/null +++ b/tests/memory_limit.phpt @@ -0,0 +1,72 @@ +--TEST-- +Test V8::executeString() : Time limit +--SKIPIF-- + +--FILE-- +executeString($JS, 'basic.js', V8Js::FLAG_NONE, 0, 10000000)); +} catch (V8JsMemoryLimitException $e) { + var_dump($e); +} +?> +===EOF=== +--EXPECT-- +object(V8JsMemoryLimitException)#2 (7) { + ["message":protected]=> + string(46) "Script memory limit of 10000000 bytes exceeded" + ["string":"Exception":private]=> + string(0) "" + ["code":protected]=> + int(0) + ["file":protected]=> + string(36) "/var/www/v8js/tests/memory_limit.php" + ["line":protected]=> + int(13) + ["trace":"Exception":private]=> + array(1) { + [0]=> + array(6) { + ["file"]=> + string(36) "/var/www/v8js/tests/memory_limit.php" + ["line"]=> + int(13) + ["function"]=> + string(13) "executeString" + ["class"]=> + string(4) "V8Js" + ["type"]=> + string(2) "->" + ["args"]=> + array(5) { + [0]=> + string(125) "var text = "abcdefghijklmnopqrstuvwyxz0123456789"; +var memory = ""; +for (var i = 0; i < 1000000; ++i) { + memory += text; +}" + [1]=> + string(8) "basic.js" + [2]=> + int(1) + [3]=> + int(0) + [4]=> + int(10000000) + } + } + } + ["previous":"Exception":private]=> + NULL +} +===EOF=== \ No newline at end of file diff --git a/tests/time_limit.phpt b/tests/time_limit.phpt new file mode 100644 index 0000000..a7112b3 --- /dev/null +++ b/tests/time_limit.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test V8::executeString() : Time limit +--SKIPIF-- + +--FILE-- +executeString($JS, 'basic.js', V8Js::FLAG_NONE, 1000)); +} catch (V8JsTimeLimitException $e) { + var_dump($e); +} +?> +===EOF=== +--EXPECT-- +object(V8JsTimeLimitException)#2 (7) { + ["message":protected]=> + string(47) "Script time limit of 1000 milliseconds exceeded" + ["string":"Exception":private]=> + string(0) "" + ["code":protected]=> + int(0) + ["file":protected]=> + string(34) "/var/www/v8js/tests/time_limit.php" + ["line":protected]=> + int(13) + ["trace":"Exception":private]=> + array(1) { + [0]=> + array(6) { + ["file"]=> + string(34) "/var/www/v8js/tests/time_limit.php" + ["line"]=> + int(13) + ["function"]=> + string(13) "executeString" + ["class"]=> + string(4) "V8Js" + ["type"]=> + string(2) "->" + ["args"]=> + array(4) { + [0]=> + string(124) "var text = "abcdefghijklmnopqrstuvwyxz0123456789"; +for (var i = 0; i < 10000000; ++i) { + var encoded = encodeURI(text); +}" + [1]=> + string(8) "basic.js" + [2]=> + int(1) + [3]=> + int(1000) + } + } + } + ["previous":"Exception":private]=> + NULL +} +===EOF===