Annotation of embedaddon/php/ext/standard/tests/math/hexdec_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test hexdec() function : usage variations - different data types as $number arg
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: /* Prototype : number hexdec ( string $hex_string )
12: * Description: Returns the decimal equivalent of the hexadecimal number represented by the hex_string argument.
13: * Source code: ext/standard/math.c
14: */
15:
16: echo "*** Testing hexdec() : usage variations ***\n";
17: //get an unset variable
18: $unset_var = 10;
19: unset ($unset_var);
20:
21: // heredoc string
22: $heredoc = <<<EOT
23: abc
24: xyz
25: EOT;
26:
27: // get a resource variable
28: $fp = fopen(__FILE__, "r");
29:
30: $inputs = array(
31: // int data
32: /*1*/ 0,
33: 1,
34: 12345,
35: -2345,
36: 4294967295, // largest decimal
37: 4294967296,
38:
39: // float data
40: /*7*/ 10.5,
41: -10.5,
42: 12.3456789000e10,
43: 12.3456789000E-10,
44: .5,
45:
46: // null data
47: /*12*/ NULL,
48: null,
49:
50: // boolean data
51: /*14*/ true,
52: false,
53: TRUE,
54: FALSE,
55:
56: // empty data
57: /*18*/ "",
58: '',
59: array(),
60:
61: // string data
62: /*21*/ "abcxyz",
63: 'abcxyz',
64: $heredoc,
65:
66: // undefined data
67: /*24*/ @$undefined_var,
68:
69: // unset data
70: /*25*/ @$unset_var,
71:
72: // resource variable
73: /*26*/ $fp
74: );
75:
76: // loop through each element of $inputs to check the behaviour of hexdec()
77: $iterator = 1;
78: foreach($inputs as $input) {
79: echo "\n-- Iteration $iterator --\n";
80: var_dump(hexdec($input));
81: $iterator++;
82: };
83: fclose($fp);
84: ?>
85: ===Done===
86: --EXPECTF--
87: *** Testing hexdec() : usage variations ***
88:
89: -- Iteration 1 --
90: int(0)
91:
92: -- Iteration 2 --
93: int(1)
94:
95: -- Iteration 3 --
96: int(74565)
97:
98: -- Iteration 4 --
99: int(9029)
100:
101: -- Iteration 5 --
102: float(285960729237)
103:
104: -- Iteration 6 --
105: float(285960729238)
106:
107: -- Iteration 7 --
108: int(261)
109:
110: -- Iteration 8 --
111: int(261)
112:
113: -- Iteration 9 --
114: float(20015998341120)
115:
116: -- Iteration 10 --
117: float(1250999896553)
118:
119: -- Iteration 11 --
120: int(5)
121:
122: -- Iteration 12 --
123: int(0)
124:
125: -- Iteration 13 --
126: int(0)
127:
128: -- Iteration 14 --
129: int(1)
130:
131: -- Iteration 15 --
132: int(0)
133:
134: -- Iteration 16 --
135: int(1)
136:
137: -- Iteration 17 --
138: int(0)
139:
140: -- Iteration 18 --
141: int(0)
142:
143: -- Iteration 19 --
144: int(0)
145:
146: -- Iteration 20 --
147:
148: Notice: Array to string conversion in %s on line %d
149: int(170)
150:
151: -- Iteration 21 --
152: int(2748)
153:
154: -- Iteration 22 --
155: int(2748)
156:
157: -- Iteration 23 --
158: int(2748)
159:
160: -- Iteration 24 --
161: int(0)
162:
163: -- Iteration 25 --
164: int(0)
165:
166: -- Iteration 26 --
167: %s
168: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>