1--TEST--
2Test decbin() function : usage variations - different data types as $number arg
3--INI--
4precision=14
5--SKIPIF--
6<?php
7if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
8?>
9--FILE--
10<?php
11/* Prototype  : string decbin  ( int $number  )
12 * Description: Decimal to binary.
13 * Source code: ext/standard/math.c
14 */
15
16echo "*** Testing decbin() : usage variations ***\n";
17//get an unset variable
18$unset_var = 10;
19unset ($unset_var);
20
21// heredoc string
22$heredoc = <<<EOT
23abc
24xyz
25EOT;
26
27// get a class
28class classA
29{
30}
31
32// get a resource variable
33$fp = fopen(__FILE__, "r");
34
35$inputs = array(
36       // int data
37/*1*/  0,
38       1,
39       12345,
40       -2345,
41       18446744073709551615,  // largest decimal
42       18446744073709551616,
43
44       // float data
45/*7*/  10.5,
46       -10.5,
47       12.3456789000e10,
48       12.3456789000E-10,
49       .5,
50
51       // null data
52/*12*/ NULL,
53       null,
54
55       // boolean data
56/*14*/ true,
57       false,
58       TRUE,
59       FALSE,
60
61       // empty data
62/*18*/ "",
63       '',
64       array(),
65
66       // string data
67/*21*/ "abcxyz",
68       'abcxyz',
69       $heredoc,
70
71       // object data
72/*24*/ new classA(),
73
74       // undefined data
75/*25*/ @$undefined_var,
76
77       // unset data
78/*26*/ @$unset_var,
79
80       // resource variable
81/*27*/ $fp
82);
83
84// loop through each element of $inputs to check the behaviour of decbin()
85$iterator = 1;
86foreach($inputs as $input) {
87	echo "\n-- Iteration $iterator --\n";
88	var_dump(decbin($input));
89	$iterator++;
90};
91fclose($fp);
92?>
93===Done===
94--EXPECTF--
95*** Testing decbin() : usage variations ***
96
97-- Iteration 1 --
98string(1) "0"
99
100-- Iteration 2 --
101string(1) "1"
102
103-- Iteration 3 --
104string(14) "11000000111001"
105
106-- Iteration 4 --
107string(64) "1111111111111111111111111111111111111111111111111111011011010111"
108
109-- Iteration 5 --
110string(1) "0"
111
112-- Iteration 6 --
113string(1) "0"
114
115-- Iteration 7 --
116string(4) "1010"
117
118-- Iteration 8 --
119string(64) "1111111111111111111111111111111111111111111111111111111111110110"
120
121-- Iteration 9 --
122string(37) "1110010111110100110010001101000001000"
123
124-- Iteration 10 --
125string(1) "0"
126
127-- Iteration 11 --
128string(1) "0"
129
130-- Iteration 12 --
131string(1) "0"
132
133-- Iteration 13 --
134string(1) "0"
135
136-- Iteration 14 --
137string(1) "1"
138
139-- Iteration 15 --
140string(1) "0"
141
142-- Iteration 16 --
143string(1) "1"
144
145-- Iteration 17 --
146string(1) "0"
147
148-- Iteration 18 --
149string(1) "0"
150
151-- Iteration 19 --
152string(1) "0"
153
154-- Iteration 20 --
155string(1) "0"
156
157-- Iteration 21 --
158string(1) "0"
159
160-- Iteration 22 --
161string(1) "0"
162
163-- Iteration 23 --
164string(1) "0"
165
166-- Iteration 24 --
167
168Notice: Object of class classA could not be converted to int in %s on line %d
169string(1) "1"
170
171-- Iteration 25 --
172string(1) "0"
173
174-- Iteration 26 --
175string(1) "0"
176
177-- Iteration 27 --
178string(%d) "%d"
179===Done===