mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 20:01:50 +00:00
Bug 1754015 - Assert.jsm should throw when comparing a NaN number, r=Gijs.
Differential Revision: https://phabricator.services.mozilla.com/D138041
This commit is contained in:
parent
d538838400
commit
ee0f63bdfc
@ -515,8 +515,8 @@ proto.rejects = function(promise, expected, message) {
|
||||
};
|
||||
|
||||
function compareNumbers(expression, lhs, rhs, message, operator) {
|
||||
let lhsIsNumber = typeof lhs == "number";
|
||||
let rhsIsNumber = typeof rhs == "number";
|
||||
let lhsIsNumber = typeof lhs == "number" && !Number.isNaN(lhs);
|
||||
let rhsIsNumber = typeof rhs == "number" && !Number.isNaN(rhs);
|
||||
|
||||
if (lhsIsNumber && rhsIsNumber) {
|
||||
this.report(expression, lhs, rhs, message, operator);
|
||||
|
@ -409,6 +409,20 @@ function run_test() {
|
||||
}
|
||||
assert.equal(message, "AssertionError: 2 <= 1");
|
||||
|
||||
try {
|
||||
assert.greater(NaN, 0);
|
||||
} catch (e) {
|
||||
message = e.toString().split("\n")[0];
|
||||
}
|
||||
assert.equal(message, "AssertionError: 'NaN' is not a number");
|
||||
|
||||
try {
|
||||
assert.greater(0, NaN);
|
||||
} catch (e) {
|
||||
message = e.toString().split("\n")[0];
|
||||
}
|
||||
assert.equal(message, "AssertionError: 'NaN' is not a number");
|
||||
|
||||
/* ---- stringMatches ---- */
|
||||
assert.stringMatches("hello world", /llo\s/);
|
||||
assert.stringMatches("hello world", "llo\\s");
|
||||
|
Loading…
x
Reference in New Issue
Block a user