1--TEST--
2Test expm1() function : usage variations - different data types as $arg argument
3--INI--
4precision=14
5--FILE--
6<?php
7
8/* Prototype  : float expm1  ( float $arg  )
9 * Description: Returns exp(number) - 1, computed in a way that is accurate even
10 *              when the value of number is close to zero.
11 * Source code: ext/standard/math.c
12 */
13
14echo "*** Testing expm1() : usage variations ***\n";
15
16//get an unset variable
17$unset_var = 10;
18unset ($unset_var);
19
20// heredoc string
21$heredoc = <<<EOT
22abc
23xyz
24EOT;
25
26// get a class
27class classA
28{
29}
30
31// get a resource variable
32$fp = fopen(__FILE__, "r");
33
34// unexpected values to be passed to $arg argument
35$inputs = array(
36       // int data
37/*1*/  0,
38       1,
39       12345,
40       -2345,
41
42       // float data
43/*5*/  10.5,
44       -10.5,
45       12.3456789E4,
46       12.3456789E-4,
47       .5,
48
49       // null data
50/*10*/ NULL,
51       null,
52
53       // boolean data
54/*12*/ true,
55       false,
56       TRUE,
57       FALSE,
58
59       // empty data
60/*16*/ "",
61       '',
62       array(),
63
64       // string data
65/*19*/ "abcxyz",
66       'abcxyz',
67       $heredoc,
68
69       // array data
70       array(),
71       array(1,2,4),
72
73       // object data
74/*24*/ new classA(),
75
76       // undefined data
77/*25*/ @$undefined_var,
78
79       // unset data
80/*26*/ @$unset_var,
81
82       // resource variable
83/*27*/ $fp
84);
85
86// loop through each element of $inputs to check the behaviour of expm1()
87$iterator = 1;
88foreach($inputs as $input) {
89	echo "\n-- Iteration $iterator --\n";
90	var_dump(expm1($input));
91	$iterator++;
92};
93fclose($fp);
94?>
95===Done===
96--EXPECTF--
97*** Testing expm1() : usage variations ***
98
99-- Iteration 1 --
100float(0)
101
102-- Iteration 2 --
103float(1.718281828459)
104
105-- Iteration 3 --
106float(INF)
107
108-- Iteration 4 --
109float(-1)
110
111-- Iteration 5 --
112float(36314.502674247)
113
114-- Iteration 6 --
115float(-0.99997246355065)
116
117-- Iteration 7 --
118float(INF)
119
120-- Iteration 8 --
121float(0.0012353302826471)
122
123-- Iteration 9 --
124float(0.64872127070013)
125
126-- Iteration 10 --
127float(0)
128
129-- Iteration 11 --
130float(0)
131
132-- Iteration 12 --
133float(1.718281828459)
134
135-- Iteration 13 --
136float(0)
137
138-- Iteration 14 --
139float(1.718281828459)
140
141-- Iteration 15 --
142float(0)
143
144-- Iteration 16 --
145
146Warning: expm1() expects parameter 1 to be double, string given in %s on line %d
147NULL
148
149-- Iteration 17 --
150
151Warning: expm1() expects parameter 1 to be double, string given in %s on line %d
152NULL
153
154-- Iteration 18 --
155
156Warning: expm1() expects parameter 1 to be double, array given in %s on line %d
157NULL
158
159-- Iteration 19 --
160
161Warning: expm1() expects parameter 1 to be double, string given in %s on line %d
162NULL
163
164-- Iteration 20 --
165
166Warning: expm1() expects parameter 1 to be double, string given in %s on line %d
167NULL
168
169-- Iteration 21 --
170
171Warning: expm1() expects parameter 1 to be double, string given in %s on line %d
172NULL
173
174-- Iteration 22 --
175
176Warning: expm1() expects parameter 1 to be double, array given in %s on line %d
177NULL
178
179-- Iteration 23 --
180
181Warning: expm1() expects parameter 1 to be double, array given in %s on line %d
182NULL
183
184-- Iteration 24 --
185
186Warning: expm1() expects parameter 1 to be double, object given in %s on line %d
187NULL
188
189-- Iteration 25 --
190float(0)
191
192-- Iteration 26 --
193float(0)
194
195-- Iteration 27 --
196
197Warning: expm1() expects parameter 1 to be double, resource given in %s on line %d
198NULL
199===Done===