Annotation of embedaddon/php/ext/standard/tests/general_functions/var_export_basic3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test var_export() function with valid float values
3: --INI--
4: precision=14
5: --FILE--
6: <?php
7: /* Prototype : mixed var_export(mixed var [, bool return])
8: * Description: Outputs or returns a string representation of a variable
9: * Source code: ext/standard/var.c
10: * Alias to functions:
11: */
12:
13: echo "*** Testing var_export() with valid float values ***\n";
14: // different valid float vlaues
15: $valid_floats = array(
16: "-2147483649" => -2147483649, // float value
17: "2147483648" => 2147483648, // float value
18: "-0x80000001" => -0x80000001, // float value, beyond max negative int
19: "0x800000001" => 0x800000001, // float value, beyond max positive int
20: "020000000001" => 020000000001, // float value, beyond max positive int
21: "-020000000001" => -020000000001, // float value, beyond max negative int
22: "0.0" => 0.0,
23: "-0.1" => -0.1,
24: "10.0000000000000000005" => 10.0000000000000000005,
25: "10.5e+5" => 10.5e+5,
26: "1e5" => 1e5,
27: "1e-5" => 1e-5,
28: "1e+5" => 1e+5,
29: "1E5" => 1E5,
30: "1E+5" => 1E+5,
31: "1E-5" => 1E-5,
32: ".5e+7" => .5e+7,
33: ".6e-19" => .6e-19,
34: ".05E+44" => .05E+44,
35: ".0034E-30" => .0034E-30
36: );
37: /* Loop to check for above float values with var_export() */
38: echo "\n*** Output for float values ***\n";
39: foreach($valid_floats as $key => $float_value) {
40: echo "\n-- Iteration: $key --\n";
41: var_export( $float_value );
42: echo "\n";
43: var_export( $float_value, FALSE);
44: echo "\n";
45: var_dump( var_export( $float_value, TRUE) );
46: echo "\n";
47: }
48:
49: ?>
50: ===DONE===
51: --EXPECT--
52: *** Testing var_export() with valid float values ***
53:
54: *** Output for float values ***
55:
56: -- Iteration: -2147483649 --
57: -2147483649
58: -2147483649
59: string(11) "-2147483649"
60:
61:
62: -- Iteration: 2147483648 --
63: 2147483648
64: 2147483648
65: string(10) "2147483648"
66:
67:
68: -- Iteration: -0x80000001 --
69: -2147483649
70: -2147483649
71: string(11) "-2147483649"
72:
73:
74: -- Iteration: 0x800000001 --
75: 34359738369
76: 34359738369
77: string(11) "34359738369"
78:
79:
80: -- Iteration: 020000000001 --
81: 2147483649
82: 2147483649
83: string(10) "2147483649"
84:
85:
86: -- Iteration: -020000000001 --
87: -2147483649
88: -2147483649
89: string(11) "-2147483649"
90:
91:
92: -- Iteration: 0.0 --
93: 0
94: 0
95: string(1) "0"
96:
97:
98: -- Iteration: -0.1 --
99: -0.1
100: -0.1
101: string(4) "-0.1"
102:
103:
104: -- Iteration: 10.0000000000000000005 --
105: 10
106: 10
107: string(2) "10"
108:
109:
110: -- Iteration: 10.5e+5 --
111: 1050000
112: 1050000
113: string(7) "1050000"
114:
115:
116: -- Iteration: 1e5 --
117: 100000
118: 100000
119: string(6) "100000"
120:
121:
122: -- Iteration: 1e-5 --
123: 1.0E-5
124: 1.0E-5
125: string(6) "1.0E-5"
126:
127:
128: -- Iteration: 1e+5 --
129: 100000
130: 100000
131: string(6) "100000"
132:
133:
134: -- Iteration: 1E5 --
135: 100000
136: 100000
137: string(6) "100000"
138:
139:
140: -- Iteration: 1E+5 --
141: 100000
142: 100000
143: string(6) "100000"
144:
145:
146: -- Iteration: 1E-5 --
147: 1.0E-5
148: 1.0E-5
149: string(6) "1.0E-5"
150:
151:
152: -- Iteration: .5e+7 --
153: 5000000
154: 5000000
155: string(7) "5000000"
156:
157:
158: -- Iteration: .6e-19 --
159: 6.0E-20
160: 6.0E-20
161: string(7) "6.0E-20"
162:
163:
164: -- Iteration: .05E+44 --
165: 5.0E+42
166: 5.0E+42
167: string(7) "5.0E+42"
168:
169:
170: -- Iteration: .0034E-30 --
171: 3.4E-33
172: 3.4E-33
173: string(7) "3.4E-33"
174:
175: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>