Skip to content

Commit 15e31d5

Browse files
committed
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3: More intl tests extracted from symfony
2 parents 14847af + 1a23d42 commit 15e31d5

19 files changed

+598
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #1
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 #testFormatTypeDoubleIntl
10+
$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:1:"1";}');
11+
12+
var_dump($unit_test_args);
13+
14+
// execute the code from #testFormatTypeDoubleIntl
15+
$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE);
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(1) "1"
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#testFormatTypeDoubleIntl #2
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 #testFormatTypeDoubleIntl
10+
$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:3:"1.1";}');
11+
12+
var_dump($unit_test_args);
13+
14+
// execute the code from #testFormatTypeDoubleIntl
15+
$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE);
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(3) "1.1"
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#testFormatTypeDoubleIntl #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 #testFormatTypeDoubleIntl
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 #testFormatTypeDoubleIntl
15+
$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE);
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#testFormatTypeDoubleIntl #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 #testFormatTypeDoubleIntl
10+
$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;d:1.1000000000000001;i:2;s:7:"SFD1.10";}');
11+
12+
var_dump($unit_test_args);
13+
14+
// execute the code from #testFormatTypeDoubleIntl
15+
$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE);
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.10"
29+
}
30+
== didn't crash ==
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 ==
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #1
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 #testFormatTypeInt64Intl
10+
$unit_test_args = unserialize('a:3:{i:0;O:15:"NumberFormatter":0:{}i:1;i:1;i:2;s:1:"1";}');
11+
12+
var_dump($unit_test_args);
13+
14+
// execute the code from #testFormatTypeInt64Intl
15+
//$unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT64);
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(1) "1"
29+
}
30+
== didn't crash ==

0 commit comments

Comments
 (0)