-
Notifications
You must be signed in to change notification settings - Fork 202
/
Copy patharray_pass_flags.phpt
99 lines (92 loc) · 1.84 KB
/
array_pass_flags.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
--TEST--
Test V8::executeString() : Check passing array from JS to PHP (using force array flag)
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$v8 = new V8Js();
$v8->test = function ($arr) { var_dump($arr); };
try {
$v8->executeString('PHP.test([0, 1, 2]);', "test", \V8Js::FLAG_FORCE_ARRAY);
} catch (V8JsScriptException $e) {
var_dump($e->getMessage());
}
try {
$v8->executeString('PHP.test({ "0" : "0", "1" : "1", "2" : "2" });', "test", \V8Js::FLAG_FORCE_ARRAY);
} catch (V8JsScriptException $e) {
var_dump($e->getMessage());
}
try {
$v8->executeString('PHP.test({ "0" : "foo", "1" : "bar", "2" : "baz" });', "test", \V8Js::FLAG_FORCE_ARRAY);
} catch (V8JsScriptException $e) {
var_dump($e->getMessage());
}
try {
$v8->executeString('PHP.test({ "foo" : "0", "bar" : "1", "baz" : "2" });', "test", \V8Js::FLAG_FORCE_ARRAY);
} catch (V8JsScriptException $e) {
var_dump($e->getMessage());
}
try {
// includes gap
$v8->executeString('PHP.test({ "0" : "0", "2" : "2", "3" : "3" });', "test", \V8Js::FLAG_FORCE_ARRAY);
} catch (V8JsScriptException $e) {
var_dump($e->getMessage());
}
try {
// mixed key types
$v8->executeString('PHP.test({ "0" : "0", "bar" : "1", "2" : "2" });', "test", \V8Js::FLAG_FORCE_ARRAY);
} catch (V8JsScriptException $e) {
var_dump($e->getMessage());
}
?>
===EOF===
--EXPECT--
array(3) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(2)
}
array(3) {
[0]=>
string(1) "0"
[1]=>
string(1) "1"
[2]=>
string(1) "2"
}
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "bar"
[2]=>
string(3) "baz"
}
array(3) {
["foo"]=>
string(1) "0"
["bar"]=>
string(1) "1"
["baz"]=>
string(1) "2"
}
array(3) {
[0]=>
string(1) "0"
[2]=>
string(1) "2"
[3]=>
string(1) "3"
}
array(3) {
[0]=>
string(1) "0"
[2]=>
string(1) "2"
["bar"]=>
string(1) "1"
}
===EOF===