Improve coverage for ops involving negative zero

Prior to this commit, the modified tests used the strict equality
operator to compare computed values with negative zero. Due to the
semantics of that operator, these tests would spuriously pass if the
value under test was in fact positive zero.

Update the tests to be more precise by instead asserting equality with
the `assert.sameValue` utility method (since that method correctly
distinguishes between negative zero and positive zero).
This commit is contained in:
Mike Pennisi 2021-09-15 17:08:12 -04:00 committed by Rick Waldron
parent 93ecde9f3a
commit 650e7add4a
4 changed files with 4 additions and 8 deletions

View File

@ -14,7 +14,5 @@ exponents[1] = -111;
exponents[0] = -111111;
for (var i = 0; i < exponents.length; i++) {
if ((base ** exponents[i]) !== -0) {
throw new Test262Error("(" + base + " ** " + exponents[i] + ") !== -0");
}
assert.sameValue(base ** exponents[i], -0, base + " ** " + exponents[i]);
}

View File

@ -14,7 +14,5 @@ exponents[1] = 111;
exponents[2] = 111111;
for (var i = 0; i < exponents.length; i++) {
if ((base ** exponents[i]) !== -0) {
throw new Test262Error("(" + base + " ** " + exponents[i] + ") !== -0");
}
assert.sameValue(base ** exponents[i], -0, base + " ** " + exponents[i]);
}

View File

@ -71,5 +71,5 @@ try{
throw -0;
}
catch(e){
if (e!==-0) throw new Test262Error('#8: Exception ===-0. Actual: Exception ==='+ e );
assert.sameValue(e, -0);
}

View File

@ -96,5 +96,5 @@ try{
throw -0;
}
catch(e){
if (e!==-0) throw new Test262Error('#11: Exception ===-0. Actual: Exception ==='+ e );
assert.sameValue(e, -0);
}