2012-04-27 16:26:15 +00:00
|
|
|
--TEST--
|
2015-04-26 11:49:13 +00:00
|
|
|
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);
|
2013-04-13 23:36:31 +00:00
|
|
|
} catch (V8JsScriptException $e) {
|
2012-04-27 16:26:15 +00:00
|
|
|
var_dump($e);
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
===EOF===
|
2013-10-29 19:26:16 +00:00
|
|
|
--EXPECTF--
|
2012-04-27 16:26:15 +00:00
|
|
|
array(2) {
|
|
|
|
[0]=>
|
2013-10-29 19:26:16 +00:00
|
|
|
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]=>
|
2013-10-29 19:26:16 +00:00
|
|
|
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===
|