Skip to content

Commit 5dae1e1

Browse files
committed
Split var_dump tests
So that these aren't huge mega tests
1 parent 83090b4 commit 5dae1e1

15 files changed

+671
-3098
lines changed

ext/standard/tests/general_functions/var_dump.phpt

Lines changed: 0 additions & 1549 deletions
This file was deleted.

ext/standard/tests/general_functions/var_dump_64bit.phpt

Lines changed: 0 additions & 1549 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Test var_dump() function with circular array
3+
--FILE--
4+
<?php
5+
6+
$a1 = [];
7+
$a2 = [&$a1];
8+
$a1[] =& $a2;
9+
10+
var_dump($a2);
11+
12+
?>
13+
--EXPECT--
14+
array(1) {
15+
[0]=>
16+
&array(1) {
17+
[0]=>
18+
*RECURSION*
19+
}
20+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
--TEST--
2+
Test var_dump() function with arrays
3+
--INI--
4+
precision=14
5+
--FILE--
6+
<?php
7+
8+
$values = [
9+
[],
10+
[null],
11+
[false],
12+
[true],
13+
[''],
14+
[[], []],
15+
[[1, 2], ['a', 'b']],
16+
[1 => 'One'],
17+
["test" => "is_array"],
18+
[0],
19+
[-1],
20+
[10.5, 5.6],
21+
['string', 'test'],
22+
];
23+
24+
foreach ($values as $value) {
25+
var_dump($value);
26+
}
27+
28+
?>
29+
--EXPECT--
30+
array(0) {
31+
}
32+
array(1) {
33+
[0]=>
34+
NULL
35+
}
36+
array(1) {
37+
[0]=>
38+
bool(false)
39+
}
40+
array(1) {
41+
[0]=>
42+
bool(true)
43+
}
44+
array(1) {
45+
[0]=>
46+
string(0) ""
47+
}
48+
array(2) {
49+
[0]=>
50+
array(0) {
51+
}
52+
[1]=>
53+
array(0) {
54+
}
55+
}
56+
array(2) {
57+
[0]=>
58+
array(2) {
59+
[0]=>
60+
int(1)
61+
[1]=>
62+
int(2)
63+
}
64+
[1]=>
65+
array(2) {
66+
[0]=>
67+
string(1) "a"
68+
[1]=>
69+
string(1) "b"
70+
}
71+
}
72+
array(1) {
73+
[1]=>
74+
string(3) "One"
75+
}
76+
array(1) {
77+
["test"]=>
78+
string(8) "is_array"
79+
}
80+
array(1) {
81+
[0]=>
82+
int(0)
83+
}
84+
array(1) {
85+
[0]=>
86+
int(-1)
87+
}
88+
array(2) {
89+
[0]=>
90+
float(10.5)
91+
[1]=>
92+
float(5.6)
93+
}
94+
array(2) {
95+
[0]=>
96+
string(6) "string"
97+
[1]=>
98+
string(4) "test"
99+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Test var_dump() function with booleans
3+
--FILE--
4+
<?php
5+
6+
$values = [
7+
'true' => true,
8+
'false' => false,
9+
];
10+
11+
foreach ($values as $key => $value) {
12+
echo "$key:\n";
13+
var_dump($value);
14+
}
15+
16+
?>
17+
DONE
18+
--EXPECT--
19+
true:
20+
bool(true)
21+
false:
22+
bool(false)
23+
DONE
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
--TEST--
2+
Test var_dump() function with floats
3+
--INI--
4+
precision=14
5+
--FILE--
6+
<?php
7+
8+
function check_var_dump( $variables ) {
9+
$counter = 1;
10+
foreach( $variables as $variable ) {
11+
echo "-- Iteration $counter --\n";
12+
var_dump($variable);
13+
$counter++;
14+
}
15+
}
16+
17+
$floats = [
18+
-0.0,
19+
+0.0,
20+
1.234,
21+
-1.234,
22+
-2.000000,
23+
000002.00,
24+
-.5,
25+
.567,
26+
-.6700000e-3,
27+
.6700000e+3,
28+
-4.10003e-3,
29+
4.100003e-3,
30+
1e5,
31+
-1e5,
32+
1e-5,
33+
-1e-5,
34+
1e+5,
35+
-1e+5,
36+
];
37+
check_var_dump($floats);
38+
39+
?>
40+
--EXPECT--
41+
-- Iteration 1 --
42+
float(-0)
43+
-- Iteration 2 --
44+
float(0)
45+
-- Iteration 3 --
46+
float(1.234)
47+
-- Iteration 4 --
48+
float(-1.234)
49+
-- Iteration 5 --
50+
float(-2)
51+
-- Iteration 6 --
52+
float(2)
53+
-- Iteration 7 --
54+
float(-0.5)
55+
-- Iteration 8 --
56+
float(0.567)
57+
-- Iteration 9 --
58+
float(-0.00067)
59+
-- Iteration 10 --
60+
float(670)
61+
-- Iteration 11 --
62+
float(-0.00410003)
63+
-- Iteration 12 --
64+
float(0.004100003)
65+
-- Iteration 13 --
66+
float(100000)
67+
-- Iteration 14 --
68+
float(-100000)
69+
-- Iteration 15 --
70+
float(1.0E-5)
71+
-- Iteration 16 --
72+
float(-1.0E-5)
73+
-- Iteration 17 --
74+
float(100000)
75+
-- Iteration 18 --
76+
float(-100000)
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
--TEST--
2+
Test var_dump() function with integers
3+
--INI--
4+
precision=14
5+
--FILE--
6+
<?php
7+
8+
function check_var_dump( $variables ) {
9+
$counter = 1;
10+
foreach( $variables as $variable ) {
11+
echo "-- Iteration $counter --\n";
12+
var_dump($variable);
13+
$counter++;
14+
}
15+
}
16+
17+
$integers = [
18+
0, // zero as argument
19+
000000123, //octal value of 83
20+
123000000,
21+
-00000123, //octal value of 83
22+
-12300000,
23+
range(1,10), // positive values
24+
range(-1,-10), // negative values
25+
+2147483647, // max 32bit integer
26+
-2147483647, // min 32bit integer
27+
];
28+
29+
check_var_dump($integers);
30+
31+
?>
32+
--EXPECT--
33+
-- Iteration 1 --
34+
int(0)
35+
-- Iteration 2 --
36+
int(83)
37+
-- Iteration 3 --
38+
int(123000000)
39+
-- Iteration 4 --
40+
int(-83)
41+
-- Iteration 5 --
42+
int(-12300000)
43+
-- Iteration 6 --
44+
array(10) {
45+
[0]=>
46+
int(1)
47+
[1]=>
48+
int(2)
49+
[2]=>
50+
int(3)
51+
[3]=>
52+
int(4)
53+
[4]=>
54+
int(5)
55+
[5]=>
56+
int(6)
57+
[6]=>
58+
int(7)
59+
[7]=>
60+
int(8)
61+
[8]=>
62+
int(9)
63+
[9]=>
64+
int(10)
65+
}
66+
-- Iteration 7 --
67+
array(10) {
68+
[0]=>
69+
int(-1)
70+
[1]=>
71+
int(-2)
72+
[2]=>
73+
int(-3)
74+
[3]=>
75+
int(-4)
76+
[4]=>
77+
int(-5)
78+
[5]=>
79+
int(-6)
80+
[6]=>
81+
int(-7)
82+
[7]=>
83+
int(-8)
84+
[8]=>
85+
int(-9)
86+
[9]=>
87+
int(-10)
88+
}
89+
-- Iteration 8 --
90+
int(2147483647)
91+
-- Iteration 9 --
92+
int(-2147483647)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Test var_dump() function with 32 bit integers
3+
--INI--
4+
precision=14
5+
--SKIPIF--
6+
<?php
7+
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
8+
?>
9+
--FILE--
10+
<?php
11+
12+
function check_var_dump( $variables ) {
13+
$counter = 1;
14+
foreach( $variables as $variable ) {
15+
echo "-- Iteration $counter --\n";
16+
var_dump($variable);
17+
$counter++;
18+
}
19+
}
20+
21+
$integers = [
22+
+2147483648, // max 32bit positive integer + 1
23+
-2147483648, // min 32bit positive integer - 1
24+
];
25+
26+
check_var_dump($integers);
27+
28+
?>
29+
--EXPECT--
30+
-- Iteration 1 --
31+
float(2147483648)
32+
-- Iteration 2 --
33+
float(-2147483648)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--TEST--
2+
Test var_dump() function with 64 bit integers
3+
--INI--
4+
precision=14
5+
--SKIPIF--
6+
<?php
7+
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
8+
?>
9+
--FILE--
10+
<?php
11+
12+
function check_var_dump( $variables ) {
13+
$counter = 1;
14+
foreach( $variables as $variable ) {
15+
echo "-- Iteration $counter --\n";
16+
var_dump($variable);
17+
$counter++;
18+
}
19+
}
20+
21+
$integers = [
22+
0x7FFFFFFF, // max positive hexadecimal integer
23+
-0x80000000, // min range of hexadecimal integer
24+
017777777777, // max positive octal integer
25+
-020000000000, // min range of octal integer
26+
+2147483648, // max 32bit positive integer + 1
27+
-2147483648, // min 32bit positive integer - 1
28+
];
29+
30+
check_var_dump($integers);
31+
32+
?>
33+
--EXPECT--
34+
-- Iteration 1 --
35+
int(2147483647)
36+
-- Iteration 2 --
37+
int(-2147483648)
38+
-- Iteration 3 --
39+
int(2147483647)
40+
-- Iteration 4 --
41+
int(-2147483648)
42+
-- Iteration 5 --
43+
int(2147483648)
44+
-- Iteration 6 --
45+
int(-2147483648)

0 commit comments

Comments
 (0)