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