Skip to content

Commit d0da616

Browse files
committed
Fix more tests
1 parent 7c52943 commit d0da616

File tree

12 files changed

+173
-78
lines changed

12 files changed

+173
-78
lines changed

ext/calendar/tests/bug80185.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ try {
1616
echo $ex->getMessage(), PHP_EOL;
1717
}
1818
?>
19-
--EXPECT--
19+
--EXPECTF--
2020
int(2170713600)
21+
22+
Deprecated: Implicit conversion to int from non-compatible float 106751993607888.640625 in %s on line %d
2123
int(9223372036854720000)
24+
25+
Deprecated: Implicit conversion to int from non-compatible float 106751993607889.640625 in %s on line %d
2226
jday must be between 2440588 and 106751993607888

ext/gd/tests/imagefilter.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ $SOURCE_IMG = $SAVE_DIR . "/test.png";
4545

4646
$im = imagecreatefrompng($SOURCE_IMG);
4747

48-
if (imagefilter($im, IMG_FILTER_COLORIZE, -127.12, -127.98, 127)) {
48+
if (imagefilter($im, IMG_FILTER_COLORIZE, -127, -127, 127)) {
4949
imagepng($im, $SAVE_DIR . "/IMG_FILTER_COLORIZE.png");
5050
echo "IMG_FILTER_COLORIZE success\n";
5151
unlink($SAVE_DIR . "/IMG_FILTER_COLORIZE.png");

ext/gd/tests/libgd00100.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $points = array(
3030
$x, $top,
3131
$x+2*$d, $top,
3232
$x+2*$d, $bot,
33-
$x+$d, ($top+$bot)/2,
33+
$x+$d, (int) (($top+$bot)/2),
3434
$x, $bot
3535
);
3636
imagefilledpolygon($im, $points, $yellow);

ext/gmp/tests/gmp_fact.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ try {
2323
echo $e->getMessage() . \PHP_EOL;
2424
}
2525

26-
var_dump(gmp_strval(gmp_fact(1.1)));
2726
var_dump(gmp_strval(gmp_fact(20)));
2827
var_dump(gmp_strval(gmp_fact("50")));
2928
var_dump(gmp_strval(gmp_fact("10")));
@@ -52,7 +51,6 @@ gmp_fact(): Argument #1 ($num) is not an integer string
5251
string(1) "1"
5352
gmp_fact(): Argument #1 ($num) must be greater than or equal to 0
5453
gmp_fact(): Argument #1 ($num) must be greater than or equal to 0
55-
string(1) "1"
5654
string(19) "2432902008176640000"
5755
string(65) "30414093201713378043612608166064768844377641568960512000000000000"
5856
string(7) "3628800"

ext/gmp/tests/gmp_intval.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ var_dump(gmp_intval("-1"));
99
var_dump(gmp_intval(-1));
1010
var_dump(gmp_intval(-2349828));
1111
var_dump(gmp_intval(2342344));
12-
var_dump(gmp_intval(1.0001));
1312

1413
$g = gmp_init("12345678");
1514
var_dump(gmp_intval($g));
@@ -42,7 +41,6 @@ int(-1)
4241
int(-1)
4342
int(-2349828)
4443
int(2342344)
45-
int(1)
4644
int(12345678)
4745
gmp_intval(): Argument #1 ($num) is not an integer string
4846
gmp_intval(): Argument #1 ($num) must be of type GMP|string|int, stdClass given

ext/standard/tests/strings/bug23894.phpt

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #23894 (sprintf() decimal specifiers problem) 32bit version
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
6+
?>
7+
--FILE--
8+
<?php
9+
$a = -12.3456;
10+
$test = sprintf("%04d", $a);
11+
var_dump($test, bin2hex($test));
12+
$test = sprintf("% 13u", $a);
13+
var_dump($test, bin2hex($test));
14+
?>
15+
--EXPECTF--
16+
Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d
17+
string(4) "-012"
18+
string(8) "2d303132"
19+
20+
Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d
21+
string(13) " 4294967284"
22+
string(26) "20202034323934393637323834"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #23894 (sprintf() decimal specifiers problem) 64bit version
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
6+
?>
7+
--FILE--
8+
<?php
9+
$a = -12.3456;
10+
$test = sprintf("%04d", $a);
11+
var_dump($test, bin2hex($test));
12+
$test = sprintf("% 13u", $a);
13+
var_dump($test, bin2hex($test));
14+
?>
15+
--EXPECTF--
16+
Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d
17+
string(4) "-012"
18+
string(8) "2d303132"
19+
20+
Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d
21+
string(20) "18446744073709551604"
22+
string(40) "3138343436373434303733373039353531363034"

ext/standard/tests/strings/sprintf_f_2.phpt

Lines changed: 37 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,6 @@ $format = 'The %2$s contains %1$d monkeys.
3333
That\'s a nice %2$s full of %1$d monkeys.';
3434
var_dump(sprintf($format, $num, $location));
3535

36-
/* example#5: various examples */
37-
$n = 43951789;
38-
$u = -43951789;
39-
$c = 65; // ASCII 65 is 'A'
40-
41-
// notice the double %%, this prints a literal '%' character
42-
var_dump(sprintf("%%b = '%b'", $n)); // binary representation
43-
var_dump(sprintf("%%c = '%c'", $c)); // print the ascii character, same as chr() function
44-
var_dump(sprintf("%%d = '%d'", $n)); // standard integer representation
45-
var_dump(sprintf("%%e = '%e'", $n)); // scientific notation
46-
var_dump(sprintf("%%u = '%u'", $n)); // unsigned integer representation of a positive integer
47-
var_dump(sprintf("%%u = '%u'", $u)); // unsigned integer representation of a negative integer
48-
var_dump(sprintf("%%f = '%f'", $n)); // floating point representation
49-
var_dump(sprintf("%%o = '%o'", $n)); // octal representation
50-
var_dump(sprintf("%%s = '%s'", $n)); // string representation
51-
var_dump(sprintf("%%x = '%x'", $n)); // hexadecimal representation (lower-case)
52-
var_dump(sprintf("%%X = '%X'", $n)); // hexadecimal representation (upper-case)
53-
54-
var_dump(sprintf("%%+d = '%+d'", $n)); // sign specifier on a positive integer
55-
var_dump(sprintf("%%+d = '%+d'", $u)); // sign specifier on a negative integer
56-
57-
5836
/* example#6: string specifiers */
5937
$s = 'monkey';
6038
$t = 'many monkeys';
@@ -80,37 +58,40 @@ $number = 362525200;
8058

8159
var_dump(sprintf("%.3e", $number)); // outputs 3.63e+8
8260
?>
83-
--EXPECTREGEX--
84-
string\(7\) \"100\.426\"
85-
string\(6\) \"100\.43\"
86-
string\(3\) \"100\"
87-
string\(3\) \"100\"
88-
string\(3\) \"144\"
89-
string\(3\) \"144\"
90-
string\(34\) \"There are 100 monkeys in the world\"
91-
string\(28\) \"The 100\.1 contains 0 monkeys\"
92-
string\(30\) \"The world contains 100 monkeys\"
93-
string\(76\) \"The world contains 100 monkeys.
94-
That's a nice world full of 100 monkeys\.\"
95-
string\(33\) \"%b = '10100111101010011010101101'\"
96-
string\(8\) \"%c = 'A'\"
97-
string\(15\) \"%d = '43951789'\"
98-
string\(18\) \"%e = '4\.395179e\+7'\"
99-
string\(15\) \"%u = '43951789'\"
100-
(string\(17\) \"%u = '4251015507'\"|string\(27\) \"%u = '18446744073665599827'\")
101-
string\(22\) \"%f = '43951789\.000000'\"
102-
string\(16\) \"%o = '247523255'\"
103-
string\(15\) \"%s = '43951789'\"
104-
string\(14\) \"%x = '29ea6ad'\"
105-
string\(14\) \"%X = '29EA6AD'\"
106-
string\(17\) \"%\+d = '\+43951789'\"
107-
string\(17\) \"%\+d = '-43951789'\"
108-
string\(8\) \"\[monkey\]\"
109-
string\(12\) \"\[ monkey\]\"
110-
string\(12\) \"\[monkey \]\"
111-
string\(12\) \"\[0000monkey\]\"
112-
string\(12\) \"\[####monkey\]\"
113-
string\(12\) \"\[many monke\]\"
114-
string\(10\) \"2006-12-18\"
115-
string\(6\) \"123\.10\"
116-
string\(8\) \"3\.625e\+8\"
61+
--EXPECTF--
62+
string(7) "100.426"
63+
string(6) "100.43"
64+
65+
Deprecated: Implicit conversion to int from non-compatible float 100.426000 in %s on line %d
66+
string(3) "100"
67+
68+
Deprecated: Implicit conversion to int from non-compatible float 100.900000 in %s on line %d
69+
string(3) "100"
70+
71+
Deprecated: Implicit conversion to int from non-compatible float 100.426000 in %s on line %d
72+
string(3) "144"
73+
74+
Deprecated: Implicit conversion to int from non-compatible float 100.900000 in %s on line %d
75+
string(3) "144"
76+
77+
Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d
78+
string(34) "There are 100 monkeys in the world"
79+
string(28) "The 100.1 contains 0 monkeys"
80+
81+
Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d
82+
string(30) "The world contains 100 monkeys"
83+
84+
Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d
85+
86+
Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d
87+
string(76) "The world contains 100 monkeys.
88+
That's a nice world full of 100 monkeys."
89+
string(8) "[monkey]"
90+
string(12) "[ monkey]"
91+
string(12) "[monkey ]"
92+
string(12) "[0000monkey]"
93+
string(12) "[####monkey]"
94+
string(12) "[many monke]"
95+
string(10) "2006-12-18"
96+
string(6) "123.10"
97+
string(8) "3.625e+8"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
sprintf %u With signed integer 32bit
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE != 4) {
6+
die("skip this test is for 32bit platform only");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
12+
/* example#5: various examples */
13+
$n = 43951789;
14+
$u = -43951789;
15+
16+
// notice the double %%, this prints a literal '%' character
17+
var_dump(sprintf("%%u = '%u'", $n)); // unsigned integer representation of a positive integer
18+
var_dump(sprintf("%%u = '%u'", $u)); // unsigned integer representation of a negative integer
19+
20+
?>
21+
--EXPECT--
22+
string(15) "%u = '43951789'"
23+
string(17) "%u = '4251015507'"
24+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
sprintf %u With signed integer 32bit
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE != 8) {
6+
die("skip this test is for 64bit platform only");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
12+
/* example#5: various examples */
13+
$n = 43951789;
14+
$u = -43951789;
15+
16+
// notice the double %%, this prints a literal '%' character
17+
var_dump(sprintf("%%u = '%u'", $n)); // unsigned integer representation of a positive integer
18+
var_dump(sprintf("%%u = '%u'", $u)); // unsigned integer representation of a negative integer
19+
20+
?>
21+
--EXPECT--
22+
string(15) "%u = '43951789'"
23+
string(27) "%u = '18446744073665599827'"
24+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
sprintf With signed integer
3+
--FILE--
4+
<?php
5+
6+
/* example#5: various examples */
7+
$n = 43951789;
8+
$u = -43951789;
9+
$c = 65; // ASCII 65 is 'A'
10+
11+
// notice the double %%, this prints a literal '%' character
12+
var_dump(sprintf("%%b = '%b'", $n)); // binary representation
13+
var_dump(sprintf("%%c = '%c'", $c)); // print the ascii character, same as chr() function
14+
var_dump(sprintf("%%d = '%d'", $n)); // standard integer representation
15+
var_dump(sprintf("%%e = '%e'", $n)); // scientific notation
16+
var_dump(sprintf("%%f = '%f'", $n)); // floating point representation
17+
var_dump(sprintf("%%o = '%o'", $n)); // octal representation
18+
var_dump(sprintf("%%s = '%s'", $n)); // string representation
19+
var_dump(sprintf("%%x = '%x'", $n)); // hexadecimal representation (lower-case)
20+
var_dump(sprintf("%%X = '%X'", $n)); // hexadecimal representation (upper-case)
21+
22+
var_dump(sprintf("%%+d = '%+d'", $n)); // sign specifier on a positive integer
23+
var_dump(sprintf("%%+d = '%+d'", $u)); // sign specifier on a negative integer
24+
25+
?>
26+
--EXPECT--
27+
string(33) "%b = '10100111101010011010101101'"
28+
string(8) "%c = 'A'"
29+
string(15) "%d = '43951789'"
30+
string(18) "%e = '4.395179e+7'"
31+
string(22) "%f = '43951789.000000'"
32+
string(16) "%o = '247523255'"
33+
string(15) "%s = '43951789'"
34+
string(14) "%x = '29ea6ad'"
35+
string(14) "%X = '29EA6AD'"
36+
string(17) "%+d = '+43951789'"
37+
string(17) "%+d = '-43951789'"

0 commit comments

Comments
 (0)