|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-10-09 15:43 UTC] phpbugrep-20061009 at pgregg dot com
Description:
------------
Running make test on 5.2.0RC4 fails with:
FAIL Math constants [ext/standard/tests/math/constants.phpt]
Reproduce code:
---------------
Add this additional debug to run-tests.php at line 1494:
$output_pgarr = explode("\n", $output);
$wanted_pgarr = explode("\n", $wanted);
foreach($wanted_pgarr as $line) {
list($pgleft, $pgright) = explode(":", $line, 2);
$pgleft = trim($pgleft); $pgright = trim($pgright);
$pgwanted[$pgleft] = "$pgright";
}
foreach($output_pgarr as $line) {
list($pgleft, $pgright) = explode(":", $line, 2);
$pgleft = trim($pgleft); $pgright = trim($pgright);
if (strcmp($pgright, $pgwanted[$pgleft]) !== 0)
printf("%-10s: Expected: %-16s Got: %-16s Diff: %s\n", $pgleft, $pgwanted[$pgleft], $pgright, bcsub($pgwant
ed[$pgleft], $pgright,12));
}
% echo "ext/standard/tests/math/constants.phpt" > pgtest.txt
% php run-tests.php -l pgtest.txt
Expected result:
----------------
Expected test to PASS
Actual result:
--------------
Added more code to run-tests.php to report on what was going on and got:
M_E : Expected: 2.718281828459 Got: 2.71828182846 Diff: -0.000000000001
M_LOG2E : Expected: 1.442695040889 Got: 1.44269504089 Diff: -0.000000000001
M_LN2 : Expected: 0.693147180559 Got: 0.69314718056 Diff: -0.000000000001
M_LN10 : Expected: 2.302585092994 Got: 2.30258509299 Diff: 0.000000000004
M_PI : Expected: 3.141592653589 Got: 3.14159265359 Diff: -0.000000000001
M_PI_2 : Expected: 1.570796326794 Got: 1.57079632679 Diff: 0.000000000004
M_1_PI : Expected: 0.318309886183 Got: 0.318309886184 Diff: -0.000000000001
M_2_PI : Expected: 0.636619772367 Got: 0.636619772368 Diff: -0.000000000001
M_SQRTPI : Expected: 1.772453850905 Got: 1.77245385091 Diff: -0.000000000005
M_2_SQRTPI: Expected: 1.128379167095 Got: 1.1283791671 Diff: -0.000000000005
M_LNPI : Expected: 1.144729885849 Got: 1.14472988585 Diff: -0.000000000001
M_EULER : Expected: 0.577215664901 Got: 0.577215664902 Diff: -0.000000000001
M_SQRT2 : Expected: 1.414213562373 Got: 1.41421356237 Diff: 0.000000000003
M_SQRT1_2 : Expected: 0.707106781186 Got: 0.707106781187 Diff: -0.000000000001
M_SQRT3 : Expected: 1.732050807568 Got: 1.73205080757 Diff: -0.000000000002
FAIL Math constants [ext/standard/tests/math/constants.phpt]
As you can see, we have lost a decimal place of precision.
plop:root/p2-/usr/local/src/Web/Apache2_PHP5/php-5.2.0RC5-862#->uname -a 4:38PM
FreeBSD plop.pgregg.com 5.5-PRERELEASE FreeBSD 5.5-PRERELEASE #4: Tue Mar 7 13:49:31 GMT 2006 pgregg@plop.pgregg.com:/usr/obj/usr/src/sys/PGREGG_PLOP i386
This test passed ok in 5.2.0RC4
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 16:00:02 2025 UTC |
Fix for the test: *** ext/standard/tests/math/constants.phpt.bak Mon Oct 9 17:47:37 2006 --- ext/standard/tests/math/constants.phpt Mon Oct 9 17:49:02 2006 *************** *** 25,46 **** printf("%-10s: %.14s\n", $constant, constant($constant)); } ?> ! --EXPECT-- ! M_E : 2.718281828459 ! M_LOG2E : 1.442695040889 ! M_LOG10E : 0.434294481903 ! M_LN2 : 0.693147180559 ! M_LN10 : 2.302585092994 ! M_PI : 3.141592653589 ! M_PI_2 : 1.570796326794 ! M_PI_4 : 0.785398163397 ! M_1_PI : 0.318309886183 ! M_2_PI : 0.636619772367 ! M_SQRTPI : 1.772453850905 ! M_2_SQRTPI: 1.128379167095 ! M_LNPI : 1.144729885849 ! M_EULER : 0.577215664901 ! M_SQRT2 : 1.414213562373 ! M_SQRT1_2 : 0.707106781186 ! M_SQRT3 : 1.732050807568 --- 25,46 ---- printf("%-10s: %.14s\n", $constant, constant($constant)); } ?> ! --EXPECTREGEX-- ! M_E : 2.718281[0-9]* ! M_LOG2E : 1.442695[0-9]* ! M_LOG10E : 0.434294[0-9]* ! M_LN2 : 0.693147[0-9]* ! M_LN10 : 2.302585[0-9]* ! M_PI : 3.141592[0-9]* ! M_PI_2 : 1.570796[0-9]* ! M_PI_4 : 0.785398[0-9]* ! M_1_PI : 0.318309[0-9]* ! M_2_PI : 0.636619[0-9]* ! M_SQRTPI : 1.772453[0-9]* ! M_2_SQRTPI: 1.128379[0-9]* ! M_LNPI : 1.144729[0-9]* ! M_EULER : 0.577215[0-9]* ! M_SQRT2 : 1.414213[0-9]* ! M_SQRT1_2 : 0.707106[0-9]* ! M_SQRT3 : 1.732050[0-9]*