Skip to content

Commit

Permalink
Fix bug #66179
Browse files Browse the repository at this point in the history
This also fixes ext/standard/tests/general_functions/var_export-locale.phpt
to actually run the floating-point section.
  • Loading branch information
hikari-no-yume committed Dec 18, 2015
1 parent 8f9af36 commit 8d217db
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 79 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ PHP NEWS
. Fixed bug #71154 (Incorrect HT iterator invalidation causes iterator reuse).
(Nikita)
. Fixed bug #52355 (Negating zero does not produce negative zero). (Andrea)
. Fixed bug #66179 (var_export() exports float as integer). (Andrea)

. CURL:
. Fixed bug #71144 (Sementation fault when using cURL with ZTS).
Expand Down
138 changes: 111 additions & 27 deletions ext/standard/tests/general_functions/var_export-locale.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ $valid_ints = array(
'0x12ab',
'0Xfff',
'0XFA',
-0x80000000, // max negative integer as hexadecimal
-0x7fffffff - 1, // max negative integer as hexadecimal
'0x7fffffff', // max positive integer as hexadecimal
0x7FFFFFFF, // max positive integer as hexadecimal
'0123', // integer as octal
01, // should be quivalent to octal 1
-020000000000, // max negative integer as octal
-017777777777 - 1, // max negative integer as octal
017777777777, // max positive integer as octal
);
$counter = 1;
Expand Down Expand Up @@ -79,12 +79,12 @@ $counter++;
echo "*** Testing var_export() with valid float values ***\n";
// different valid float vlaues
$valid_floats = array(
-2147483649, // float value
2147483648, // float value
-0x80000001, // float value, beyond max negative int
0x800000001, // float value, beyond max positive int
020000000001, // float value, beyond max positive int
-020000000001, // float value, beyond max negative int
(float)-2147483649, // float value
(float)2147483648, // float value
(float)-0x80000001, // float value, beyond max negative int
(float)0x800000001, // float value, beyond max positive int
(float)020000000001, // float value, beyond max positive int
(float)-020000000001, // float value, beyond max negative int
0.0,
-0.1,
10.0000000000000000005,
Expand All @@ -103,7 +103,7 @@ $valid_floats = array(
$counter = 1;
/* Loop to check for above float values with var_export() */
echo "\n*** Output for float values ***\n";
foreach($valid_bool as $float_value) {
foreach($valid_floats as $float_value) {
echo "\nIteration ".$counter."\n";
var_export( $float_value );
echo "\n";
Expand Down Expand Up @@ -467,39 +467,123 @@ string(5) "false"
*** Output for float values ***

Iteration 1
1
1
string(1) "1"
-2147483649.0
-2147483649.0
string(13) "-2147483649.0"


Iteration 2
true
true
string(4) "true"
2147483648.0
2147483648.0
string(12) "2147483648.0"


Iteration 3
true
true
string(4) "true"
-2147483649.0
-2147483649.0
string(13) "-2147483649.0"


Iteration 4
0
0
string(1) "0"
34359738369.0
34359738369.0
string(13) "34359738369.0"


Iteration 5
false
false
string(5) "false"
2147483649.0
2147483649.0
string(12) "2147483649.0"


Iteration 6
false
false
string(5) "false"
-2147483649.0
-2147483649.0
string(13) "-2147483649.0"


Iteration 7
0.0
0.0
string(3) "0.0"


Iteration 8
-0.10000000000000001
-0.10000000000000001
string(20) "-0.10000000000000001"


Iteration 9
10.0
10.0
string(4) "10.0"


Iteration 10
1050000.0
1050000.0
string(9) "1050000.0"


Iteration 11
100000.0
100000.0
string(8) "100000.0"


Iteration 12
1.0000000000000001E-5
1.0000000000000001E-5
string(21) "1.0000000000000001E-5"


Iteration 13
100000.0
100000.0
string(8) "100000.0"


Iteration 14
100000.0
100000.0
string(8) "100000.0"


Iteration 15
100000.0
100000.0
string(8) "100000.0"


Iteration 16
1.0000000000000001E-5
1.0000000000000001E-5
string(21) "1.0000000000000001E-5"


Iteration 17
5000000.0
5000000.0
string(9) "5000000.0"


Iteration 18
6.0000000000000006E-20
6.0000000000000006E-20
string(22) "6.0000000000000006E-20"


Iteration 19
5.0000000000000001E+42
5.0000000000000001E+42
string(22) "5.0000000000000001E+42"


Iteration 20
3.4000000000000001E-33
3.4000000000000001E-33
string(22) "3.4000000000000001E-33"

*** Testing var_export() with valid strings ***

Expand Down
4 changes: 2 additions & 2 deletions ext/standard/tests/general_functions/var_export_basic1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ $valid_ints = array(
"'0x12ab'" => '0x12ab',
"'0Xfff'" => '0Xfff',
"'0XFA'" => '0XFA',
"-0x80000000" => -0x80000000, // max negative integer as hexadecimal
"-0x80000000" => -0x7FFFFFFF - 1, // max negative integer as hexadecimal
"'0x7fffffff'" => '0x7fffffff', // max positive integer as hexadecimal
"0x7FFFFFFF" => 0x7FFFFFFF, // max positive integer as hexadecimal
"'0123'" => '0123', // integer as octal
"01912" => 01, // should be quivalent to octal 1
"-020000000000" => -020000000000, // max negative integer as octal
"-020000000000" => -017777777777 - 1, // max negative integer as octal
"017777777777" => 017777777777, // max positive integer as octal
);

Expand Down
96 changes: 48 additions & 48 deletions ext/standard/tests/general_functions/var_export_basic3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ serialize_precision=17
echo "*** Testing var_export() with valid float values ***\n";
// different valid float vlaues
$valid_floats = array(
"-2147483649" => -2147483649, // float value
"2147483648" => 2147483648, // float value
"-0x80000001" => -0x80000001, // float value, beyond max negative int
"0x800000001" => 0x800000001, // float value, beyond max positive int
"020000000001" => 020000000001, // float value, beyond max positive int
"-020000000001" => -020000000001, // float value, beyond max negative int
"-2147483649" => (float)-2147483649, // float value
"2147483648" => (float)2147483648, // float value
"-0x80000001" => (float)-0x80000001, // float value, beyond max negative int
"0x800000001" => (float)0x800000001, // float value, beyond max positive int
"020000000001" => (float)020000000001, // float value, beyond max positive int
"-020000000001" => (float)-020000000001, // float value, beyond max negative int
"0.0" => 0.0,
"-0.1" => -0.1,
"10.0000000000000000005" => 10.0000000000000000005,
Expand Down Expand Up @@ -54,45 +54,45 @@ foreach($valid_floats as $key => $float_value) {
*** Output for float values ***

-- Iteration: -2147483649 --
-2147483649
-2147483649
string(11) "-2147483649"
-2147483649.0
-2147483649.0
string(13) "-2147483649.0"


-- Iteration: 2147483648 --
2147483648
2147483648
string(10) "2147483648"
2147483648.0
2147483648.0
string(12) "2147483648.0"


-- Iteration: -0x80000001 --
-2147483649
-2147483649
string(11) "-2147483649"
-2147483649.0
-2147483649.0
string(13) "-2147483649.0"


-- Iteration: 0x800000001 --
34359738369
34359738369
string(11) "34359738369"
34359738369.0
34359738369.0
string(13) "34359738369.0"


-- Iteration: 020000000001 --
2147483649
2147483649
string(10) "2147483649"
2147483649.0
2147483649.0
string(12) "2147483649.0"


-- Iteration: -020000000001 --
-2147483649
-2147483649
string(11) "-2147483649"
-2147483649.0
-2147483649.0
string(13) "-2147483649.0"


-- Iteration: 0.0 --
0
0
string(1) "0"
0.0
0.0
string(3) "0.0"


-- Iteration: -0.1 --
Expand All @@ -102,21 +102,21 @@ string(20) "-0.10000000000000001"


-- Iteration: 10.0000000000000000005 --
10
10
string(2) "10"
10.0
10.0
string(4) "10.0"


-- Iteration: 10.5e+5 --
1050000
1050000
string(7) "1050000"
1050000.0
1050000.0
string(9) "1050000.0"


-- Iteration: 1e5 --
100000
100000
string(6) "100000"
100000.0
100000.0
string(8) "100000.0"


-- Iteration: 1e-5 --
Expand All @@ -126,21 +126,21 @@ string(21) "1.0000000000000001E-5"


-- Iteration: 1e+5 --
100000
100000
string(6) "100000"
100000.0
100000.0
string(8) "100000.0"


-- Iteration: 1E5 --
100000
100000
string(6) "100000"
100000.0
100000.0
string(8) "100000.0"


-- Iteration: 1E+5 --
100000
100000
string(6) "100000"
100000.0
100000.0
string(8) "100000.0"


-- Iteration: 1E-5 --
Expand All @@ -150,9 +150,9 @@ string(21) "1.0000000000000001E-5"


-- Iteration: .5e+7 --
5000000
5000000
string(7) "5000000"
5000000.0
5000000.0
string(9) "5000000.0"


-- Iteration: .6e-19 --
Expand Down
29 changes: 29 additions & 0 deletions ext/standard/tests/general_functions/var_export_bug66179.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--TEST--
Bug #66179 (var_export() exports float as integer)
--FILE--
<?php

var_export(1.0);
echo PHP_EOL;
var_export(123.0);
echo PHP_EOL;
var_export(-1.0);
echo PHP_EOL;
var_export(-123.0);
echo PHP_EOL;
var_export(0.0);
echo PHP_EOL;
var_export(-0.0);
echo PHP_EOL;
var_export(10000000000000000.0);
echo PHP_EOL;

?>
--EXPECTF--
1.0
123.0
-1.0
-123.0
0.0
-0.0
10000000000000000.0
Loading

0 comments on commit 8d217db

Please sign in to comment.