1--TEST--
2array_pad() tests
3--FILE--
4<?php
5
6var_dump(array_pad(array(), 1, 0));
7
8var_dump(array_pad(array(), 0, 0));
9var_dump(array_pad(array(), -1, 0));
10var_dump(array_pad(array("", -1, 2.0), 5, 0));
11var_dump(array_pad(array("", -1, 2.0), 5, array()));
12var_dump(array_pad(array("", -1, 2.0), 2, array()));
13var_dump(array_pad(array("", -1, 2.0), -3, array()));
14var_dump(array_pad(array("", -1, 2.0), -4, array()));
15
16try {
17    var_dump(array_pad(array("", -1, 2.0), 2000000, 0));
18} catch (\ValueError $e) {
19    echo $e->getMessage() . "\n";
20}
21
22?>
23--EXPECT--
24array(1) {
25  [0]=>
26  int(0)
27}
28array(0) {
29}
30array(1) {
31  [0]=>
32  int(0)
33}
34array(5) {
35  [0]=>
36  string(0) ""
37  [1]=>
38  int(-1)
39  [2]=>
40  float(2)
41  [3]=>
42  int(0)
43  [4]=>
44  int(0)
45}
46array(5) {
47  [0]=>
48  string(0) ""
49  [1]=>
50  int(-1)
51  [2]=>
52  float(2)
53  [3]=>
54  array(0) {
55  }
56  [4]=>
57  array(0) {
58  }
59}
60array(3) {
61  [0]=>
62  string(0) ""
63  [1]=>
64  int(-1)
65  [2]=>
66  float(2)
67}
68array(3) {
69  [0]=>
70  string(0) ""
71  [1]=>
72  int(-1)
73  [2]=>
74  float(2)
75}
76array(4) {
77  [0]=>
78  array(0) {
79  }
80  [1]=>
81  string(0) ""
82  [2]=>
83  int(-1)
84  [3]=>
85  float(2)
86}
87array_pad(): Argument #2 ($length) must be less than or equal to 1048576
88