Fix Math.imul and add tests (#432)

This commit is contained in:
Max Graey
2019-01-24 02:23:53 +02:00
committed by Daniel Wirtz
parent 54b02c287c
commit d3715688fc
8 changed files with 745 additions and 258 deletions

View File

@ -3269,6 +3269,21 @@ assert(test_truncf(-0.9999923706, -0.0, 0.0, INEXACT));
assert(test_truncf(7.888609052e-31, 0.0, 0.0, INEXACT));
assert(test_truncf(-7.888609052e-31, -0.0, 0.0, INEXACT));
// Math.imul //////////////////////////////////////////////////////////////////////////////////
assert(NativeMath.imul(2, 4) == 8);
assert(NativeMath.imul(-1, 8) == -8);
assert(NativeMath.imul(-2, -2) == 4);
assert(NativeMath.imul(0xffffffff, 5) == -5);
assert(NativeMath.imul(0xfffffffe, 5) == -10);
assert(NativeMath.imul(1e+60, 1e+60) == 0);
assert(NativeMath.imul(1e+60,-1e+60) == 0);
assert(NativeMath.imul(-1e+60,-1e+60) == 0);
assert(NativeMath.imul(1e+24, 1e2) == -2147483648);
assert(NativeMath.imul(NaN, 1) == 0);
assert(NativeMath.imul(1, Infinity) == 0);
assert(NativeMath.imul(f64.MAX_VALUE, f64.MAX_VALUE) == 0);
// ipow64 /////////////////////////////////////////////////////////////////////////////////////
assert(ipow64(0, 0) == 1);