},
finish: function() {
config.current = this;
- if ( config.requireExpects && this.expected == null ) {
+ if ( config.requireExpects && this.expected === null ) {
QUnit.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack );
- } else if ( this.expected != null && this.expected != this.assertions.length ) {
+ } else if ( this.expected !== null && this.expected !== this.assertions.length ) {
QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack );
- } else if ( this.expected == null && !this.assertions.length ) {
+ } else if ( this.expected === null && !this.assertions.length ) {
QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack );
}
addEvent(b, "dblclick", function( e ) {
var target = e && e.target ? e.target : window.event.srcElement;
- if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) {
+ if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) {
target = target.parentNode;
}
if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
* @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" );
*/
equal: function( actual, expected, message ) {
+ /*jshint eqeqeq:false */
QUnit.push( expected == actual, actual, expected, message );
},
* @function
*/
notEqual: function( actual, expected, message ) {
+ /*jshint eqeqeq:false */
QUnit.push( expected != actual, actual, expected, message );
},
// Safe object type checking
is: function( type, obj ) {
- return QUnit.objectType( obj ) == type;
+ return QUnit.objectType( obj ) === type;
},
objectType: function( obj ) {
actual = escapeInnerText( QUnit.jsDump.parse(actual) );
output += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" + expected + "</pre></td></tr>";
- if ( actual != expected ) {
+ if ( actual !== expected ) {
output += "<tr class='test-actual'><th>Result: </th><td><pre>" + actual + "</pre></td></tr>";
output += "<tr class='test-diff'><th>Diff: </th><td><pre>" + QUnit.diff( expected, actual ) + "</pre></td></tr>";
}
if ( fileName ) {
include = [];
for ( i = offset; i < stack.length; i++ ) {
- if ( stack[ i ].indexOf( fileName ) != -1 ) {
+ if ( stack[ i ].indexOf( fileName ) !== -1 ) {
break;
}
include.push( stack[ i ] );
// for string, boolean, number and null
function useStrictEquality( b, a ) {
+ /*jshint eqeqeq:false */
if ( b instanceof a.constructor || a instanceof b.constructor ) {
// to catch short annotaion VS 'new' annotation of a
// declaration
type = typeof parser;
inStack = inArray( obj, stack );
- if ( inStack != -1 ) {
+ if ( inStack !== -1 ) {
return "recursion(" + (inStack - stack.length) + ")";
}
- if ( type == "function" ) {
+ if ( type === "function" ) {
stack.push( obj );
res = parser.call( this, obj, stack );
stack.pop();
return res;
}
- return ( type == "string" ) ? parser : this.parsers.error;
+ return ( type === "string" ) ? parser : this.parsers.error;
},
typeOf: function( obj ) {
var type;
* QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) == "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
*/
QUnit.diff = (function() {
+ /*jshint eqeqeq:false, eqnull:true */
function diff( o, n ) {
var i,
ns = {},
if ( !hasOwn.call( ns, i ) ) {
continue;
}
- if ( ns[i].rows.length == 1 && typeof os[i] != "undefined" && os[i].rows.length == 1 ) {
+ if ( ns[i].rows.length === 1 && os[i] !== undefined && os[i].rows.length === 1 ) {
n[ ns[i].rows[0] ] = {
text: n[ ns[i].rows[0] ],
row: os[i].rows[0]
// for CommonJS enviroments, export everything
if ( typeof exports !== "undefined" ) {
- extend(exports, QUnit);
+ extend( exports, QUnit );
}
// get at whatever the global object is, like window in browsers
equal(QUnit.equiv('', null), false, "string");
equal(QUnit.equiv('', undefined), false, "string");
+ // Rename for lint validation.
+ // We know this is bad, we are asserting whether we can coop with bad code like this.
+ var SafeNumber = Number, SafeString = String, SafeBoolean = Boolean, SafeObject = Object;
+
// primitives vs. objects
- equal(QUnit.equiv(0, new Number()), true, "primitives vs. objects");
- equal(QUnit.equiv(new Number(), 0), true, "primitives vs. objects");
- equal(QUnit.equiv(1, new Number(1)), true, "primitives vs. objects");
- equal(QUnit.equiv(new Number(1), 1), true, "primitives vs. objects");
- equal(QUnit.equiv(new Number(0), 1), false, "primitives vs. objects");
- equal(QUnit.equiv(0, new Number(1)), false, "primitives vs. objects");
-
- equal(QUnit.equiv(new String(), ""), true, "primitives vs. objects");
- equal(QUnit.equiv("", new String()), true, "primitives vs. objects");
- equal(QUnit.equiv(new String("My String"), "My String"), true, "primitives vs. objects");
- equal(QUnit.equiv("My String", new String("My String")), true, "primitives vs. objects");
- equal(QUnit.equiv("Bad String", new String("My String")), false, "primitives vs. objects");
- equal(QUnit.equiv(new String("Bad String"), "My String"), false, "primitives vs. objects");
-
- equal(QUnit.equiv(false, new Boolean()), true, "primitives vs. objects");
- equal(QUnit.equiv(new Boolean(), false), true, "primitives vs. objects");
- equal(QUnit.equiv(true, new Boolean(true)), true, "primitives vs. objects");
- equal(QUnit.equiv(new Boolean(true), true), true, "primitives vs. objects");
- equal(QUnit.equiv(true, new Boolean(1)), true, "primitives vs. objects");
- equal(QUnit.equiv(false, new Boolean(false)), true, "primitives vs. objects");
- equal(QUnit.equiv(new Boolean(false), false), true, "primitives vs. objects");
- equal(QUnit.equiv(false, new Boolean(0)), true, "primitives vs. objects");
- equal(QUnit.equiv(true, new Boolean(false)), false, "primitives vs. objects");
- equal(QUnit.equiv(new Boolean(false), true), false, "primitives vs. objects");
-
- equal(QUnit.equiv(new Object(), {}), true, "object literal vs. instantiation");
- equal(QUnit.equiv({}, new Object()), true, "object literal vs. instantiation");
- equal(QUnit.equiv(new Object(), {a:1}), false, "object literal vs. instantiation");
- equal(QUnit.equiv({a:1}, new Object()), false, "object literal vs. instantiation");
- equal(QUnit.equiv({a:undefined}, new Object()), false, "object literal vs. instantiation");
- equal(QUnit.equiv(new Object(), {a:undefined}), false, "object literal vs. instantiation");
+
+ equal(QUnit.equiv(0, new SafeNumber()), true, "primitives vs. objects");
+ equal(QUnit.equiv(new SafeNumber(), 0), true, "primitives vs. objects");
+ equal(QUnit.equiv(1, new SafeNumber(1)), true, "primitives vs. objects");
+ equal(QUnit.equiv(new SafeNumber(1), 1), true, "primitives vs. objects");
+ equal(QUnit.equiv(new SafeNumber(0), 1), false, "primitives vs. objects");
+ equal(QUnit.equiv(0, new SafeNumber(1)), false, "primitives vs. objects");
+
+ equal(QUnit.equiv(new SafeString(), ""), true, "primitives vs. objects");
+ equal(QUnit.equiv("", new SafeString()), true, "primitives vs. objects");
+ equal(QUnit.equiv(new SafeString("My String"), "My String"), true, "primitives vs. objects");
+ equal(QUnit.equiv("My String", new SafeString("My String")), true, "primitives vs. objects");
+ equal(QUnit.equiv("Bad String", new SafeString("My String")), false, "primitives vs. objects");
+ equal(QUnit.equiv(new SafeString("Bad String"), "My String"), false, "primitives vs. objects");
+
+ equal(QUnit.equiv(false, new SafeBoolean()), true, "primitives vs. objects");
+ equal(QUnit.equiv(new SafeBoolean(), false), true, "primitives vs. objects");
+ equal(QUnit.equiv(true, new SafeBoolean(true)), true, "primitives vs. objects");
+ equal(QUnit.equiv(new SafeBoolean(true), true), true, "primitives vs. objects");
+ equal(QUnit.equiv(true, new SafeBoolean(1)), true, "primitives vs. objects");
+ equal(QUnit.equiv(false, new SafeBoolean(false)), true, "primitives vs. objects");
+ equal(QUnit.equiv(new SafeBoolean(false), false), true, "primitives vs. objects");
+ equal(QUnit.equiv(false, new SafeBoolean(0)), true, "primitives vs. objects");
+ equal(QUnit.equiv(true, new SafeBoolean(false)), false, "primitives vs. objects");
+ equal(QUnit.equiv(new SafeBoolean(false), true), false, "primitives vs. objects");
+
+ equal(QUnit.equiv(new SafeObject(), {}), true, "object literal vs. instantiation");
+ equal(QUnit.equiv({}, new SafeObject()), true, "object literal vs. instantiation");
+ equal(QUnit.equiv(new SafeObject(), {a:1}), false, "object literal vs. instantiation");
+ equal(QUnit.equiv({a:1}, new SafeObject()), false, "object literal vs. instantiation");
+ equal(QUnit.equiv({a:undefined}, new SafeObject()), false, "object literal vs. instantiation");
+ equal(QUnit.equiv(new SafeObject(), {a:undefined}), false, "object literal vs. instantiation");
});
test("Objects Basics.", function() {