Ad
  • Custom User Avatar

    It appears that Test.assertSimilar() has an issue with comparing negative and positive zeros in javascript.

    By definition in ECMA-262 Section 7.2.14 -0 === +0 === true.

    The comparison x === y, where x and y are values, produces true or false. Such a comparison is performed as follows:

    1. If Type(x) is different from Type(y), return false.
    2. If Type(x) is Number, then
    3. If x is NaN, return false.
    4. If y is NaN, return false.
    5. If x is the same Number value as y, return true.
    6. If x is +0 and y is -0, return true.
    7. If x is -0 and y is +0, return true.
    8. Return false.
    9. Return SameValueNonNumber(x, y).

    However, the Test.assertSimilar() method fails for the following test.

    Test.assertSimilar([-0], [0]);
    // => Expected: '[0]', instead got: '[-0]'
    
  • Custom User Avatar

    I'm getting the same error in my tests. I wonder why this is happening when -0 === 0 returns true in javascript.