0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-08 18:58:41 +00:00
phpv8/tests/execute_flags_args.phpt

76 lines
1.2 KiB
Plaintext
Raw Normal View History

2012-04-27 16:26:15 +00:00
--TEST--
Test V8::executeString() : Forcing to arrays (argument passing)
2012-04-27 16:26:15 +00:00
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$js = <<<'EOT'
String.prototype.test = function(){ return PHP.test(this, arguments); };
"Foobar".test("foo", "bar");
EOT;
$v8 = new V8Js();
$v8->test = function ($value) { var_dump(func_get_args()); };
try {
$v8->executeString($js, 'no_flags.js');
echo "---\n";
$v8->executeString($js, 'force_to_array.js', V8Js::FLAG_FORCE_ARRAY);
} catch (V8JsScriptException $e) {
2012-04-27 16:26:15 +00:00
var_dump($e);
}
?>
===EOF===
--EXPECTF--
2012-04-27 16:26:15 +00:00
array(2) {
[0]=>
object(V8Object)#%d (6) {
2012-04-27 16:26:15 +00:00
["0"]=>
string(1) "F"
["1"]=>
string(1) "o"
["2"]=>
string(1) "o"
["3"]=>
string(1) "b"
["4"]=>
string(1) "a"
["5"]=>
string(1) "r"
}
[1]=>
object(V8Object)#%d (2) {
2012-04-27 16:26:15 +00:00
["0"]=>
string(3) "foo"
["1"]=>
string(3) "bar"
}
}
---
array(2) {
[0]=>
array(6) {
[0]=>
string(1) "F"
[1]=>
string(1) "o"
[2]=>
string(1) "o"
[3]=>
string(1) "b"
[4]=>
string(1) "a"
[5]=>
string(1) "r"
}
[1]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
string(3) "bar"
}
}
===EOF===