Issues

ZF-2813: Bunch of Zend_Measure test errors

Description

Some Zend_Measure unit tests errors came with latest commits to Zend_Locale_Math and Zend_Locale_Math_PhpMath:


1) testFlow_VolumeSetComputedType2(Zend_Measure_Flow_VolumeTest)
Zend_Locale_Math_Exception: multiplication overflow: -100 * 0.16365924 != -16.365924
/home/cawa/ZendFramework/svn/framework/trunk/library/Zend/Measure/Abstract.php:212
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/Flow/VolumeTest.php:322
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:71
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:115

2) testFrequencySetComputedType1(Zend_Measure_FrequencyTest)
Zend_Locale_Math_Exception: division overflow: -100 / 22619.467 != -0.0044209706621292
/home/cawa/ZendFramework/svn/framework/trunk/library/Zend/Measure/Abstract.php:202
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/FrequencyTest.php:327
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:71
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:115

3) testNumberSetType(Zend_Measure_NumberTest)
Zend_Locale_Math_Exception: modulo overflow: 61 % 7 (result=8.7142857142857)
/home/cawa/ZendFramework/svn/framework/trunk/library/Zend/Measure/Number.php:314
/home/cawa/ZendFramework/svn/framework/trunk/library/Zend/Measure/Number.php:378
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/NumberTest.php:188
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:71
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:115

4) testPowerSetType(Zend_Measure_PowerTest)
Zend_Locale_Math_Exception: division overflow: -1000000000 / 11630 != -85984.522785899
/home/cawa/ZendFramework/svn/framework/trunk/library/Zend/Measure/Abstract.php:235
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/PowerTest.php:315
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:71
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:115

5) testPowerSetComputedType2(Zend_Measure_PowerTest)
Zend_Locale_Math_Exception: division overflow: -0.027777777777778 / 1.0e-7 != -277777.77777778
/home/cawa/ZendFramework/svn/framework/trunk/library/Zend/Measure/Abstract.php:235
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/PowerTest.php:351
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:71
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:115

6) testTorqueSetComputedType2(Zend_Measure_TorqueTest)
Zend_Locale_Math_Exception: multiplication overflow: -100 * 0.084738622 != -8.4738622
/home/cawa/ZendFramework/svn/framework/trunk/library/Zend/Measure/Abstract.php:212
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/TorqueTest.php:339
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:71
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:115

7) testVolumeSetComputedType1(Zend_Measure_VolumeTest)
Zend_Locale_Math_Exception: division overflow: -0.49511316872429 / 0.0037854118 != -130.7950613786
/home/cawa/ZendFramework/svn/framework/trunk/library/Zend/Measure/Abstract.php:235
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/VolumeTest.php:333
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:71
/home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/Measure/AllTests.php:115

Comments

I got a fix for this.

The problem was in the float numbers processing and comparison:


var_dump(-16.365924/0.16365924 + 100); // output is "float(1.4210854715202E-14)" instead of "float(0)"

converting value to string (or actually normalization operation) solves the problem

A small failure... You have to normalize before at result. Otherwise you will get an false exception throws when float is extended.

I added this with 8580... this has no effect to your changeset, but fixes a problem when float is extended. Otherwise a false exception message would be returned.

Yeah. Cool!

This issue should have been fixed for the 1.5 release.