1--TEST--
2Test decoct() function : usage variations - different data types as $num arg
3--INI--
4precision=14
5--SKIPIF--
6<?php
7if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
8?>
9--FILE--
10<?php
11echo "*** Testing decoct() : usage variations ***\n";
12
13$inputs = [
14       // int data
15/*1*/  0,
16       1,
17       12345,
18       -2345,
19       4294967295,  // largest decimal
20       4294967296,
21
22       // float data
23/* 7*/ 12.3456789000e10,
24
25       // boolean data
26/* 8*/ true,
27       false,
28       TRUE,
29       FALSE,
30
31       // empty data
32/*12*/ "",
33       '',
34];
35
36// loop through each element of $inputs to check the behaviour of decoct()
37foreach ($inputs as $i => $input) {
38    $iterator = $i + 1;
39    echo "\n-- Iteration $iterator --\n";
40    try {
41        var_dump(decoct($input));
42    } catch (TypeError $exception) {
43        echo $exception->getMessage() . "\n";
44    }
45}
46
47?>
48--EXPECT--
49*** Testing decoct() : usage variations ***
50
51-- Iteration 1 --
52string(1) "0"
53
54-- Iteration 2 --
55string(1) "1"
56
57-- Iteration 3 --
58string(5) "30071"
59
60-- Iteration 4 --
61string(11) "37777773327"
62
63-- Iteration 5 --
64decoct(): Argument #1 ($num) must be of type int, float given
65
66-- Iteration 6 --
67decoct(): Argument #1 ($num) must be of type int, float given
68
69-- Iteration 7 --
70decoct(): Argument #1 ($num) must be of type int, float given
71
72-- Iteration 8 --
73string(1) "1"
74
75-- Iteration 9 --
76string(1) "0"
77
78-- Iteration 10 --
79string(1) "1"
80
81-- Iteration 11 --
82string(1) "0"
83
84-- Iteration 12 --
85decoct(): Argument #1 ($num) must be of type int, string given
86
87-- Iteration 13 --
88decoct(): Argument #1 ($num) must be of type int, string given
89