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
11echo "*** Testing decbin() : usage variations ***\n";
12//get an unset variable
13$unset_var = 10;
14unset ($unset_var);
15
16// heredoc string
17$heredoc = <<<EOT
18abc
19xyz
20EOT;
21
22// get a class
23class 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       18446744073709551615,  // largest decimal
37       18446744073709551616,
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       // object data
67/*24*/ new classA(),
68
69       // undefined data
70/*25*/ @$undefined_var,
71
72       // unset data
73/*26*/ @$unset_var,
74
75       // resource variable
76/*27*/ $fp
77);
78
79// loop through each element of $inputs to check the behaviour of decbin()
80foreach($inputs as $i => $input) {
81    $iterator = $i + 1;
82    echo "\n-- Iteration $iterator --\n";
83    try {
84        var_dump(decbin($input));
85    } catch (TypeError $exception) {
86        echo $exception->getMessage() . "\n";
87    }
88}
89fclose($fp);
90?>
91--EXPECT--
92*** Testing decbin() : usage variations ***
93
94-- Iteration 1 --
95string(1) "0"
96
97-- Iteration 2 --
98string(1) "1"
99
100-- Iteration 3 --
101string(14) "11000000111001"
102
103-- Iteration 4 --
104string(64) "1111111111111111111111111111111111111111111111111111011011010111"
105
106-- Iteration 5 --
107decbin(): Argument #1 ($num) must be of type int, float given
108
109-- Iteration 6 --
110decbin(): Argument #1 ($num) must be of type int, float given
111
112-- Iteration 7 --
113string(4) "1010"
114
115-- Iteration 8 --
116string(64) "1111111111111111111111111111111111111111111111111111111111110110"
117
118-- Iteration 9 --
119string(37) "1110010111110100110010001101000001000"
120
121-- Iteration 10 --
122string(1) "0"
123
124-- Iteration 11 --
125string(1) "0"
126
127-- Iteration 12 --
128string(1) "0"
129
130-- Iteration 13 --
131string(1) "0"
132
133-- Iteration 14 --
134string(1) "1"
135
136-- Iteration 15 --
137string(1) "0"
138
139-- Iteration 16 --
140string(1) "1"
141
142-- Iteration 17 --
143string(1) "0"
144
145-- Iteration 18 --
146decbin(): Argument #1 ($num) must be of type int, string given
147
148-- Iteration 19 --
149decbin(): Argument #1 ($num) must be of type int, string given
150
151-- Iteration 20 --
152decbin(): Argument #1 ($num) must be of type int, array given
153
154-- Iteration 21 --
155decbin(): Argument #1 ($num) must be of type int, string given
156
157-- Iteration 22 --
158decbin(): Argument #1 ($num) must be of type int, string given
159
160-- Iteration 23 --
161decbin(): Argument #1 ($num) must be of type int, string given
162
163-- Iteration 24 --
164decbin(): Argument #1 ($num) must be of type int, classA given
165
166-- Iteration 25 --
167string(1) "0"
168
169-- Iteration 26 --
170string(1) "0"
171
172-- Iteration 27 --
173decbin(): Argument #1 ($num) must be of type int, resource given
174