Annotation of embedaddon/php/ext/standard/tests/math/log_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test log() function : usage variations - different data types as $base argument
3: --FILE--
4: <?php
5: /* Prototype : float log ( float $arg [, float $base ] )
6: * Description: Natural logarithm.
7: * Source code: ext/standard/math.c
8: */
9:
10: echo "*** Testing log() : 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 class
23: class classA
24: {
25: }
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: 2147483647,
37:
38: // float data
39: /*6*/ 10.5,
40: -10.5,
41: 12.3456789000e10,
42: 12.3456789000E-10,
43: .5,
44:
45: // null data
46: /*11*/ NULL,
47: null,
48:
49: // boolean data
50: /*13*/ true,
51: false,
52: TRUE,
53: FALSE,
54:
55: // empty data
56: /*17*/ "",
57: '',
58: array(),
59:
60: // string data
61: /*20*/ "abcxyz",
62: 'abcxyz',
63: $heredoc,
64:
65: // object data
66: /*23*/ new classA(),
67:
68: // undefined data
69: /*24*/ @$undefined_var,
70:
71: // unset data
72: /*25*/ @$unset_var,
73:
74: // resource variable
75: /*26*/ $fp
76: );
77:
78: // loop through each element of $inputs to check the behaviour of log()
79: $iterator = 1;
80: foreach($inputs as $input) {
81: echo "\n-- Iteration $iterator --\n";
82: var_dump(log(3.14, $input));
83: $iterator++;
84: };
85: fclose($fp);
86: ?>
87: ===Done===
88: --EXPECTF--
89: *** Testing log() : usage variations ***
90:
91: -- Iteration 1 --
92:
93: Warning: log(): base must be greater than 0 in %s on line %d
94: bool(false)
95:
96: -- Iteration 2 --
97: float(NAN)
98:
99: -- Iteration 3 --
100: float(0.12145441273706)
101:
102: -- Iteration 4 --
103:
104: Warning: log(): base must be greater than 0 in %s on line %d
105: bool(false)
106:
107: -- Iteration 5 --
108: float(0.053250469650086)
109:
110: -- Iteration 6 --
111: float(0.48661854224853)
112:
113: -- Iteration 7 --
114:
115: Warning: log(): base must be greater than 0 in %s on line %d
116: bool(false)
117:
118: -- Iteration 8 --
119: float(0.044802684673473)
120:
121: -- Iteration 9 --
122: float(-0.055781611216686)
123:
124: -- Iteration 10 --
125: float(-1.6507645591169)
126:
127: -- Iteration 11 --
128:
129: Warning: log(): base must be greater than 0 in %s on line %d
130: bool(false)
131:
132: -- Iteration 12 --
133:
134: Warning: log(): base must be greater than 0 in %s on line %d
135: bool(false)
136:
137: -- Iteration 13 --
138: float(NAN)
139:
140: -- Iteration 14 --
141:
142: Warning: log(): base must be greater than 0 in %s on line %d
143: bool(false)
144:
145: -- Iteration 15 --
146: float(NAN)
147:
148: -- Iteration 16 --
149:
150: Warning: log(): base must be greater than 0 in %s on line %d
151: bool(false)
152:
153: -- Iteration 17 --
154:
155: Warning: log() expects parameter 2 to be double, string given in %s on line %d
156: NULL
157:
158: -- Iteration 18 --
159:
160: Warning: log() expects parameter 2 to be double, string given in %s on line %d
161: NULL
162:
163: -- Iteration 19 --
164:
165: Warning: log() expects parameter 2 to be double, array given in %s on line %d
166: NULL
167:
168: -- Iteration 20 --
169:
170: Warning: log() expects parameter 2 to be double, string given in %s on line %d
171: NULL
172:
173: -- Iteration 21 --
174:
175: Warning: log() expects parameter 2 to be double, string given in %s on line %d
176: NULL
177:
178: -- Iteration 22 --
179:
180: Warning: log() expects parameter 2 to be double, string given in %s on line %d
181: NULL
182:
183: -- Iteration 23 --
184:
185: Warning: log() expects parameter 2 to be double, object given in %s on line %d
186: NULL
187:
188: -- Iteration 24 --
189:
190: Warning: log(): base must be greater than 0 in %s on line %d
191: bool(false)
192:
193: -- Iteration 25 --
194:
195: Warning: log(): base must be greater than 0 in %s on line %d
196: bool(false)
197:
198: -- Iteration 26 --
199:
200: Warning: log() expects parameter 2 to be double, resource given in %s on line %d
201: NULL
202: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>