Bug 1165533 - Use SameValue semantics in Mochitests' is() and similar methods. r=Ms2ger

This commit is contained in:
Jeff Walden 2015-05-19 13:09:48 -07:00
parent 46d87fd534
commit b2f6bbd517

View File

@ -278,10 +278,11 @@ SimpleTest.ok = function (condition, name, diag) {
};
/**
* Roughly equivalent to ok(a===b, name)
* Roughly equivalent to ok(Object.is(a, b), name)
**/
SimpleTest.is = function (a, b, name) {
var pass = (a === b);
// Be lazy and use Object.is til we want to test a browser without it.
var pass = Object.is(a, b);
var diag = pass ? "" : "got " + repr(a) + ", expected " + repr(b)
SimpleTest.ok(pass, name, diag);
};
@ -293,7 +294,7 @@ SimpleTest.isfuzzy = function (a, b, epsilon, name) {
};
SimpleTest.isnot = function (a, b, name) {
var pass = (a !== b);
var pass = !Object.is(a, b);
var diag = pass ? "" : "didn't expect " + repr(a) + ", but got it";
SimpleTest.ok(pass, name, diag);
};
@ -411,14 +412,14 @@ SimpleTest.info = function(name, message) {
**/
SimpleTest.todo_is = function (a, b, name) {
var pass = (a === b);
var pass = Object.is(a, b);
var diag = pass ? repr(a) + " should equal " + repr(b)
: "got " + repr(a) + ", expected " + repr(b);
SimpleTest.todo(pass, name, diag);
};
SimpleTest.todo_isnot = function (a, b, name) {
var pass = (a !== b);
var pass = !Object.is(a, b);
var diag = pass ? repr(a) + " should not equal " + repr(b)
: "didn't expect " + repr(a) + ", but got it";
SimpleTest.todo(pass, name, diag);