Skip to content

Commit ed793b2

Browse files
Matt Fickenweltling
authored andcommitted
Added the intl tests extracted from Symfony. These are making the intl ext crash with ICU at least 4.6, but probably with earlier versions too.
1 parent a239658 commit ed793b2

7 files changed

+238
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #1
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
--FILE--
6+
<?php
7+
8+
// port of Symfony's Symfony\Component\Locale\Tests\Stub\StubNumberFormatterTest#testFormatTypeInt32Intl
9+
10+
11+
// Crashes on Windows
12+
// Windows note: the popup '...program has stopped working'(AEDebug Popup)
13+
// doesn't always show if you're rapidly running this test repeatedly.
14+
// regardless of that, the test always crashes every time.
15+
// (it will show up the first time, or if you wait a while before running it again.)
16+
// (the popup may also be disabled, which can be done with a registry setting.)
17+
// you can confirm it crashed by checking the exit code OR
18+
// the message this test prints at the very end (expected output for pass).
19+
//
20+
// Get Exit Code
21+
// Linux: echo $?
22+
// Windows: echo %ErrorLevel%
23+
24+
25+
26+
27+
28+
// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
29+
$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:1:"1";}');
30+
31+
var_dump($unit_test_args);
32+
33+
// execute the code from #testFormatTypeInt32Intl
34+
$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
35+
36+
echo "== didn't crash ==".PHP_EOL;
37+
38+
?>
39+
--EXPECT--
40+
array(3) {
41+
[0]=>
42+
object(NumberFormatter)#1 (0) {
43+
}
44+
[1]=>
45+
int(1)
46+
[2]=>
47+
string(1) "1"
48+
}
49+
== didn't crash ==
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #2
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
--FILE--
6+
<?php
7+
8+
// StubNumberFormatterTest#testFormatTypeInt32Intl is tested many times, each with different args.
9+
// there are 7 sets of args that crash PHP (and other args that don't), each of those 7 is now a separate PHPT test
10+
// to ensure that each of the 7 args are always tested.
11+
12+
// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
13+
$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:1:"1";}');
14+
15+
var_dump($unit_test_args);
16+
17+
// execute the code from #testFormatTypeInt32Intl
18+
$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
19+
20+
echo "== didn't crash ==".PHP_EOL;
21+
22+
?>
23+
--EXPECT--
24+
array(3) {
25+
[0]=>
26+
object(NumberFormatter)#1 (0) {
27+
}
28+
[1]=>
29+
float(1.1)
30+
[2]=>
31+
string(1) "1"
32+
}
33+
== didn't crash ==
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #3
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
--FILE--
6+
<?php
7+
8+
9+
// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
10+
$unit_test_args = unserialize('a:4:{i:0;O:15:"NumberFormatter":0:{}i:1;d:2147483648;i:2;s:14:"-2,147,483,648";i:3;s:83:"->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}');
11+
12+
var_dump($unit_test_args);
13+
14+
// execute the code from #testFormatTypeInt32Intl
15+
$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
16+
17+
echo "== didn't crash ==".PHP_EOL;
18+
19+
?>
20+
--EXPECT--
21+
array(4) {
22+
[0]=>
23+
object(NumberFormatter)#1 (0) {
24+
}
25+
[1]=>
26+
float(2147483648)
27+
[2]=>
28+
string(14) "-2,147,483,648"
29+
[3]=>
30+
string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range."
31+
}
32+
== didn't crash ==
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #4
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
--FILE--
6+
<?php
7+
8+
9+
// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
10+
$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:7:"SFD1.00";}');
11+
12+
var_dump($unit_test_args);
13+
14+
// execute the code from #testFormatTypeInt32Intl
15+
$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
16+
17+
echo "== didn't crash ==".PHP_EOL;
18+
19+
?>
20+
--EXPECT--
21+
array(3) {
22+
[0]=>
23+
object(NumberFormatter)#1 (0) {
24+
}
25+
[1]=>
26+
int(1)
27+
[2]=>
28+
string(7) "SFD1.00"
29+
}
30+
== didn't crash ==
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #5
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
--FILE--
6+
<?php
7+
8+
9+
// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
10+
$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:7:"SFD1.00";}');
11+
12+
var_dump($unit_test_args);
13+
14+
// execute the code from #testFormatTypeInt32Intl
15+
$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
16+
17+
echo "== didn't crash ==".PHP_EOL;
18+
19+
?>
20+
--EXPECT--
21+
array(3) {
22+
[0]=>
23+
object(NumberFormatter)#1 (0) {
24+
}
25+
[1]=>
26+
float(1.1)
27+
[2]=>
28+
string(7) "SFD1.00"
29+
}
30+
== didn't crash ==
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #6
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
--FILE--
6+
<?php
7+
8+
9+
// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
10+
$unit_test_args = unserialize('a:4:{i:0;O:15:"NumberFormatter":0:{}i:1;d:2147483648;i:2;s:21:"(SFD2,147,483,648.00)";i:3;s:83:"->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}');
11+
12+
var_dump($unit_test_args);
13+
14+
// execute the code from #testFormatTypeInt32Intl
15+
$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
16+
17+
echo "== didn't crash ==".PHP_EOL;
18+
19+
?>
20+
--EXPECT--
21+
array(4) {
22+
[0]=>
23+
object(NumberFormatter)#1 (0) {
24+
}
25+
[1]=>
26+
float(2147483648)
27+
[2]=>
28+
string(21) "(SFD2,147,483,648.00)"
29+
[3]=>
30+
string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range."
31+
}
32+
== didn't crash ==
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #7
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
--FILE--
6+
<?php
7+
8+
9+
// PHP Unit's code to unserialize data passed as args to #testFormatTypeInt32Intl
10+
$unit_test_args = unserialize('a:4:{i:0;O:15:"NumberFormatter":0:{}i:1;d:-2147483649;i:2;s:19:"SFD2,147,483,647.00";i:3;s:83:"->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}');
11+
12+
var_dump($unit_test_args);
13+
14+
// execute the code from #testFormatTypeInt32Intl
15+
$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32);
16+
17+
echo "== didn't crash ==".PHP_EOL;
18+
19+
?>
20+
--EXPECT--
21+
array(4) {
22+
[0]=>
23+
object(NumberFormatter)#1 (0) {
24+
}
25+
[1]=>
26+
float(-2147483649)
27+
[2]=>
28+
string(19) "SFD2,147,483,647.00"
29+
[3]=>
30+
string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range."
31+
}
32+
== didn't crash ==

0 commit comments

Comments
 (0)