Use === for is() and is_not() in contenttests.

The notion of equality used by == in JavaScript is not useful for testing.
This commit is contained in:
Ms2ger 2014-07-30 12:16:19 +02:00
parent 43d176f653
commit 9ad878e877
3 changed files with 7 additions and 7 deletions

View file

@ -20,8 +20,8 @@ function _printer(opstr, op) {
};
}
var is = _printer("==", function (a,b) { return a == b; });
var is_not = _printer("!=", function (a,b) { return a != b; });
var is = _printer("===", function (a,b) { return a === b; });
var is_not = _printer("!==", function (a,b) { return a !== b; });
var is_a = _printer("is a", function (a,b) { return a instanceof b; });
var is_not_a = _printer("is not a", function (a,b) { return !(a instanceof b); });
var is_in = _printer("is in", function (a,b) { return a in b; });

View file

@ -9,7 +9,7 @@
function check_collection(obj, num, classes, name) {
is_a(obj, HTMLCollection);
is(obj.length, num);
is(obj[obj.length], null);
is(obj[obj.length], undefined);
if (classes === undefined)
return;
@ -17,7 +17,7 @@ function check_collection(obj, num, classes, name) {
classes = [Element, HTMLElement].concat(classes);
for (var i=0; i<obj.length; i++) {
is_not(obj[i], null);
is_not(obj[i], undefined);
is(obj[i].tagName, name);
for (var j=0; j<classes.length; j++) {
is_a(obj[i], classes[j]);

View file

@ -20,11 +20,11 @@
}
// test2: Node.namespaceURI
{
is(document.namespaceURI, null, "test2.0: createElementNS");
is(document.namespaceURI, undefined, "test2.0: createElementNS");
is(document.documentElement.namespaceURI, "http://www.w3.org/1999/xhtml", "test2.1: createElementNS");
var scriptElt = document.getElementById("script");
is(scriptElt.firstChild.namespaceURI, null, "test2.2: createElementNS");
is(scriptElt.nextSibling.namespaceURI, null, "test2.3: createElementNS");
is(scriptElt.firstChild.namespaceURI, undefined, "test2.2: createElementNS");
is(scriptElt.nextSibling.namespaceURI, undefined, "test2.3: createElementNS");
}
finish();