[wp-trac] [WordPress Trac] #23626: wp_convert_bytes_to_hr tests and NaN

WordPress Trac noreply at wordpress.org
Tue Feb 26 11:46:08 UTC 2013


#23626: wp_convert_bytes_to_hr tests and NaN
--------------------------+-----------------------------
 Reporter:  soulseekah    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 [1218/tests] were written for the `deprecated wp_convert_bytes_to_hr`,
 these tests are broken at least on 64-bit machines, at most - on all
 machines.

 On 64-bit PHP (PHP_INT_SIZE == 8) floating point does not match expected
 output (gets 1022.9990234375MB). The last digits in floating point should
 not be depended upon due to these inaccuracies. Rounding in PHP < 5.3 is
 not an option either, since rounding mode was introduced later and
 different systems get different results (round up vs. round down by
 default). So perhaps looking at error and discrepancy would be a decent
 solution (maybe even less error 0.00001?).

 Next [23440], in the function itself we get `(int)double(NAN`) result from
 feeding -1 and 0, which results in `$power` to be a huge negative number
 instead of 0. This results in both a Warning (undefined array index) being
 thrown, and the "B" missing in tests, i.e. expected "NANB" != "NAN" and
 expected "0B" != "0".

 Related #19067

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23626>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list