forked from facebookarchive/phpembed
/
test.php
136 lines (103 loc) · 3.12 KB
/
test.php
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?
// test.php - file for testing php embed
// Copyright (c) 2007 Andrew Bosworth, Facebook, inc
// Modified by Dmitry Zenovich <dzenovich@gmail.com>
// All rights reserved
//
// This file is loaded by the PHP interpreter compiled into test
// we set a larger memory limit just in case
ini_set('memory_limit', '100M');
function foo_void(){
echo "passed.\n";
ob_flush();
return;
}
function foo_long(){
return 3;
}
function foo_bool(){
return true;
}
function foo_double(){
return 3.14;
}
function foo_string(){
return "hello world\n";
}
function foo_string_ex(){
return "hello \0world\n";
}
function foo_vector_long(){
return array(2, 3, 4, 3);
}
function foo_vector_bool(){
return array(true, false, true);
}
function foo_vector_double(){
return array(2.71, 3.14, 4.0, 3.14);
}
function foo_vector_string(){
return array("two", "three", "four\0\1", "three");
}
function foo_assoc_string(){
return array("two" => "dos", "three" => "tres", "four\0\1" => "quatro\0\1");
}
function foo_assoc_double(){
return array("two" => 2.71, "three" => 3.14, "four\0\1" => 4.0, "five" => 3.14);
}
function foo_assoc_long(){
return array("two" => 2, "three" => 3, "four\0\1" => 4, "five" => 3);
}
function foo_assoc_bool(){
return array("two" => true, "three" => false, "four\0\1" => true);
}
function foo_index_string(){
return array(2 => "two", 3 => "three", 4 => "four\0\1", 5 => "three");
}
function foo_index_double(){
return array(2 => 2.71, 3 => 3.14, 4 => 4.0, 5 => 3.14);
}
function foo_index_long(){
return array(2 => 2, 3 => 3, 4 => 4, 6 => 6);
}
function foo_index_bool(){
return array(2 => true, 3 => false, 4 => true);
}
function foo_complex_array(){
return array(array(array("1" => 1),2 => "2"), array("x" => 3.14), 4 => false, "a\0.\0.a" => "b\0.\0.b\1");
}
function bar($l, $d, $c, $b, $i, $u, $s){
return($l == 2 && $d == 3.14 && $c == 'four' && $b && $i == 5 && $u == 6 && $s == "a.\0.\0.a");
}
function verify_assoc($a){
if(!isset($a["a"]) || !isset($a["bee"]) || !isset($a["cee\0\1"]))
return false;
$first = $a["a"];
$second = $a["bee"];
$third = $a["cee\0\1"];
return($first == 1 && $second == "tw\0\1" && $third == 3);
}
function verify_index($a){
return(isset($a[5]) && isset($a[2]) && isset($a[10]) && $a[5] == "one" && $a[2] == "abc" && $a[10] == 2.71);
}
function verify_mixed($a){
return(isset($a[5]) && isset($a[2]) && isset($a[10]) && isset($a["what"]) &&
$a[5] == "one" && $a[2] == "abc" && $a[10] == 2.71 && $a["what"] == "yo");
}
function verify_enum($a){
return(isset($a[5]) && isset($a[2]) && isset($a[10]) && isset($a["what"]) && isset($a[11]) &&
$a[5] == "one" && $a[2] == "abc" && $a[10] == 2.71 && $a["what"] == "yo" &&
$a[11] == 2.1413);
}
function verify_nested($a){
return(verify_assoc($a[0]) && verify_enum($a[1]));
}
function verify_remove($a, $b){
if(isset($a["a"]) || isset($b[5]) || isset($a["cee\0\1"]))
return false;
if(!isset($a["bee"]) || !isset($b[2]) || !isset($b[10]) || !isset($b[11]))
return false;
$first = $a["bee"];
return($first == "tw\0\1" && $b[2] == "abc" && $b[10] == 2.71 && $b[11] == 2.1413);
}
?>