Comparing version 1.12.0-pre to 1.12.0
@@ -6,3 +6,3 @@ # PhantomJS Runner # | ||
```bash | ||
phantomjs runner.js [url-of-your-qunit-testsuite] | ||
phantomjs runner.js [url-of-your-qunit-testsuite] [timeout-in-seconds] | ||
``` | ||
@@ -17,2 +17,2 @@ | ||
- Requires [PhantomJS](http://phantomjs.org/) 1.6+ (1.7+ recommended). | ||
- If you're using Grunt, you should take a look at its [qunit task](https://github.com/gruntjs/grunt/blob/master/docs/task_qunit.md). | ||
- If you're using Grunt, you should take a look at its [qunit task](https://github.com/gruntjs/grunt-contrib-qunit). |
@@ -14,3 +14,2 @@ /* | ||
/*jshint latedef:false */ | ||
/*global phantom:false, require:false, console:false, window:false, QUnit:false */ | ||
@@ -21,12 +20,16 @@ | ||
var args = require('system').args; | ||
var url, page, timeout, | ||
args = require('system').args; | ||
// arg[0]: scriptName, args[1...]: arguments | ||
if (args.length !== 2) { | ||
console.error('Usage:\n phantomjs runner.js [url-of-your-qunit-testsuite]'); | ||
if (args.length < 2 || args.length > 3) { | ||
console.error('Usage:\n phantomjs runner.js [url-of-your-qunit-testsuite] [timeout-in-seconds]'); | ||
phantom.exit(1); | ||
} | ||
var url = args[1], | ||
page = require('webpage').create(); | ||
url = args[1]; | ||
page = require('webpage').create(); | ||
if (args[2] !== undefined) { | ||
timeout = parseInt(args[2], 10); | ||
} | ||
@@ -69,2 +72,10 @@ // Route `console.log()` calls from within the Page context to the main Phantom context (i.e. current `this`) | ||
// Set a timeout on the test running, otherwise tests with async problems will hang forever | ||
if (typeof timeout === 'number') { | ||
setTimeout(function() { | ||
console.error('The specified timeout of ' + timeout + ' seconds has expired. Aborting...'); | ||
phantom.exit(1); | ||
}, timeout * 1000); | ||
} | ||
// Do nothing... the callback mechanism will handle everything! | ||
@@ -76,3 +87,3 @@ } | ||
window.document.addEventListener('DOMContentLoaded', function() { | ||
var current_test_assertions = []; | ||
var currentTestAssertions = []; | ||
@@ -95,8 +106,9 @@ QUnit.log(function(details) { | ||
response += 'expected: ' + details.expected + ', but was: ' + details.actual; | ||
if (details.source) { | ||
response += "\n" + details.source; | ||
} | ||
} | ||
current_test_assertions.push('Failed assertion: ' + response); | ||
if (details.source) { | ||
response += "\n" + details.source; | ||
} | ||
currentTestAssertions.push('Failed assertion: ' + response); | ||
}); | ||
@@ -112,8 +124,8 @@ | ||
for (i = 0, len = current_test_assertions.length; i < len; i++) { | ||
console.log(' ' + current_test_assertions[i]); | ||
for (i = 0, len = currentTestAssertions.length; i < len; i++) { | ||
console.log(' ' + currentTestAssertions[i]); | ||
} | ||
} | ||
current_test_assertions.length = 0; | ||
currentTestAssertions.length = 0; | ||
}); | ||
@@ -120,0 +132,0 @@ |
@@ -12,4 +12,4 @@ Jörn Zaefferer <joern.zaefferer@gmail.com> | ||
Chris Lloyd <christopher.lloyd@gmail.com> | ||
Louis-Rémi Babé <public@lrbabe.com> | ||
Jake Archibald <jake.archibald@bbc.co.uk> | ||
Louis-Rémi Babé <lrbabe@gmail.com> | ||
Jake Archibald <jaffathecake@gmail.com> | ||
Frances Berriman <frances.berriman@bbc.co.uk> | ||
@@ -27,3 +27,3 @@ Rune Halvorsen <runefh@gmail.com> | ||
Anton Matzneller <obhvsbypqghgc@gmail.com> | ||
Aurélien Bombo | ||
Aurélien Bombo <hellosexyprout@gmail.com> | ||
Mathias Bynens <mathias@qiwi.be> | ||
@@ -58,1 +58,21 @@ Erik Vold <erikvvold@gmail.com> | ||
Sergii Kliuchnyk <sergiikliuchnyk@gmail.com> | ||
Corey Frang <gnarf@gnarf.net> | ||
John Reeves <john@jonnyreeves.co.uk> | ||
Antranig Basman <amb26ohloh@ponder.org.uk> | ||
Vivin Paliath <vivin.paliath@gmail.com> | ||
Joshua Niehus <jm.niehus@gmail.com> | ||
Glen Huang <curvedmark@gmail.com> | ||
Jonas Ulrich <jochenulrich@t-online.de> | ||
Jamie Hoover <jamie@ninjaui.com> | ||
James M. Greene <james.m.greene@gmail.com> | ||
Rodney Rehm <mail+github@rodneyrehm.de> | ||
Peter Wagenet <peter.wagenet@gmail.com> | ||
Clog <flewya@gmail.com> | ||
Matthew Mirande <itsbusticated@gmail.com> | ||
Jared Wyles <jared.wyles@gmail.com> | ||
Dmitry Gusev <dmitry.gusev@gmail.com> | ||
Ian Wallis <qazzian@gmail.com> | ||
Dan Andreescu <dan.andreescu@gmail.com> | ||
Matthew DuVall <mduvall89@gmail.com> | ||
Dave K. Smith <dave.k.smith@gmail.com> | ||
David Vollbracht <david.vollbracht@gmail.com> |
@@ -0,1 +1,28 @@ | ||
1.12.0 / 2013-06-21 | ||
=================== | ||
* Add a deprecation comment to QUnit.reset. Partial fix for #354 | ||
* Fix mis-match between moduleStart and moduleDone events | ||
* Removed jQuery.trim optimization. Fixes #424. | ||
* Use a local setTimeout reference, add separate unit test suite for that. Fixes #432 - Using a setTimeout stub can stop test suite from continuing. Closes gh-433 | ||
* Added CONTRIBUTING.md. | ||
* Moved 'addons/themes/nv' to 'Krinkle/qunit-theme-nv.git' | ||
* Moved 'addons/themes/ninja' to 'Krinkle/qunit-theme-ninja.git' | ||
* Moved 'addons/themes/gabe' to 'Krinkle/qunit-theme-gabe.git' | ||
* Moved 'addons/canvas' to 'JamesMGreene/qunit-assert-canvas.git'. Tree: https://github.com/JamesMGreene/qunit-assert-canvas/tree/v1.0.0 | ||
* Moved 'addons/close-enough' to 'JamesMGreene/qunit-assert-close.git'. Tree: https://github.com/JamesMGreene/qunit-assert-close/tree/v1.0.0 | ||
* Moved 'addons/step' to 'JamesMGreene/qunit-assert-step.git'. Tree: https://github.com/JamesMGreene/qunit-assert-step/tree/v1.0.0 | ||
* Canvas plugin: Show how to test with images. Closes gh-438. | ||
* Clear filter and testNumber when choosing a module. Fixes #442. | ||
* Deprecate QUnit.current_testEnvironment in favour of config.current.testEnvironment. | ||
* assert.ok: Message shouldn't be undefined in 'log' event. | ||
* Emit moduleStart before testStart even if test isn't in a module. | ||
* PhantomJS plugin: Added optional timeout. Closes #415. | ||
* PhantomJS plugin: Include stack trace for all failed tests. Closes #416. | ||
* Moved 'addons/composite' to 'jquery/qunit-composite.git'. Tree: https://github.com/jquery/qunit-composite/tree/v1.0.0 Fixes #419. | ||
* Moved 'addons/junitlogger' to 'jquery/qunit-reporter-junit.git'. | ||
* Sort the module names so we no longer rely on implicit ordering. Fixes #391. Closes gh-392 | ||
* JUnitLogger: Add a `name` property to the test run. Closes gh-389 | ||
* Improve circular reference logic in equiv - Fixes #397 | ||
1.11.0 / 2013-01-20 | ||
@@ -55,7 +82,7 @@ ================== | ||
* Move checkboxes into toolbar and give them labels and descriptions (as tooltip). Fixes #274 - Improve urlFilter API and UI | ||
* Where we recieve no exception in throws() use a relevant message. | ||
* Where we receive no exception in throws() use a relevant message. | ||
* Also make module filter case-insensitive. Follow-up to #252 | ||
* Banner: Link should ignore "testNumber" and "module". Fixes #270 | ||
* Rename assert.raises to assert.throws. Fixes #267 | ||
* Change package.json name property to 'qunitjs' to avoid conflicht with node-qunit; will publish next release to npm | ||
* Change package.json name property to 'qunitjs' to avoid conflict with node-qunit; will publish next release to npm | ||
@@ -91,3 +118,3 @@ 1.8.0 / 2012-06-14 | ||
* Prefix test-output id and ignore that in noglobals check. Fixes #212 | ||
* Only check for an exports object to detect a CommonJS enviroment. Fixes #237 - Incompatibility with require.js | ||
* Only check for an exports object to detect a CommonJS environment. Fixes #237 - Incompatibility with require.js | ||
* Add testswarm integration as grunt task | ||
@@ -113,3 +140,3 @@ * Added padding on URL config checkboxes. | ||
* Prefix test-related session-storage items to make removal more specific. Fixes #213 - Keep hide-passed state when clearing session storage | ||
* Update grunt.js with seperate configs for qunit.js and grunt.js, also add tests but disable for now, not passing yet. Add grunt to devDependencies | ||
* Update grunt.js with separate configs for qunit.js and grunt.js, also add tests but disable for now, not passing yet. Add grunt to devDependencies | ||
* typo | ||
@@ -145,7 +172,7 @@ * Cleanup grunt.js, no need for the banner | ||
* Extend nodejs test runner to check for stacktrace output | ||
* Generate more base markup, but allow the user to exclude that completelty or choose their own. Fixes #127 | ||
* Generate more base markup, but allow the user to exclude that completely or choose their own. Fixes #127 | ||
* Add a simple test file to check basic nodejs integration works | ||
* Check for global object to find setTimeout in node | ||
* Fix CommonJS export by assigning QUnit to module.exports. | ||
* Remove the testEnviromentArg to test(). Most obscure, never used anywhere. test() is still heavily overloaded with argument shifting, this makes it a little more sane. Fixes #172 | ||
* Remove the testEnvironmentArg to test(). Most obscure, never used anywhere. test() is still heavily overloaded with argument shifting, this makes it a little more sane. Fixes #172 | ||
* Serialize expected and actual values only when test fails. Speeds up output of valid tests, especially for lots of large objects. Fixes #183 | ||
@@ -162,3 +189,3 @@ * Fix sourceFromsTacktrace to get the right line in Firefox. Shift the 'error' line away in Chrome to get a match. | ||
* Update nv.html, add gabe theme based on https://github.com/jquery/qunit/pull/188 | ||
* Experiemental custom theme based on https://github.com/jquery/qunit/pull/62 by NV | ||
* Experimental custom theme based on https://github.com/jquery/qunit/pull/62 by NV | ||
* Replace deprecated same and equals aliases with placeholders that just throw errors, providing a hint at what to use instead. Rename test file to match that. | ||
@@ -220,5 +247,5 @@ * Can't rely on outerHTML for Firefox < 11. Use cloneNode instead. | ||
* Update readmes with .md extension for GitHub to render them as markdown | ||
* Update close-enough addon to include readme and match (new) naming convetions | ||
* Update close-enough addon to include readme and match (new) naming conventions | ||
* Merge remote branch 'righi/close-enough-addon' | ||
* Canvas addon: Update file referneces | ||
* Canvas addon: Update file references | ||
* Update canvas addon: Rename files and add README | ||
@@ -275,4 +302,4 @@ * Merge remote branch 'wwalser/composite' | ||
* Write to sessionStorage only bad tests | ||
* Moved QUnit.url() defintion after QUnit properties are merged into the global scope. Fixes #93 - QUnit url/extend function breaking urls in jQuery ajax test component | ||
* Add a "Rerun" link to each test to replce the dblclick (still supported, for now). | ||
* Moved QUnit.url() definition after QUnit properties are merged into the global scope. Fixes #93 - QUnit url/extend function breaking urls in jQuery ajax test component | ||
* Add a "Rerun" link to each test to replace the dblclick (still supported, for now). | ||
* Fixed the regex for parsing the name of a test when double clicking to filter. | ||
@@ -290,5 +317,5 @@ * Merge remote branch 'scottgonzalez/url' | ||
* Added URL flag ?notrycatch (ala ?noglobals) for debugging exceptions. Won't try/catch test code, giving better debugging changes on the original exceptions. Fixes #72 | ||
* Always show quni-toolbar (if at all specified), persist checkbox via sessionStorage. Fixes #47 | ||
* Always show qunit-toolbar (if at all specified), persist checkbox via sessionStorage. Fixes #47 | ||
* Use non-html testname for calls to fail(). Fixes #77 | ||
* Overhaul of QUnit.callbacks. Consistent single argument with related properties, with additonal runtime property for QUnit.done | ||
* Overhaul of QUnit.callbacks. Consistent single argument with related properties, with additional runtime property for QUnit.done | ||
* Extended test/logs.html to capture more of the callbacks. | ||
@@ -303,7 +330,7 @@ * Fixed moduleStart/Done callbacks. Added test/logs.html to test these callbacks. To be extended. | ||
* fix references inside Complex Instances Nesting to what was originally intended. | ||
* Qualify calls to ok() in raises() for compability with CLI enviroments. | ||
* Qualify calls to ok() in raises() for compatibility with CLI environments. | ||
* Fix done() handling, check for blocking, not block property | ||
* Fix moduleStart/Done and done callbacks. | ||
* Replacing sessionStorage test with the one from Modernizr/master (instead of current release). Here's hoping it'll work for some time. | ||
* Updated test for availibility of sessionStorage, based on test from Modernizr. Fixes #64 | ||
* Updated test for availability of sessionStorage, based on test from Modernizr. Fixes #64 | ||
* Defer test execution when previous run passed, persisted via sessionStorage. Fixes #49 | ||
@@ -355,3 +382,3 @@ * Refactored module handling and queuing to enable selective defer of test runs. | ||
* Cleaning up rubble from the previous commit. | ||
* Added raises assertion, reusing some of kennsnyder's code. | ||
* Added raises assertion, reusing some of kensnyder's code. | ||
* Merged kensnyder's object detection code. Original message: Streamlined object detection and exposed QUnit.objectType as a function. | ||
@@ -466,3 +493,3 @@ * Fixed some bad formatting. | ||
* qunit: don't child selectors when IE should behave nicely, too | ||
* qunit: improvment for the test-scope: create a new object and call setup, the test, and teardown in the scope of that object - allows you to provide test fixtures to each test without messing with global data; kudos to Martin Häcker for the contribution | ||
* qunit: improvement for the test-scope: create a new object and call setup, the test, and teardown in the scope of that object - allows you to provide test fixtures to each test without messing with global data; kudos to Martin Häcker for the contribution | ||
* qunit: added missing semicolons | ||
@@ -491,5 +518,5 @@ * qunit: fixed a semicolon, that should have been a comma | ||
* QUnit: minor output formatting | ||
* QUnit: adding same-assertion for a recursive comparsion of primite values, arrays and objects, thanks to Philippe Rathé for the contribution, including tests | ||
* QUnit: adding same-assertion for a recursive comparsion of primite values, arrays and objects, thanks to Philippe Rathé for the contribution, including tests | ||
* QUnit: adding same-assertion for a recursive comparsion of primite values, arrays and objects, thanks to Philippe Rathé for the contribution, including tests | ||
* QUnit: adding same-assertion for a recursive comparison of primitive values, arrays and objects, thanks to Philippe Rathé for the contribution, including tests | ||
* QUnit: adding same-assertion for a recursive comparison of primitive values, arrays and objects, thanks to Philippe Rathé for the contribution, including tests | ||
* QUnit: adding same-assertion for a recursive comparison of primitive values, arrays and objects, thanks to Philippe Rathé for the contribution, including tests | ||
* qunit: use window.load to initialize tests, allowing other code to run on document-ready before starting to run tests | ||
@@ -496,0 +523,0 @@ * qunit: allow either setup or teardown, instead of both or nothing |
@@ -5,3 +5,3 @@ { | ||
"description": "An easy-to-use JavaScript Unit Testing framework.", | ||
"version": "1.12.0pre", | ||
"version": "1.12.0", | ||
"author": { | ||
@@ -33,7 +33,13 @@ "name": "jQuery Foundation and other contributors", | ||
"main": "qunit/qunit.js", | ||
"scripts": { | ||
"test": "grunt" | ||
}, | ||
"devDependencies": { | ||
"grunt": "0.3.x", | ||
"grunt-git-authors": "1.0.0", | ||
"testswarm": "1.0.0-alpha" | ||
"grunt": "~0.4.0", | ||
"grunt-contrib-jshint": "~0.2.0", | ||
"grunt-contrib-qunit": "~0.2.0", | ||
"grunt-contrib-watch": "~0.3.0", | ||
"grunt-git-authors": "~1.2.0", | ||
"testswarm": "~1.0.1" | ||
} | ||
} |
/** | ||
* QUnit v1.12.0pre - A JavaScript Unit Testing Framework | ||
* QUnit v1.12.0 - A JavaScript Unit Testing Framework | ||
* | ||
* http://qunitjs.com | ||
* | ||
* Copyright 2012 jQuery Foundation and other contributors | ||
* Copyright 2013 jQuery Foundation and other contributors | ||
* Released under the MIT license. | ||
* http://jquery.org/license | ||
* https://jquery.org/license/ | ||
*/ | ||
@@ -23,2 +23,3 @@ | ||
Date = window.Date, | ||
setTimeout = window.setTimeout, | ||
defined = { | ||
@@ -119,4 +120,12 @@ setTimeout: typeof window.setTimeout !== "undefined", | ||
setup: function() { | ||
if ( this.module !== config.previousModule ) { | ||
if ( config.previousModule ) { | ||
if ( | ||
// Emit moduleStart when we're switching from one module to another | ||
this.module !== config.previousModule || | ||
// They could be equal (both undefined) but if the previousModule property doesn't | ||
// yet exist it means this is the first test in a suite that isn't wrapped in a | ||
// module, in which case we'll just emit a moduleStart event for 'undefined'. | ||
// Without this, reporters can get testStart before moduleStart which is a problem. | ||
!hasOwn.call( config, "previousModule" ) | ||
) { | ||
if ( hasOwn.call( config, "previousModule" ) ) { | ||
runLoggingCallbacks( "moduleDone", QUnit, { | ||
@@ -134,6 +143,2 @@ name: config.previousModule, | ||
}); | ||
} else if ( config.autorun ) { | ||
runLoggingCallbacks( "moduleStart", QUnit, { | ||
name: this.module | ||
}); | ||
} | ||
@@ -154,6 +159,14 @@ | ||
// allow utility functions to access the current test environment | ||
// TODO why?? | ||
/*jshint camelcase:false */ | ||
/** | ||
* Expose the current test environment. | ||
* | ||
* @deprecated since 1.12.0: Use QUnit.config.current.testEnvironment instead. | ||
*/ | ||
QUnit.current_testEnvironment = this.testEnvironment; | ||
/*jshint camelcase:true */ | ||
if ( !config.pollution ) { | ||
@@ -163,7 +176,7 @@ saveGlobal(); | ||
if ( config.notrycatch ) { | ||
this.testEnvironment.setup.call( this.testEnvironment ); | ||
this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert ); | ||
return; | ||
} | ||
try { | ||
this.testEnvironment.setup.call( this.testEnvironment ); | ||
this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert ); | ||
} catch( e ) { | ||
@@ -216,7 +229,7 @@ QUnit.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); | ||
} | ||
this.testEnvironment.teardown.call( this.testEnvironment ); | ||
this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert ); | ||
return; | ||
} else { | ||
try { | ||
this.testEnvironment.teardown.call( this.testEnvironment ); | ||
this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert ); | ||
} catch( e ) { | ||
@@ -428,3 +441,3 @@ QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); | ||
// Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through. | ||
// Specify the number of expected assertions to guarantee that failed test (no assertions are run at all) don't slip through. | ||
expect: function( asserts ) { | ||
@@ -464,3 +477,3 @@ if (arguments.length === 1) { | ||
if ( defined.setTimeout ) { | ||
window.setTimeout(function() { | ||
setTimeout(function() { | ||
if ( config.semaphore > 0 ) { | ||
@@ -488,3 +501,3 @@ return; | ||
clearTimeout( config.timeout ); | ||
config.timeout = window.setTimeout(function() { | ||
config.timeout = setTimeout(function() { | ||
QUnit.ok( false, "Test timed out" ); | ||
@@ -499,3 +512,3 @@ config.semaphore = 1; | ||
// `assert` initialized at top of scope | ||
// Asssert helpers | ||
// Assert helpers | ||
// All of these must either call QUnit.push() or manually do: | ||
@@ -518,2 +531,3 @@ // - runLoggingCallbacks( "log", .. ); | ||
result = !!result; | ||
msg = msg || (result ? "okay" : "failed" ); | ||
@@ -528,4 +542,3 @@ var source, | ||
msg = escapeText( msg || (result ? "okay" : "failed" ) ); | ||
msg = "<span class='test-message'>" + msg + "</span>"; | ||
msg = "<span class='test-message'>" + escapeText( msg ) + "</span>"; | ||
@@ -657,3 +670,3 @@ if ( !result ) { | ||
} else { | ||
QUnit.pushFailure( message, null, 'No exception was thrown.' ); | ||
QUnit.pushFailure( message, null, "No exception was thrown." ); | ||
} | ||
@@ -664,3 +677,3 @@ } | ||
/** | ||
* @deprecate since 1.8.0 | ||
* @deprecated since 1.8.0 | ||
* Kept assertion helpers in root for backwards compatibility. | ||
@@ -754,3 +767,3 @@ */ | ||
if ( typeof exports === "undefined" ) { | ||
extend( window, QUnit ); | ||
extend( window, QUnit.constructor.prototype ); | ||
@@ -854,2 +867,7 @@ // Expose QUnit object | ||
// Resets the test setup. Useful for tests that modify the DOM. | ||
/* | ||
DEPRECATED: Use multiple tests instead of resetting inside a test. | ||
Use testStart or testDone for custom cleanup. | ||
This method will throw an error in 2.0, and will be removed in 2.1 | ||
*/ | ||
reset: function() { | ||
@@ -1004,7 +1022,6 @@ var fixture = id( "qunit-fixture" ); | ||
for ( key in params ) { | ||
if ( !hasOwn.call( params, key ) ) { | ||
continue; | ||
if ( hasOwn.call( params, key ) ) { | ||
querystring += encodeURIComponent( key ) + "=" + | ||
encodeURIComponent( params[ key ] ) + "&"; | ||
} | ||
querystring += encodeURIComponent( key ) + "=" + | ||
encodeURIComponent( params[ key ] ) + "&"; | ||
} | ||
@@ -1017,3 +1034,6 @@ return window.location.protocol + "//" + window.location.host + | ||
id: id, | ||
addEvent: addEvent | ||
addEvent: addEvent, | ||
addClass: addClass, | ||
hasClass: hasClass, | ||
removeClass: removeClass | ||
// load, equiv, jsDump, diff: Attached later | ||
@@ -1065,2 +1085,3 @@ }); | ||
numModules = 0, | ||
moduleNames = [], | ||
moduleFilterHtml = "", | ||
@@ -1094,3 +1115,11 @@ urlConfigHtml = "", | ||
} | ||
for ( i in config.modules ) { | ||
if ( config.modules.hasOwnProperty( i ) ) { | ||
moduleNames.push(i); | ||
} | ||
} | ||
numModules = moduleNames.length; | ||
moduleNames.sort( function( a, b ) { | ||
return a.localeCompare( b ); | ||
}); | ||
moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' " + | ||
@@ -1100,9 +1129,7 @@ ( config.module === undefined ? "selected='selected'" : "" ) + | ||
for ( i in config.modules ) { | ||
if ( config.modules.hasOwnProperty( i ) ) { | ||
numModules += 1; | ||
moduleFilterHtml += "<option value='" + escapeText( encodeURIComponent(i) ) + "' " + | ||
( config.module === i ? "selected='selected'" : "" ) + | ||
">" + escapeText(i) + "</option>"; | ||
} | ||
for ( i = 0; i < numModules; i++) { | ||
moduleFilterHtml += "<option value='" + escapeText( encodeURIComponent(moduleNames[i]) ) + "' " + | ||
( config.module === moduleNames[i] ? "selected='selected'" : "" ) + | ||
">" + escapeText(moduleNames[i]) + "</option>"; | ||
} | ||
@@ -1161,3 +1188,3 @@ moduleFilterHtml += "</select>"; | ||
label.setAttribute( "for", "qunit-filter-pass" ); | ||
label.setAttribute( "title", "Only show tests and assertons that fail. Stored in sessionStorage." ); | ||
label.setAttribute( "title", "Only show tests and assertions that fail. Stored in sessionStorage." ); | ||
label.innerHTML = "Hide passed tests"; | ||
@@ -1182,4 +1209,4 @@ toolbar.appendChild( label ); | ||
if (numModules > 1) { | ||
moduleFilter = document.createElement( 'span' ); | ||
moduleFilter.setAttribute( 'id', 'qunit-modulefilter-container' ); | ||
moduleFilter = document.createElement( "span" ); | ||
moduleFilter.setAttribute( "id", "qunit-modulefilter-container" ); | ||
moduleFilter.innerHTML = moduleFilterHtml; | ||
@@ -1190,3 +1217,8 @@ addEvent( moduleFilter.lastChild, "change", function() { | ||
window.location = QUnit.url( { module: ( selectedModule === "" ) ? undefined : selectedModule } ); | ||
window.location = QUnit.url({ | ||
module: ( selectedModule === "" ) ? undefined : selectedModule, | ||
// Remove any existing filters | ||
filter: undefined, | ||
testNumber: undefined | ||
}); | ||
}); | ||
@@ -1215,3 +1247,3 @@ toolbar.appendChild(moduleFilter); | ||
// Cover uncaught exceptions | ||
// Returning true will surpress the default browser handler, | ||
// Returning true will suppress the default browser handler, | ||
// returning false will let it run. | ||
@@ -1225,3 +1257,3 @@ window.onerror = function ( error, filePath, linerNr ) { | ||
// Treat return value as window.onerror itself does, | ||
// Only do our handling if not surpressed. | ||
// Only do our handling if not suppressed. | ||
if ( ret !== true ) { | ||
@@ -1256,2 +1288,3 @@ if ( QUnit.config.current ) { | ||
} | ||
delete config.previousModule; | ||
@@ -1416,12 +1449,12 @@ var i, key, | ||
switch( s ) { | ||
case '\'': | ||
return '''; | ||
case '"': | ||
return '"'; | ||
case '<': | ||
return '<'; | ||
case '>': | ||
return '>'; | ||
case '&': | ||
return '&'; | ||
case "'": | ||
return "'"; | ||
case "\"": | ||
return """; | ||
case "<": | ||
return "<"; | ||
case ">": | ||
return ">"; | ||
case "&": | ||
return "&"; | ||
} | ||
@@ -1450,3 +1483,3 @@ }); | ||
} else { | ||
window.setTimeout( next, 13 ); | ||
setTimeout( next, 13 ); | ||
break; | ||
@@ -1466,7 +1499,9 @@ } | ||
for ( var key in window ) { | ||
// in Opera sometimes DOM element ids show up here, ignore them | ||
if ( !hasOwn.call( window, key ) || /^qunit-test-output/.test( key ) ) { | ||
continue; | ||
if ( hasOwn.call( window, key ) ) { | ||
// in Opera sometimes DOM element ids show up here, ignore them | ||
if ( /^qunit-test-output/.test( key ) ) { | ||
continue; | ||
} | ||
config.pollution.push( key ); | ||
} | ||
config.pollution.push( key ); | ||
} | ||
@@ -1513,8 +1548,11 @@ } | ||
for ( var prop in b ) { | ||
if ( b[ prop ] === undefined ) { | ||
delete a[ prop ]; | ||
// Avoid "Member not found" error in IE8 caused by setting window.constructor | ||
} else if ( prop !== "constructor" || a !== window ) { | ||
a[ prop ] = b[ prop ]; | ||
if ( hasOwn.call( b, prop ) ) { | ||
// Avoid "Member not found" error in IE8 caused by messing with window.constructor | ||
if ( !( prop === "constructor" && a === window ) ) { | ||
if ( b[ prop ] === undefined ) { | ||
delete a[ prop ]; | ||
} else { | ||
a[ prop ] = b[ prop ]; | ||
} | ||
} | ||
} | ||
@@ -1569,4 +1607,4 @@ } | ||
} | ||
// If possible, trim it for prettiness, but not neccecarily | ||
elem.className = window.jQuery ? jQuery.trim( set ) : ( set.trim ? set.trim() : set ); | ||
// If possible, trim it for prettiness, but not necessarily | ||
elem.className = typeof set.trim === "function" ? set.trim() : set.replace(/^\s+|\s+$/g, ""); | ||
} | ||
@@ -1620,4 +1658,6 @@ | ||
parents = [], | ||
parentsB = [], | ||
getProto = Object.getPrototypeOf || function ( obj ) { | ||
/*jshint camelcase:false */ | ||
return obj.__proto__; | ||
@@ -1631,3 +1671,3 @@ }, | ||
if ( b instanceof a.constructor || a instanceof b.constructor ) { | ||
// to catch short annotaion VS 'new' annotation of a | ||
// to catch short annotation VS 'new' annotation of a | ||
// declaration | ||
@@ -1661,3 +1701,3 @@ // e.g. var i = 1; | ||
a.source === b.source && | ||
// and its modifers | ||
// and its modifiers | ||
a.global === b.global && | ||
@@ -1679,3 +1719,3 @@ // (gmi) ... | ||
"array": function( b, a ) { | ||
var i, j, len, loop; | ||
var i, j, len, loop, aCircular, bCircular; | ||
@@ -1695,7 +1735,16 @@ // b could be an object literal here | ||
parents.push( a ); | ||
parentsB.push( b ); | ||
for ( i = 0; i < len; i++ ) { | ||
loop = false; | ||
for ( j = 0; j < parents.length; j++ ) { | ||
if ( parents[j] === a[i] ) { | ||
loop = true;// dont rewalk array | ||
aCircular = parents[j] === a[i]; | ||
bCircular = parentsB[j] === b[i]; | ||
if ( aCircular || bCircular ) { | ||
if ( a[i] === b[i] || aCircular && bCircular ) { | ||
loop = true; | ||
} else { | ||
parents.pop(); | ||
parentsB.pop(); | ||
return false; | ||
} | ||
} | ||
@@ -1705,2 +1754,3 @@ } | ||
parents.pop(); | ||
parentsB.pop(); | ||
return false; | ||
@@ -1710,2 +1760,3 @@ } | ||
parents.pop(); | ||
parentsB.pop(); | ||
return true; | ||
@@ -1715,3 +1766,4 @@ }, | ||
"object": function( b, a ) { | ||
var i, j, loop, | ||
/*jshint forin:false */ | ||
var i, j, loop, aCircular, bCircular, | ||
// Default to true | ||
@@ -1735,17 +1787,24 @@ eq = true, | ||
callers.push( a.constructor ); | ||
// track reference to avoid circular references | ||
parents.push( a ); | ||
parentsB.push( b ); | ||
for ( i in a ) { // be strict: don't ensures hasOwnProperty | ||
// and go deep | ||
// be strict: don't ensure hasOwnProperty and go deep | ||
for ( i in a ) { | ||
loop = false; | ||
for ( j = 0; j < parents.length; j++ ) { | ||
if ( parents[j] === a[i] ) { | ||
// don't go down the same path twice | ||
loop = true; | ||
aCircular = parents[j] === a[i]; | ||
bCircular = parentsB[j] === b[i]; | ||
if ( aCircular || bCircular ) { | ||
if ( a[i] === b[i] || aCircular && bCircular ) { | ||
loop = true; | ||
} else { | ||
eq = false; | ||
break; | ||
} | ||
} | ||
} | ||
aProperties.push(i); // collect a's properties | ||
if (!loop && !innerEquiv( a[i], b[i] ) ) { | ||
aProperties.push(i); | ||
if ( !loop && !innerEquiv(a[i], b[i]) ) { | ||
eq = false; | ||
@@ -1756,4 +1815,5 @@ break; | ||
parents.pop(); | ||
parentsB.pop(); | ||
callers.pop(); // unstack, we are done | ||
parents.pop(); | ||
@@ -1788,3 +1848,3 @@ for ( i in b ) { | ||
// apply transition with (1..n) arguments | ||
}( args[0], args[1] ) && arguments.callee.apply( this, args.splice(1, args.length - 1 )) ); | ||
}( args[0], args[1] ) && innerEquiv.apply( this, args.splice(1, args.length - 1 )) ); | ||
}; | ||
@@ -1807,3 +1867,3 @@ | ||
function quote( str ) { | ||
return '"' + str.toString().replace( /"/g, '\\"' ) + '"'; | ||
return "\"" + str.toString().replace( /"/g, "\\\"" ) + "\""; | ||
} | ||
@@ -1901,9 +1961,9 @@ function literal( o ) { | ||
} | ||
return new Array( this._depth_ + (extra||0) ).join(chr); | ||
return new Array( this.depth + ( extra || 0 ) ).join(chr); | ||
}, | ||
up: function( a ) { | ||
this._depth_ += a || 1; | ||
this.depth += a || 1; | ||
}, | ||
down: function( a ) { | ||
this._depth_ -= a || 1; | ||
this.depth -= a || 1; | ||
}, | ||
@@ -1918,3 +1978,3 @@ setParser: function( name, parser ) { | ||
// | ||
_depth_: 1, | ||
depth: 1, | ||
// This is the list of parsers, to modify them, use jsDump.setParser | ||
@@ -1947,2 +2007,3 @@ parsers: { | ||
object: function( map, stack ) { | ||
/*jshint forin:false */ | ||
var ret = [ ], keys, key, val, i; | ||
@@ -2086,15 +2147,14 @@ QUnit.jsDump.up(); | ||
for ( i in ns ) { | ||
if ( !hasOwn.call( ns, i ) ) { | ||
continue; | ||
if ( hasOwn.call( ns, i ) ) { | ||
if ( ns[i].rows.length === 1 && hasOwn.call( os, i ) && os[i].rows.length === 1 ) { | ||
n[ ns[i].rows[0] ] = { | ||
text: n[ ns[i].rows[0] ], | ||
row: os[i].rows[0] | ||
}; | ||
o[ os[i].rows[0] ] = { | ||
text: o[ os[i].rows[0] ], | ||
row: ns[i].rows[0] | ||
}; | ||
} | ||
} | ||
if ( ns[i].rows.length === 1 && hasOwn.call( os, i ) && os[i].rows.length === 1 ) { | ||
n[ ns[i].rows[0] ] = { | ||
text: n[ ns[i].rows[0] ], | ||
row: os[i].rows[0] | ||
}; | ||
o[ os[i].rows[0] ] = { | ||
text: o[ os[i].rows[0] ], | ||
row: ns[i].rows[0] | ||
}; | ||
} | ||
} | ||
@@ -2194,5 +2254,5 @@ | ||
// for CommonJS enviroments, export everything | ||
// for CommonJS environments, export everything | ||
if ( typeof exports !== "undefined" ) { | ||
extend( exports, QUnit ); | ||
extend( exports, QUnit.constructor.prototype ); | ||
} | ||
@@ -2199,0 +2259,0 @@ |
@@ -1,5 +0,6 @@ | ||
[QUnit](http://qunitjs.com) - A JavaScript Unit Testing framework. | ||
================================ | ||
[![Build Status](http://jenkins.jquery.com/job/QUnit/badge/icon)](http://jenkins.jquery.com/job/QUnit/) | ||
QUnit is a powerful, easy-to-use, JavaScript test suite. It's used by the jQuery | ||
# [QUnit](http://qunitjs.com) - A JavaScript Unit Testing Framework. | ||
QUnit is a powerful, easy-to-use, JavaScript unit testing framework. It's used by the jQuery | ||
project to test its code and plugins but is capable of testing any generic | ||
@@ -26,4 +27,3 @@ JavaScript code (and even capable of testing JavaScript code on the server-side). | ||
Development | ||
----------- | ||
## Development | ||
@@ -39,4 +39,3 @@ To submit patches, fork the repository, create a branch for the change. Then implement | ||
Releases | ||
-------- | ||
## Releases | ||
@@ -43,0 +42,0 @@ Install git-extras and run `git changelog` to update History.md. Clean up the |
QUnit.start(); | ||
test("just a test", function() { | ||
test("just a test", function( assert ) { | ||
expect(1); | ||
ok(true); | ||
assert.ok(true); | ||
}); |
module("equiv"); | ||
test("Primitive types and constants", function () { | ||
equal(QUnit.equiv(null, null), true, "null"); | ||
equal(QUnit.equiv(null, {}), false, "null"); | ||
equal(QUnit.equiv(null, undefined), false, "null"); | ||
equal(QUnit.equiv(null, 0), false, "null"); | ||
equal(QUnit.equiv(null, false), false, "null"); | ||
equal(QUnit.equiv(null, ''), false, "null"); | ||
equal(QUnit.equiv(null, []), false, "null"); | ||
test("Primitive types and constants", function ( assert ) { | ||
assert.equal(QUnit.equiv(null, null), true, "null"); | ||
assert.equal(QUnit.equiv(null, {}), false, "null"); | ||
assert.equal(QUnit.equiv(null, undefined), false, "null"); | ||
assert.equal(QUnit.equiv(null, 0), false, "null"); | ||
assert.equal(QUnit.equiv(null, false), false, "null"); | ||
assert.equal(QUnit.equiv(null, ''), false, "null"); | ||
assert.equal(QUnit.equiv(null, []), false, "null"); | ||
equal(QUnit.equiv(undefined, undefined), true, "undefined"); | ||
equal(QUnit.equiv(undefined, null), false, "undefined"); | ||
equal(QUnit.equiv(undefined, 0), false, "undefined"); | ||
equal(QUnit.equiv(undefined, false), false, "undefined"); | ||
equal(QUnit.equiv(undefined, {}), false, "undefined"); | ||
equal(QUnit.equiv(undefined, []), false, "undefined"); | ||
equal(QUnit.equiv(undefined, ""), false, "undefined"); | ||
assert.equal(QUnit.equiv(undefined, undefined), true, "undefined"); | ||
assert.equal(QUnit.equiv(undefined, null), false, "undefined"); | ||
assert.equal(QUnit.equiv(undefined, 0), false, "undefined"); | ||
assert.equal(QUnit.equiv(undefined, false), false, "undefined"); | ||
assert.equal(QUnit.equiv(undefined, {}), false, "undefined"); | ||
assert.equal(QUnit.equiv(undefined, []), false, "undefined"); | ||
assert.equal(QUnit.equiv(undefined, ""), false, "undefined"); | ||
// Nan usually doest not equal to Nan using the '==' operator. | ||
// Only isNaN() is able to do it. | ||
equal(QUnit.equiv(0/0, 0/0), true, "NaN"); // NaN VS NaN | ||
equal(QUnit.equiv(1/0, 2/0), true, "Infinity"); // Infinity VS Infinity | ||
equal(QUnit.equiv(-1/0, 2/0), false, "-Infinity, Infinity"); // -Infinity VS Infinity | ||
equal(QUnit.equiv(-1/0, -2/0), true, "-Infinity, -Infinity"); // -Infinity VS -Infinity | ||
equal(QUnit.equiv(0/0, 1/0), false, "NaN, Infinity"); // Nan VS Infinity | ||
equal(QUnit.equiv(1/0, 0/0), false, "NaN, Infinity"); // Nan VS Infinity | ||
equal(QUnit.equiv(0/0, null), false, "NaN"); | ||
equal(QUnit.equiv(0/0, undefined), false, "NaN"); | ||
equal(QUnit.equiv(0/0, 0), false, "NaN"); | ||
equal(QUnit.equiv(0/0, false), false, "NaN"); | ||
equal(QUnit.equiv(0/0, function () {}), false, "NaN"); | ||
equal(QUnit.equiv(1/0, null), false, "NaN, Infinity"); | ||
equal(QUnit.equiv(1/0, undefined), false, "NaN, Infinity"); | ||
equal(QUnit.equiv(1/0, 0), false, "NaN, Infinity"); | ||
equal(QUnit.equiv(1/0, 1), false, "NaN, Infinity"); | ||
equal(QUnit.equiv(1/0, false), false, "NaN, Infinity"); | ||
equal(QUnit.equiv(1/0, true), false, "NaN, Infinity"); | ||
equal(QUnit.equiv(1/0, function () {}), false, "NaN, Infinity"); | ||
assert.equal(QUnit.equiv(0/0, 0/0), true, "NaN"); // NaN VS NaN | ||
assert.equal(QUnit.equiv(1/0, 2/0), true, "Infinity"); // Infinity VS Infinity | ||
assert.equal(QUnit.equiv(-1/0, 2/0), false, "-Infinity, Infinity"); // -Infinity VS Infinity | ||
assert.equal(QUnit.equiv(-1/0, -2/0), true, "-Infinity, -Infinity"); // -Infinity VS -Infinity | ||
assert.equal(QUnit.equiv(0/0, 1/0), false, "NaN, Infinity"); // Nan VS Infinity | ||
assert.equal(QUnit.equiv(1/0, 0/0), false, "NaN, Infinity"); // Nan VS Infinity | ||
assert.equal(QUnit.equiv(0/0, null), false, "NaN"); | ||
assert.equal(QUnit.equiv(0/0, undefined), false, "NaN"); | ||
assert.equal(QUnit.equiv(0/0, 0), false, "NaN"); | ||
assert.equal(QUnit.equiv(0/0, false), false, "NaN"); | ||
assert.equal(QUnit.equiv(0/0, function () {}), false, "NaN"); | ||
assert.equal(QUnit.equiv(1/0, null), false, "NaN, Infinity"); | ||
assert.equal(QUnit.equiv(1/0, undefined), false, "NaN, Infinity"); | ||
assert.equal(QUnit.equiv(1/0, 0), false, "NaN, Infinity"); | ||
assert.equal(QUnit.equiv(1/0, 1), false, "NaN, Infinity"); | ||
assert.equal(QUnit.equiv(1/0, false), false, "NaN, Infinity"); | ||
assert.equal(QUnit.equiv(1/0, true), false, "NaN, Infinity"); | ||
assert.equal(QUnit.equiv(1/0, function () {}), false, "NaN, Infinity"); | ||
equal(QUnit.equiv(0, 0), true, "number"); | ||
equal(QUnit.equiv(0, 1), false, "number"); | ||
equal(QUnit.equiv(1, 0), false, "number"); | ||
equal(QUnit.equiv(1, 1), true, "number"); | ||
equal(QUnit.equiv(1.1, 1.1), true, "number"); | ||
equal(QUnit.equiv(0.0000005, 0.0000005), true, "number"); | ||
equal(QUnit.equiv(0, ''), false, "number"); | ||
equal(QUnit.equiv(0, '0'), false, "number"); | ||
equal(QUnit.equiv(1, '1'), false, "number"); | ||
equal(QUnit.equiv(0, false), false, "number"); | ||
equal(QUnit.equiv(1, true), false, "number"); | ||
assert.equal(QUnit.equiv(0, 0), true, "number"); | ||
assert.equal(QUnit.equiv(0, 1), false, "number"); | ||
assert.equal(QUnit.equiv(1, 0), false, "number"); | ||
assert.equal(QUnit.equiv(1, 1), true, "number"); | ||
assert.equal(QUnit.equiv(1.1, 1.1), true, "number"); | ||
assert.equal(QUnit.equiv(0.0000005, 0.0000005), true, "number"); | ||
assert.equal(QUnit.equiv(0, ''), false, "number"); | ||
assert.equal(QUnit.equiv(0, '0'), false, "number"); | ||
assert.equal(QUnit.equiv(1, '1'), false, "number"); | ||
assert.equal(QUnit.equiv(0, false), false, "number"); | ||
assert.equal(QUnit.equiv(1, true), false, "number"); | ||
equal(QUnit.equiv(true, true), true, "boolean"); | ||
equal(QUnit.equiv(true, false), false, "boolean"); | ||
equal(QUnit.equiv(false, true), false, "boolean"); | ||
equal(QUnit.equiv(false, 0), false, "boolean"); | ||
equal(QUnit.equiv(false, null), false, "boolean"); | ||
equal(QUnit.equiv(false, undefined), false, "boolean"); | ||
equal(QUnit.equiv(true, 1), false, "boolean"); | ||
equal(QUnit.equiv(true, null), false, "boolean"); | ||
equal(QUnit.equiv(true, undefined), false, "boolean"); | ||
assert.equal(QUnit.equiv(true, true), true, "boolean"); | ||
assert.equal(QUnit.equiv(true, false), false, "boolean"); | ||
assert.equal(QUnit.equiv(false, true), false, "boolean"); | ||
assert.equal(QUnit.equiv(false, 0), false, "boolean"); | ||
assert.equal(QUnit.equiv(false, null), false, "boolean"); | ||
assert.equal(QUnit.equiv(false, undefined), false, "boolean"); | ||
assert.equal(QUnit.equiv(true, 1), false, "boolean"); | ||
assert.equal(QUnit.equiv(true, null), false, "boolean"); | ||
assert.equal(QUnit.equiv(true, undefined), false, "boolean"); | ||
equal(QUnit.equiv('', ''), true, "string"); | ||
equal(QUnit.equiv('a', 'a'), true, "string"); | ||
equal(QUnit.equiv("foobar", "foobar"), true, "string"); | ||
equal(QUnit.equiv("foobar", "foo"), false, "string"); | ||
equal(QUnit.equiv('', 0), false, "string"); | ||
equal(QUnit.equiv('', false), false, "string"); | ||
equal(QUnit.equiv('', null), false, "string"); | ||
equal(QUnit.equiv('', undefined), false, "string"); | ||
assert.equal(QUnit.equiv('', ''), true, "string"); | ||
assert.equal(QUnit.equiv('a', 'a'), true, "string"); | ||
assert.equal(QUnit.equiv("foobar", "foobar"), true, "string"); | ||
assert.equal(QUnit.equiv("foobar", "foo"), false, "string"); | ||
assert.equal(QUnit.equiv('', 0), false, "string"); | ||
assert.equal(QUnit.equiv('', false), false, "string"); | ||
assert.equal(QUnit.equiv('', null), false, "string"); | ||
assert.equal(QUnit.equiv('', undefined), false, "string"); | ||
@@ -79,41 +79,41 @@ // Rename for lint validation. | ||
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"); | ||
assert.equal(QUnit.equiv(0, new SafeNumber()), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(new SafeNumber(), 0), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(1, new SafeNumber(1)), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(new SafeNumber(1), 1), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(new SafeNumber(0), 1), false, "primitives vs. objects"); | ||
assert.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"); | ||
assert.equal(QUnit.equiv(new SafeString(), ""), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv("", new SafeString()), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(new SafeString("My String"), "My String"), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv("My String", new SafeString("My String")), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv("Bad String", new SafeString("My String")), false, "primitives vs. objects"); | ||
assert.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"); | ||
assert.equal(QUnit.equiv(false, new SafeBoolean()), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(new SafeBoolean(), false), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(true, new SafeBoolean(true)), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(new SafeBoolean(true), true), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(true, new SafeBoolean(1)), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(false, new SafeBoolean(false)), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(new SafeBoolean(false), false), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(false, new SafeBoolean(0)), true, "primitives vs. objects"); | ||
assert.equal(QUnit.equiv(true, new SafeBoolean(false)), false, "primitives vs. objects"); | ||
assert.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"); | ||
assert.equal(QUnit.equiv(new SafeObject(), {}), true, "object literal vs. instantiation"); | ||
assert.equal(QUnit.equiv({}, new SafeObject()), true, "object literal vs. instantiation"); | ||
assert.equal(QUnit.equiv(new SafeObject(), {a:1}), false, "object literal vs. instantiation"); | ||
assert.equal(QUnit.equiv({a:1}, new SafeObject()), false, "object literal vs. instantiation"); | ||
assert.equal(QUnit.equiv({a:undefined}, new SafeObject()), false, "object literal vs. instantiation"); | ||
assert.equal(QUnit.equiv(new SafeObject(), {a:undefined}), false, "object literal vs. instantiation"); | ||
}); | ||
test("Objects Basics.", function() { | ||
equal(QUnit.equiv({}, {}), true); | ||
equal(QUnit.equiv({}, null), false); | ||
equal(QUnit.equiv({}, undefined), false); | ||
equal(QUnit.equiv({}, 0), false); | ||
equal(QUnit.equiv({}, false), false); | ||
test("Objects basics", function( assert ) { | ||
assert.equal(QUnit.equiv({}, {}), true); | ||
assert.equal(QUnit.equiv({}, null), false); | ||
assert.equal(QUnit.equiv({}, undefined), false); | ||
assert.equal(QUnit.equiv({}, 0), false); | ||
assert.equal(QUnit.equiv({}, false), false); | ||
@@ -125,15 +125,15 @@ // This test is a hard one, it is very important | ||
// 3) Their properties are the same (doesn't exists) | ||
equal(QUnit.equiv({}, []), false); | ||
assert.equal(QUnit.equiv({}, []), false); | ||
equal(QUnit.equiv({a:1}, {a:1}), true); | ||
equal(QUnit.equiv({a:1}, {a:"1"}), false); | ||
equal(QUnit.equiv({a:[]}, {a:[]}), true); | ||
equal(QUnit.equiv({a:{}}, {a:null}), false); | ||
equal(QUnit.equiv({a:1}, {}), false); | ||
equal(QUnit.equiv({}, {a:1}), false); | ||
assert.equal(QUnit.equiv({a:1}, {a:1}), true); | ||
assert.equal(QUnit.equiv({a:1}, {a:"1"}), false); | ||
assert.equal(QUnit.equiv({a:[]}, {a:[]}), true); | ||
assert.equal(QUnit.equiv({a:{}}, {a:null}), false); | ||
assert.equal(QUnit.equiv({a:1}, {}), false); | ||
assert.equal(QUnit.equiv({}, {a:1}), false); | ||
// Hard ones | ||
equal(QUnit.equiv({a:undefined}, {}), false); | ||
equal(QUnit.equiv({}, {a:undefined}), false); | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv({a:undefined}, {}), false); | ||
assert.equal(QUnit.equiv({}, {a:undefined}), false); | ||
assert.equal(QUnit.equiv( | ||
{ | ||
@@ -150,3 +150,3 @@ a: [{ bar: undefined }] | ||
if (typeof Object.create === 'function') { | ||
equal(QUnit.equiv(Object.create(null), {}), true, "empty object without prototype VS empty object"); | ||
assert.equal(QUnit.equiv(Object.create(null), {}), true, "empty object without prototype VS empty object"); | ||
@@ -156,3 +156,3 @@ var nonEmptyWithNoProto = Object.create(null); | ||
equal(QUnit.equiv(nonEmptyWithNoProto, { foo: "bar" }), true, "object without prototype VS object"); | ||
assert.equal(QUnit.equiv(nonEmptyWithNoProto, { foo: "bar" }), true, "object without prototype VS object"); | ||
} | ||
@@ -162,5 +162,5 @@ }); | ||
test("Arrays Basics.", function() { | ||
test("Arrays basics", function( assert ) { | ||
equal(QUnit.equiv([], []), true); | ||
assert.equal(QUnit.equiv([], []), true); | ||
@@ -170,29 +170,29 @@ // May be a hard one, can invoke a crash at execution. | ||
// like a true object, it doesn't have any property at all. | ||
equal(QUnit.equiv([], null), false); | ||
assert.equal(QUnit.equiv([], null), false); | ||
equal(QUnit.equiv([], undefined), false); | ||
equal(QUnit.equiv([], false), false); | ||
equal(QUnit.equiv([], 0), false); | ||
equal(QUnit.equiv([], ""), false); | ||
assert.equal(QUnit.equiv([], undefined), false); | ||
assert.equal(QUnit.equiv([], false), false); | ||
assert.equal(QUnit.equiv([], 0), false); | ||
assert.equal(QUnit.equiv([], ""), false); | ||
// May be a hard one, but less hard | ||
// than {} with [] (note the order) | ||
equal(QUnit.equiv([], {}), false); | ||
assert.equal(QUnit.equiv([], {}), false); | ||
equal(QUnit.equiv([null],[]), false); | ||
equal(QUnit.equiv([undefined],[]), false); | ||
equal(QUnit.equiv([],[null]), false); | ||
equal(QUnit.equiv([],[undefined]), false); | ||
equal(QUnit.equiv([null],[undefined]), false); | ||
equal(QUnit.equiv([[]],[[]]), true); | ||
equal(QUnit.equiv([[],[],[]],[[],[],[]]), true); | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv([null],[]), false); | ||
assert.equal(QUnit.equiv([undefined],[]), false); | ||
assert.equal(QUnit.equiv([],[null]), false); | ||
assert.equal(QUnit.equiv([],[undefined]), false); | ||
assert.equal(QUnit.equiv([null],[undefined]), false); | ||
assert.equal(QUnit.equiv([[]],[[]]), true); | ||
assert.equal(QUnit.equiv([[],[],[]],[[],[],[]]), true); | ||
assert.equal(QUnit.equiv( | ||
[[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], | ||
[[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]), | ||
true); | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv( | ||
[[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], | ||
[[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]), // shorter | ||
false); | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv( | ||
[[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{}]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], | ||
@@ -203,3 +203,3 @@ [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]), // deepest element not an array | ||
// same multidimensional | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv( | ||
[1,2,3,4,5,6,7,8,9, [ | ||
@@ -250,3 +250,3 @@ 1,2,3,4,5,6,7,8,9, [ | ||
// different multidimensional | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv( | ||
[1,2,3,4,5,6,7,8,9, [ | ||
@@ -297,3 +297,3 @@ 1,2,3,4,5,6,7,8,9, [ | ||
// different multidimensional | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv( | ||
[1,2,3,4,5,6,7,8,9, [ | ||
@@ -344,3 +344,3 @@ 1,2,3,4,5,6,7,8,9, [ | ||
test("Functions.", function() { | ||
test("Functions", function( assert ) { | ||
var f0 = function () {}; | ||
@@ -350,23 +350,23 @@ var f1 = function () {}; | ||
// f2 and f3 have the same code, formatted differently | ||
var f2 = function () {var i = 0;}; | ||
var f2 = function () {return 0;}; | ||
var f3 = function () { | ||
/*jshint asi:true */ | ||
var i = 0 // this comment and no semicoma as difference | ||
return 0 // this comment and no semicoma as difference | ||
}; | ||
equal(QUnit.equiv(function() {}, function() {}), false, "Anonymous functions"); // exact source code | ||
equal(QUnit.equiv(function() {}, function() {return true;}), false, "Anonymous functions"); | ||
assert.equal(QUnit.equiv(function() {}, function() {}), false, "Anonymous functions"); // exact source code | ||
assert.equal(QUnit.equiv(function() {}, function() {return true;}), false, "Anonymous functions"); | ||
equal(QUnit.equiv(f0, f0), true, "Function references"); // same references | ||
equal(QUnit.equiv(f0, f1), false, "Function references"); // exact source code, different references | ||
equal(QUnit.equiv(f2, f3), false, "Function references"); // equivalent source code, different references | ||
equal(QUnit.equiv(f1, f2), false, "Function references"); // different source code, different references | ||
equal(QUnit.equiv(function() {}, true), false); | ||
equal(QUnit.equiv(function() {}, undefined), false); | ||
equal(QUnit.equiv(function() {}, null), false); | ||
equal(QUnit.equiv(function() {}, {}), false); | ||
assert.equal(QUnit.equiv(f0, f0), true, "Function references"); // same references | ||
assert.equal(QUnit.equiv(f0, f1), false, "Function references"); // exact source code, different references | ||
assert.equal(QUnit.equiv(f2, f3), false, "Function references"); // equivalent source code, different references | ||
assert.equal(QUnit.equiv(f1, f2), false, "Function references"); // different source code, different references | ||
assert.equal(QUnit.equiv(function() {}, true), false); | ||
assert.equal(QUnit.equiv(function() {}, undefined), false); | ||
assert.equal(QUnit.equiv(function() {}, null), false); | ||
assert.equal(QUnit.equiv(function() {}, {}), false); | ||
}); | ||
test("Date instances.", function() { | ||
test("Date instances", function( assert ) { | ||
// Date, we don't need to test Date.parse() because it returns a number. | ||
@@ -385,11 +385,11 @@ // Only test the Date instances by setting them a fix date. | ||
// Anyway their types differs, just in case the code fails in the order in which it deals with date | ||
equal(QUnit.equiv(d1, 0), false); // d1.valueOf() returns 0, but d1 and 0 are different | ||
assert.equal(QUnit.equiv(d1, 0), false); // d1.valueOf() returns 0, but d1 and 0 are different | ||
// test same values date and different instances equality | ||
equal(QUnit.equiv(d1, d2), true); | ||
assert.equal(QUnit.equiv(d1, d2), true); | ||
// test different date and different instances difference | ||
equal(QUnit.equiv(d1, d3), false); | ||
assert.equal(QUnit.equiv(d1, d3), false); | ||
}); | ||
test("RegExp.", function() { | ||
test("RegExp", function( assert ) { | ||
// Must test cases that imply those traps: | ||
@@ -416,18 +416,18 @@ // var a = /./; | ||
equal(QUnit.equiv(r5, r6), true, "Modifier order"); | ||
equal(QUnit.equiv(r5, r7), true, "Modifier order"); | ||
equal(QUnit.equiv(r5, r8), true, "Modifier order"); | ||
equal(QUnit.equiv(r5, r9), true, "Modifier order"); | ||
equal(QUnit.equiv(r5, r10), true, "Modifier order"); | ||
equal(QUnit.equiv(r, r5), false, "Modifier"); | ||
assert.equal(QUnit.equiv(r5, r6), true, "Modifier order"); | ||
assert.equal(QUnit.equiv(r5, r7), true, "Modifier order"); | ||
assert.equal(QUnit.equiv(r5, r8), true, "Modifier order"); | ||
assert.equal(QUnit.equiv(r5, r9), true, "Modifier order"); | ||
assert.equal(QUnit.equiv(r5, r10), true, "Modifier order"); | ||
assert.equal(QUnit.equiv(r, r5), false, "Modifier"); | ||
equal(QUnit.equiv(ri1, ri2), true, "Modifier"); | ||
equal(QUnit.equiv(r, ri1), false, "Modifier"); | ||
equal(QUnit.equiv(ri1, rm1), false, "Modifier"); | ||
equal(QUnit.equiv(r, rm1), false, "Modifier"); | ||
equal(QUnit.equiv(rm1, ri1), false, "Modifier"); | ||
equal(QUnit.equiv(rm1, rm2), true, "Modifier"); | ||
equal(QUnit.equiv(rg1, rm1), false, "Modifier"); | ||
equal(QUnit.equiv(rm1, rg1), false, "Modifier"); | ||
equal(QUnit.equiv(rg1, rg2), true, "Modifier"); | ||
assert.equal(QUnit.equiv(ri1, ri2), true, "Modifier"); | ||
assert.equal(QUnit.equiv(r, ri1), false, "Modifier"); | ||
assert.equal(QUnit.equiv(ri1, rm1), false, "Modifier"); | ||
assert.equal(QUnit.equiv(r, rm1), false, "Modifier"); | ||
assert.equal(QUnit.equiv(rm1, ri1), false, "Modifier"); | ||
assert.equal(QUnit.equiv(rm1, rm2), true, "Modifier"); | ||
assert.equal(QUnit.equiv(rg1, rm1), false, "Modifier"); | ||
assert.equal(QUnit.equiv(rm1, rg1), false, "Modifier"); | ||
assert.equal(QUnit.equiv(rg1, rg2), true, "Modifier"); | ||
@@ -437,7 +437,7 @@ // Different regex, same modifiers | ||
var r13 = /[0-9]/gi; // oops! different | ||
equal(QUnit.equiv(r11, r13), false, "Regex pattern"); | ||
assert.equal(QUnit.equiv(r11, r13), false, "Regex pattern"); | ||
var r14 = /0/ig; | ||
var r15 = /"0"/ig; // oops! different | ||
equal(QUnit.equiv(r14, r15), false, "Regex pattern"); | ||
assert.equal(QUnit.equiv(r14, r15), false, "Regex pattern"); | ||
@@ -449,5 +449,5 @@ var r1 = /[\n\r\u2028\u2029]/g; | ||
equal(QUnit.equiv(r1, r2), true, "Regex pattern"); | ||
equal(QUnit.equiv(r1, r3), false, "Regex pattern"); | ||
equal(QUnit.equiv(r1, r4), false, "Regex pattern"); | ||
assert.equal(QUnit.equiv(r1, r2), true, "Regex pattern"); | ||
assert.equal(QUnit.equiv(r1, r3), false, "Regex pattern"); | ||
assert.equal(QUnit.equiv(r1, r4), false, "Regex pattern"); | ||
@@ -466,15 +466,15 @@ // More complex regex | ||
equal(QUnit.equiv(r21, r22), true, "Complex Regex"); | ||
equal(QUnit.equiv(r21, r23), false, "Complex Regex"); | ||
equal(QUnit.equiv(r23, r23a), false, "Complex Regex"); | ||
equal(QUnit.equiv(r23a, r24a), true, "Complex Regex"); | ||
assert.equal(QUnit.equiv(r21, r22), true, "Complex Regex"); | ||
assert.equal(QUnit.equiv(r21, r23), false, "Complex Regex"); | ||
assert.equal(QUnit.equiv(r23, r23a), false, "Complex Regex"); | ||
assert.equal(QUnit.equiv(r23a, r24a), true, "Complex Regex"); | ||
// typeof r1 is "function" in some browsers and "object" in others so we must cover this test | ||
var re = / /; | ||
equal(QUnit.equiv(re, function () {}), false, "Regex internal"); | ||
equal(QUnit.equiv(re, {}), false, "Regex internal"); | ||
assert.equal(QUnit.equiv(re, function () {}), false, "Regex internal"); | ||
assert.equal(QUnit.equiv(re, {}), false, "Regex internal"); | ||
}); | ||
test("Complex Objects.", function() { | ||
test("Complex objects", function( assert ) { | ||
@@ -490,3 +490,3 @@ function fn1() { | ||
// It can failed when properties are compared between unsorted arrays. | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv( | ||
{ | ||
@@ -586,3 +586,3 @@ a: 1, | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv( | ||
{ | ||
@@ -682,3 +682,3 @@ a: 1, | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv( | ||
{ | ||
@@ -778,3 +778,3 @@ a: 1, | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv( | ||
{ | ||
@@ -966,18 +966,32 @@ a: 1, | ||
equal(QUnit.equiv(same1, same2), true); | ||
equal(QUnit.equiv(same2, same1), true); | ||
equal(QUnit.equiv(same2, diff1), false); | ||
equal(QUnit.equiv(diff1, same2), false); | ||
var diff6 = { | ||
a: [ | ||
"string", null, 0, "1", 1, { | ||
prop: null, | ||
foo: [1,2,null,{}, [], [1,2,3]], | ||
bar: undefined | ||
}, 3, "Hey!", "Κάνε πάντα γνωÏίζουμε ας των, μηχανής επιδιόÏθωσης επιδιοÏθώσεις ÏŽÏ‚ μια. Κλπ ας" | ||
], | ||
unicode: "è€ æ±‰è¯ä¸å˜åœ¨ 港澳和海外的åŽäººåœˆä¸ 贵州 我去了书店 现在尚有争", | ||
b: "b", | ||
c: fn2 // different: fn2 instead of fn1 | ||
}; | ||
equal(QUnit.equiv(same1, diff1), false); | ||
equal(QUnit.equiv(same1, diff2), false); | ||
equal(QUnit.equiv(same1, diff3), false); | ||
equal(QUnit.equiv(same1, diff3), false); | ||
equal(QUnit.equiv(same1, diff4), false); | ||
equal(QUnit.equiv(same1, diff5), false); | ||
equal(QUnit.equiv(diff5, diff1), false); | ||
assert.equal(QUnit.equiv(same1, same2), true); | ||
assert.equal(QUnit.equiv(same2, same1), true); | ||
assert.equal(QUnit.equiv(same2, diff1), false); | ||
assert.equal(QUnit.equiv(diff1, same2), false); | ||
assert.equal(QUnit.equiv(same1, diff1), false); | ||
assert.equal(QUnit.equiv(same1, diff2), false); | ||
assert.equal(QUnit.equiv(same1, diff3), false); | ||
assert.equal(QUnit.equiv(same1, diff3), false); | ||
assert.equal(QUnit.equiv(same1, diff4), false); | ||
assert.equal(QUnit.equiv(same1, diff5), false); | ||
assert.equal(QUnit.equiv(same1, diff6), false); | ||
assert.equal(QUnit.equiv(diff5, diff1), false); | ||
}); | ||
test("Complex Arrays.", function() { | ||
test("Complex Arrays", function( assert ) { | ||
@@ -987,3 +1001,3 @@ function fn() { | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv( | ||
[1, 2, 3, true, {}, null, [ | ||
@@ -1003,3 +1017,3 @@ { | ||
equal(QUnit.equiv( | ||
assert.equal(QUnit.equiv( | ||
[1, 2, 3, true, {}, null, [ | ||
@@ -1043,3 +1057,3 @@ { | ||
equal(QUnit.equiv(a, | ||
assert.equal(QUnit.equiv(a, | ||
[{ | ||
@@ -1069,3 +1083,3 @@ b: fn, | ||
equal(QUnit.equiv(a, | ||
assert.equal(QUnit.equiv(a, | ||
[{ | ||
@@ -1095,3 +1109,3 @@ b: fn, | ||
equal(QUnit.equiv(a, | ||
assert.equal(QUnit.equiv(a, | ||
[{ | ||
@@ -1121,3 +1135,3 @@ b: fn, | ||
equal(QUnit.equiv(a, | ||
assert.equal(QUnit.equiv(a, | ||
[{ | ||
@@ -1147,3 +1161,3 @@ b: fn, | ||
equal(QUnit.equiv(a, | ||
assert.equal(QUnit.equiv(a, | ||
[{ | ||
@@ -1175,3 +1189,3 @@ b: fn, | ||
test("Prototypal inheritance", function() { | ||
test("Prototypal inheritance", function( assert ) { | ||
function Gizmo(id) { | ||
@@ -1191,3 +1205,3 @@ this.id = id; | ||
// to make sure that our code does not mess with last object constructor memoization. | ||
equal(QUnit.equiv(function () {}, function () {}), false); | ||
assert.equal(QUnit.equiv(function () {}, function () {}), false); | ||
@@ -1197,3 +1211,3 @@ // Hoozit inherit from Gizmo | ||
// hoozit instanceof Gizmo; // true | ||
equal(QUnit.equiv(hoozit, gizmo), true); | ||
assert.equal(QUnit.equiv(hoozit, gizmo), true); | ||
@@ -1204,3 +1218,3 @@ Gizmo.prototype.bar = true; // not a function just in case we skip them | ||
// They are equivalent | ||
equal(QUnit.equiv(hoozit, gizmo), true); | ||
assert.equal(QUnit.equiv(hoozit, gizmo), true); | ||
@@ -1210,6 +1224,6 @@ // Make sure this is still true !important | ||
// caller to where it were called from. | ||
equal(QUnit.equiv(function () {}, function () {}), false); | ||
assert.equal(QUnit.equiv(function () {}, function () {}), false); | ||
// Make sure this is still true !important | ||
equal(QUnit.equiv(hoozit, gizmo), true); | ||
assert.equal(QUnit.equiv(hoozit, gizmo), true); | ||
@@ -1222,10 +1236,10 @@ Hoozit.prototype.foo = true; // not a function just in case we skip them | ||
// They are not equivalent | ||
equal(QUnit.equiv(hoozit, gizmo), false); | ||
assert.equal(QUnit.equiv(hoozit, gizmo), false); | ||
// Make sure this is still true !important | ||
equal(QUnit.equiv(function () {}, function () {}), false); | ||
assert.equal(QUnit.equiv(function () {}, function () {}), false); | ||
}); | ||
test("Instances", function() { | ||
test("Instances", function( assert ) { | ||
function A() {} | ||
@@ -1241,8 +1255,8 @@ var a1 = new A(); | ||
equal(QUnit.equiv(a1, a2), true, "Same property, same constructor"); | ||
assert.equal(QUnit.equiv(a1, a2), true, "Same property, same constructor"); | ||
// b1.fn and b2.fn are functions but they are different references | ||
// But we decided to skip function for instances. | ||
equal(QUnit.equiv(b1, b2), true, "Same property, same constructor"); | ||
equal(QUnit.equiv(a1, b1), false, "Same properties but different constructor"); // failed | ||
assert.equal(QUnit.equiv(b1, b2), true, "Same property, same constructor"); | ||
assert.equal(QUnit.equiv(a1, b1), false, "Same properties but different constructor"); // failed | ||
@@ -1253,3 +1267,3 @@ function Car(year) { | ||
this.isOld = function() { | ||
return year > 10; | ||
return privateVar > 10; | ||
}; | ||
@@ -1262,3 +1276,3 @@ } | ||
this.isOld = function() { | ||
return year > 80; | ||
return privateVar > 80; | ||
}; | ||
@@ -1272,19 +1286,18 @@ } | ||
var diff = { | ||
year: 30 | ||
}; | ||
/** | ||
* difference: | ||
* - year: 30 | ||
* same: | ||
* - year: 30, | ||
* - isOld: function () {} | ||
*/ | ||
var same = { | ||
year: 30, | ||
isOld: function () {} | ||
}; | ||
equal(QUnit.equiv(car, car), true); | ||
equal(QUnit.equiv(car, carDiff), false); | ||
equal(QUnit.equiv(car, carSame), true); | ||
equal(QUnit.equiv(car, human), false); | ||
assert.equal(QUnit.equiv(car, car), true); | ||
assert.equal(QUnit.equiv(car, carDiff), false); | ||
assert.equal(QUnit.equiv(car, carSame), true); | ||
assert.equal(QUnit.equiv(car, human), false); | ||
}); | ||
test("Complex Instances Nesting (with function value in literals and/or in nested instances)", function() { | ||
test("Complex instance nesting (with function values in literals and/or in nested instances)", function( assert ) { | ||
function A(fn) { | ||
@@ -1342,3 +1355,3 @@ this.a = {}; | ||
// This function won't be ingored. | ||
// It isn't visible for all C insances | ||
// It isn't visible for all C instances | ||
// and it is not in a property of an instance. (in an Object instances e.g. the object literal) | ||
@@ -1388,21 +1401,21 @@ c: fnInside | ||
var a2 = new A(function () {}); | ||
equal(QUnit.equiv(a1, a2), true); | ||
assert.equal(QUnit.equiv(a1, a2), true); | ||
equal(QUnit.equiv(a1, a2), true); // different instances | ||
assert.equal(QUnit.equiv(a1, a2), true); // different instances | ||
var b1 = new B(function () {}); | ||
var b2 = new B(function () {}); | ||
equal(QUnit.equiv(b1, b2), true); | ||
assert.equal(QUnit.equiv(b1, b2), true); | ||
var c1 = new C(function () {}); | ||
var c2 = new C(function () {}); | ||
equal(QUnit.equiv(c1, c2), true); | ||
assert.equal(QUnit.equiv(c1, c2), true); | ||
var d1 = new D(function () {}); | ||
var d2 = new D(function () {}); | ||
equal(QUnit.equiv(d1, d2), false); | ||
assert.equal(QUnit.equiv(d1, d2), false); | ||
var e1 = new E(function () {}); | ||
var e2 = new E(function () {}); | ||
equal(QUnit.equiv(e1, e2), false); | ||
assert.equal(QUnit.equiv(e1, e2), false); | ||
@@ -1412,22 +1425,22 @@ }); | ||
test('object with references to self wont loop', function() { | ||
test("Object with circular references", function( assert ) { | ||
var circularA = { | ||
abc:null | ||
abc: null | ||
}, circularB = { | ||
abc:null | ||
abc: null | ||
}; | ||
circularA.abc = circularA; | ||
circularB.abc = circularB; | ||
equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object (ambigous test)"); | ||
assert.equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object (ambiguous test)"); | ||
circularA.def = 1; | ||
circularB.def = 1; | ||
equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object (ambigous test)"); | ||
assert.equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object (ambiguous test)"); | ||
circularA.def = 1; | ||
circularB.def = 0; | ||
equal(QUnit.equiv(circularA, circularB), false, "Should not repeat test on object (unambigous test)"); | ||
assert.equal(QUnit.equiv(circularA, circularB), false, "Should not repeat test on object (unambiguous test)"); | ||
}); | ||
test('array with references to self wont loop', function() { | ||
test("Array with circular references", function( assert ) { | ||
var circularA = [], | ||
@@ -1437,14 +1450,14 @@ circularB = []; | ||
circularB.push(circularB); | ||
equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on array (ambigous test)"); | ||
assert.equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on array (ambiguous test)"); | ||
circularA.push( 'abc' ); | ||
circularB.push( 'abc' ); | ||
equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on array (ambigous test)"); | ||
circularA.push( "abc" ); | ||
circularB.push( "abc" ); | ||
assert.equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on array (ambiguous test)"); | ||
circularA.push( 'hello' ); | ||
circularB.push( 'goodbye' ); | ||
equal(QUnit.equiv(circularA, circularB), false, "Should not repeat test on array (unambigous test)"); | ||
circularA.push( "hello" ); | ||
circularB.push( "goodbye" ); | ||
assert.equal(QUnit.equiv(circularA, circularB), false, "Should not repeat test on array (unambiguous test)"); | ||
}); | ||
test('mixed object/array with references to self wont loop', function() { | ||
test("Mixed object/array with references to self wont loop", function( assert ) { | ||
var circularA = [{abc:null}], | ||
@@ -1457,14 +1470,40 @@ circularB = [{abc:null}]; | ||
circularB.push(circularB); | ||
equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object/array (ambigous test)"); | ||
assert.equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object/array (ambiguous test)"); | ||
circularA[0].def = 1; | ||
circularB[0].def = 1; | ||
equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object/array (ambigous test)"); | ||
assert.equal(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object/array (ambiguous test)"); | ||
circularA[0].def = 1; | ||
circularB[0].def = 0; | ||
equal(QUnit.equiv(circularA, circularB), false, "Should not repeat test on object/array (unambigous test)"); | ||
assert.equal(QUnit.equiv(circularA, circularB), false, "Should not repeat test on object/array (unambiguous test)"); | ||
}); | ||
test("Test that must be done at the end because they extend some primitive's prototype", function() { | ||
test("Compare self-referent to tree", function ( assert ) { | ||
var temp, | ||
circularA = [0], | ||
treeA = [0, null], | ||
circularO = {}, | ||
treeO = { | ||
o: null | ||
}; | ||
circularA[1] = circularA; | ||
circularO.o = circularO; | ||
assert.equal(QUnit.equiv(circularA, treeA), false, "Array: Should not consider circular equal to tree"); | ||
assert.equal(QUnit.equiv(circularO, treeO), false, "Object: Should not consider circular equal to tree"); | ||
temp = [ 0, circularA ]; | ||
assert.equal(QUnit.equiv(circularA, temp), true, "Array: Reference is circular for one, but equal on other"); | ||
assert.equal(QUnit.equiv(temp, circularA), true, "Array: Reference is circular for one, but equal on other"); | ||
temp = { | ||
o: circularO | ||
}; | ||
assert.equal(QUnit.equiv(circularO, temp), true, "Object: Reference is circular for one, but equal on other"); | ||
assert.equal(QUnit.equiv(temp, circularO), true, "Object: Reference is circular for one, but equal on other"); | ||
}); | ||
test("Test that must be done at the end because they extend some primitive's prototype", function( assert ) { | ||
// Try that a function looks like our regular expression. | ||
@@ -1477,6 +1516,6 @@ // This tests if we check that a and b are really both instance of RegExp | ||
var re = /my regex/gm; | ||
equal(QUnit.equiv(re, function () {}), false, "A function that looks that a regex isn't a regex"); | ||
assert.equal(QUnit.equiv(re, function () {}), false, "A function that looks that a regex isn't a regex"); | ||
// This test will ensures it works in both ways, and ALSO especially that we can make differences | ||
// between RegExp and Function constructor because typeof on a RegExpt instance is "function" | ||
equal(QUnit.equiv(function () {}, re), false, "Same conversely, but ensures that function and regexp are distinct because their constructor are different"); | ||
assert.equal(QUnit.equiv(function () {}, re), false, "Same conversely, but ensures that function and regexp are distinct because their constructor are different"); | ||
}); |
115
test/logs.js
@@ -43,9 +43,9 @@ // TODO disable reordering for this suite! | ||
test("test1", 15, function() { | ||
equal( begin, 1, "QUnit.begin calls" ); | ||
equal( moduleStart, 1, "QUnit.moduleStart calls" ); | ||
equal( testStart, 1, "QUnit.testStart calls" ); | ||
equal( testDone, 0, "QUnit.testDone calls" ); | ||
equal( moduleDone, 0, "QUnit.moduleDone calls" ); | ||
deepEqual( logContext, { | ||
test("test1", 15, function( assert ) { | ||
assert.equal( begin, 1, "QUnit.begin calls" ); | ||
assert.equal( moduleStart, 1, "QUnit.moduleStart calls" ); | ||
assert.equal( testStart, 1, "QUnit.testStart calls" ); | ||
assert.equal( testDone, 0, "QUnit.testDone calls" ); | ||
assert.equal( moduleDone, 0, "QUnit.moduleDone calls" ); | ||
assert.deepEqual( logContext, { | ||
name: "test1", | ||
@@ -59,4 +59,4 @@ module: "logs1", | ||
equal( "foo", "foo" ); | ||
deepEqual(logContext, { | ||
assert.equal( "foo", "foo" ); | ||
assert.deepEqual(logContext, { | ||
name: "test1", | ||
@@ -70,4 +70,4 @@ module: "logs1", | ||
ok( true, "ok(true, message)" ); | ||
deepEqual( logContext, { | ||
assert.ok( true, "ok(true, message)" ); | ||
assert.deepEqual( logContext, { | ||
module: "logs1", | ||
@@ -79,24 +79,24 @@ name: "test1", | ||
strictEqual( testDoneContext, undefined, "testDone context" ); | ||
deepEqual( testContext, { | ||
assert.strictEqual( testDoneContext, undefined, "testDone context" ); | ||
assert.deepEqual( testContext, { | ||
module: "logs1", | ||
name: "test1" | ||
}, "test context" ); | ||
strictEqual( moduleDoneContext, undefined, "moduleDone context" ); | ||
deepEqual( moduleContext, { | ||
assert.strictEqual( moduleDoneContext, undefined, "moduleDone context" ); | ||
assert.deepEqual( moduleContext, { | ||
name: "logs1" | ||
}, "module context" ); | ||
equal( log, 14, "QUnit.log calls" ); | ||
assert.equal( log, 14, "QUnit.log calls" ); | ||
}); | ||
test("test2", 11, function() { | ||
equal( begin, 1, "QUnit.begin calls" ); | ||
equal( moduleStart, 1, "QUnit.moduleStart calls" ); | ||
equal( testStart, 2, "QUnit.testStart calls" ); | ||
equal( testDone, 1, "QUnit.testDone calls" ); | ||
equal( moduleDone, 0, "QUnit.moduleDone calls" ); | ||
test("test2", 11, function( assert ) { | ||
assert.equal( begin, 1, "QUnit.begin calls" ); | ||
assert.equal( moduleStart, 1, "QUnit.moduleStart calls" ); | ||
assert.equal( testStart, 2, "QUnit.testStart calls" ); | ||
assert.equal( testDone, 1, "QUnit.testDone calls" ); | ||
assert.equal( moduleDone, 0, "QUnit.moduleDone calls" ); | ||
ok( typeof testDoneContext.duration === "number" , "testDone context: duration" ); | ||
assert.ok( typeof testDoneContext.duration === "number" , "testDone context: duration" ); | ||
delete testDoneContext.duration; | ||
deepEqual( testDoneContext, { | ||
assert.deepEqual( testDoneContext, { | ||
module: "logs1", | ||
@@ -108,12 +108,12 @@ name: "test1", | ||
}, "testDone context" ); | ||
deepEqual( testContext, { | ||
assert.deepEqual( testContext, { | ||
module: "logs1", | ||
name: "test2" | ||
}, "test context" ); | ||
strictEqual( moduleDoneContext, undefined, "moduleDone context" ); | ||
deepEqual( moduleContext, { | ||
assert.strictEqual( moduleDoneContext, undefined, "moduleDone context" ); | ||
assert.deepEqual( moduleContext, { | ||
name: "logs1" | ||
}, "module context" ); | ||
equal( log, 25, "QUnit.log calls" ); | ||
assert.equal( log, 25, "QUnit.log calls" ); | ||
}); | ||
@@ -123,14 +123,14 @@ | ||
test( "test1", 9, function() { | ||
equal( begin, 1, "QUnit.begin calls" ); | ||
equal( moduleStart, 2, "QUnit.moduleStart calls" ); | ||
equal( testStart, 3, "QUnit.testStart calls" ); | ||
equal( testDone, 2, "QUnit.testDone calls" ); | ||
equal( moduleDone, 1, "QUnit.moduleDone calls" ); | ||
test( "test1", 9, function( assert ) { | ||
assert.equal( begin, 1, "QUnit.begin calls" ); | ||
assert.equal( moduleStart, 2, "QUnit.moduleStart calls" ); | ||
assert.equal( testStart, 3, "QUnit.testStart calls" ); | ||
assert.equal( testDone, 2, "QUnit.testDone calls" ); | ||
assert.equal( moduleDone, 1, "QUnit.moduleDone calls" ); | ||
deepEqual( testContext, { | ||
assert.deepEqual( testContext, { | ||
module: "logs2", | ||
name: "test1" | ||
}, "test context" ); | ||
deepEqual( moduleDoneContext, { | ||
assert.deepEqual( moduleDoneContext, { | ||
name: "logs1", | ||
@@ -141,24 +141,24 @@ failed: 0, | ||
}, "moduleDone context" ); | ||
deepEqual( moduleContext, { | ||
assert.deepEqual( moduleContext, { | ||
name: "logs2" | ||
}, "module context" ); | ||
equal( log, 34, "QUnit.log calls" ); | ||
assert.equal( log, 34, "QUnit.log calls" ); | ||
}); | ||
test( "test2", 8, function() { | ||
equal( begin, 1, "QUnit.begin calls" ); | ||
equal( moduleStart, 2, "QUnit.moduleStart calls" ); | ||
equal( testStart, 4, "QUnit.testStart calls" ); | ||
equal( testDone, 3, "QUnit.testDone calls" ); | ||
equal( moduleDone, 1, "QUnit.moduleDone calls" ); | ||
test( "test2", 8, function( assert ) { | ||
assert.equal( begin, 1, "QUnit.begin calls" ); | ||
assert.equal( moduleStart, 2, "QUnit.moduleStart calls" ); | ||
assert.equal( testStart, 4, "QUnit.testStart calls" ); | ||
assert.equal( testDone, 3, "QUnit.testDone calls" ); | ||
assert.equal( moduleDone, 1, "QUnit.moduleDone calls" ); | ||
deepEqual( testContext, { | ||
assert.deepEqual( testContext, { | ||
module: "logs2", | ||
name: "test2" | ||
}, "test context" ); | ||
deepEqual( moduleContext, { | ||
assert.deepEqual( moduleContext, { | ||
name: "logs2" | ||
}, "module context" ); | ||
equal( log, 42, "QUnit.log calls" ); | ||
assert.equal( log, 42, "QUnit.log calls" ); | ||
}); | ||
@@ -176,17 +176,18 @@ | ||
moduleStart = moduleDone = 0; | ||
// Since these tests run *after* done, and as such | ||
// QUnit is not able to know whether more tests are coming | ||
// the module starts/ends after each test. | ||
module("autorun"); | ||
test("reset", 0, function() {}); | ||
moduleStart = moduleDone = 0; | ||
test("first", function() { | ||
equal(moduleStart, 1, "test started"); | ||
equal(moduleDone, 0, "test in progress"); | ||
test("first", function( assert ) { | ||
assert.equal(moduleStart, 1, "test started"); | ||
assert.equal(moduleDone, 0, "test in progress"); | ||
}); | ||
test("second", function() { | ||
equal(moduleStart, 2, "test started"); | ||
equal(moduleDone, 1, "test in progress"); | ||
test("second", function( assert ) { | ||
assert.equal(moduleStart, 2, "test started"); | ||
assert.equal(moduleDone, 1, "test in progress"); | ||
}); | ||
}); |
@@ -0,1 +1,2 @@ | ||
/*jshint node:true, undef:false */ | ||
// Run with: $ narwhal test/narwhal-test.js | ||
@@ -2,0 +3,0 @@ var QUnit = require("../qunit/qunit"); |
@@ -0,1 +1,2 @@ | ||
/*jshint node:true, undef:false */ | ||
// Run with: $ node test/node-test.js | ||
@@ -2,0 +3,0 @@ var QUnit = require("../qunit/qunit"); |
@@ -0,0 +0,0 @@ // load testswarm agent |
309
test/test.js
@@ -41,24 +41,24 @@ function getPreviousTests( rTestName, rModuleName ) { | ||
test("module without setup/teardown (default)", function() { | ||
test("module without setup/teardown (default)", function( assert ) { | ||
expect(1); | ||
ok(true); | ||
assert.ok(true); | ||
}); | ||
test("expect in test", 3, function() { | ||
ok(true); | ||
ok(true); | ||
ok(true); | ||
test("expect in test", 3, function( assert ) { | ||
assert.ok(true); | ||
assert.ok(true); | ||
assert.ok(true); | ||
}); | ||
test("expect in test", 1, function() { | ||
ok(true); | ||
test("expect in test", 1, function( assert ) { | ||
assert.ok(true); | ||
}); | ||
test("expect query and multiple issue", function() { | ||
test("expect query and multiple issue", function( assert ) { | ||
expect(2); | ||
ok(true); | ||
assert.ok(true); | ||
var expected = expect(); | ||
equal(expected, 2); | ||
assert.equal(expected, 2); | ||
expect(expected + 1); | ||
ok(true); | ||
assert.ok(true); | ||
}); | ||
@@ -76,3 +76,3 @@ | ||
QUnit.ok( true, "Calling aliased method in QUnit root object" ); | ||
ok( true, "Calling aliased function in global namespace" ); | ||
assert.ok( true, "Calling aliased function in global namespace" ); | ||
@@ -87,14 +87,14 @@ // Regression fix for #341 | ||
module("setup test", { | ||
setup: function() { | ||
ok(true); | ||
setup: function( assert ) { | ||
assert.ok(true); | ||
} | ||
}); | ||
test("module with setup", function() { | ||
test("module with setup", function( assert ) { | ||
expect(2); | ||
ok(true); | ||
assert.ok(true); | ||
}); | ||
test("module with setup, expect in test call", 2, function() { | ||
ok(true); | ||
test("module with setup, expect in test call", 2, function( assert ) { | ||
assert.ok(true); | ||
}); | ||
@@ -105,3 +105,3 @@ | ||
}, | ||
teardown: function() { | ||
teardown: function( assert ) { | ||
// We can't use ok(false) inside script tags since some browsers | ||
@@ -113,9 +113,9 @@ // don't evaluate script tags inserted through innerHTML after domready. | ||
// This can either be from in #qunit-modulefilter or #qunit-testresult | ||
ok(false, 'Unscaped module name'); | ||
assert.ok(false, 'Unescaped module name'); | ||
} | ||
if (document.getElementById('qunit-unescaped-test')) { | ||
ok(false, 'Unscaped test name'); | ||
assert.ok(false, 'Unescaped test name'); | ||
} | ||
if (document.getElementById('qunit-unescaped-assertion')) { | ||
ok(false, 'Unscaped test name'); | ||
assert.ok(false, 'Unescaped test name'); | ||
} | ||
@@ -125,4 +125,4 @@ } | ||
test("<script id='qunit-unescaped-test'>'test';</script>", 1, function() { | ||
ok(true, "<script id='qunit-unescaped-asassertionsert'>'assertion';</script>"); | ||
test("<script id='qunit-unescaped-test'>'test';</script>", 1, function( assert ) { | ||
assert.ok(true, "<script id='qunit-unescaped-asassertionsert'>'assertion';</script>"); | ||
}); | ||
@@ -133,5 +133,5 @@ | ||
module("setup/teardown test", { | ||
setup: function() { | ||
setup: function( assert ) { | ||
state = true; | ||
ok(true); | ||
assert.ok(true); | ||
// Assert that we can introduce and delete globals in setup/teardown | ||
@@ -153,4 +153,4 @@ // without noglobals sounding any alarm. | ||
}, | ||
teardown: function() { | ||
ok(true); | ||
teardown: function( assert ) { | ||
assert.ok(true); | ||
@@ -167,5 +167,5 @@ /*@cc_on | ||
test("module with setup/teardown", function() { | ||
test("module with setup/teardown", function( assert ) { | ||
expect(3); | ||
ok(true); | ||
assert.ok(true); | ||
}); | ||
@@ -175,5 +175,5 @@ | ||
test("module without setup/teardown", function() { | ||
test("module without setup/teardown", function( assert ) { | ||
expect(1); | ||
ok(true); | ||
assert.ok(true); | ||
}); | ||
@@ -184,6 +184,6 @@ | ||
module("Date test", { | ||
setup: function() { | ||
setup: function( assert ) { | ||
orgDate = Date; | ||
window.Date = function () { | ||
ok( false, 'QUnit should internally be independant from Date-related manipulation and testing' ); | ||
assert.ok( false, 'QUnit should internally be independent from Date-related manipulation and testing' ); | ||
return new orgDate(); | ||
@@ -197,5 +197,5 @@ }; | ||
test("sample test for Date test", function () { | ||
test("sample test for Date test", function ( assert ) { | ||
expect(1); | ||
ok(true); | ||
assert.ok(true); | ||
}); | ||
@@ -207,4 +207,4 @@ | ||
module("teardown and stop", { | ||
teardown: function() { | ||
equal(state, "done", "Test teardown."); | ||
teardown: function( assert ) { | ||
assert.equal(state, "done", "Test teardown."); | ||
} | ||
@@ -248,6 +248,6 @@ }); | ||
module("async setup test", { | ||
setup: function() { | ||
setup: function( assert ) { | ||
stop(); | ||
setTimeout(function() { | ||
ok(true); | ||
assert.ok(true); | ||
start(); | ||
@@ -258,5 +258,5 @@ }, 500); | ||
asyncTest("module with async setup", function() { | ||
asyncTest("module with async setup", function( assert ) { | ||
expect(2); | ||
ok(true); | ||
assert.ok(true); | ||
start(); | ||
@@ -266,6 +266,6 @@ }); | ||
module("async teardown test", { | ||
teardown: function() { | ||
teardown: function( assert ) { | ||
stop(); | ||
setTimeout(function() { | ||
ok(true); | ||
assert.ok(true); | ||
start(); | ||
@@ -276,5 +276,5 @@ }, 500); | ||
asyncTest("module with async teardown", function() { | ||
asyncTest("module with async teardown", function( assert ) { | ||
expect(2); | ||
ok(true); | ||
assert.ok(true); | ||
start(); | ||
@@ -285,8 +285,7 @@ }); | ||
asyncTest("asyncTest", function() { | ||
expect(2); | ||
ok(true); | ||
asyncTest("asyncTest", 2, function( assert ) { | ||
assert.ok(true); | ||
setTimeout(function() { | ||
state = "done"; | ||
ok(true); | ||
assert.ok(true); | ||
start(); | ||
@@ -296,7 +295,8 @@ }, 13); | ||
asyncTest("asyncTest", 2, function() { | ||
ok(true); | ||
asyncTest("asyncTest with expect()", function( assert ) { | ||
expect(2); | ||
assert.ok(true); | ||
setTimeout(function() { | ||
state = "done"; | ||
ok(true); | ||
assert.ok(true); | ||
start(); | ||
@@ -306,6 +306,6 @@ }, 13); | ||
test("sync", 2, function() { | ||
test("sync", 2, function( assert ) { | ||
stop(); | ||
setTimeout(function() { | ||
ok(true); | ||
assert.ok(true); | ||
start(); | ||
@@ -315,3 +315,3 @@ }, 13); | ||
setTimeout(function() { | ||
ok(true); | ||
assert.ok(true); | ||
start(); | ||
@@ -321,10 +321,10 @@ }, 125); | ||
test("test synchronous calls to stop", 2, function() { | ||
test("test synchronous calls to stop", 2, function( assert ) { | ||
stop(); | ||
setTimeout(function() { | ||
ok(true, 'first'); | ||
assert.ok(true, 'first'); | ||
start(); | ||
stop(); | ||
setTimeout(function() { | ||
ok(true, 'second'); | ||
assert.ok(true, 'second'); | ||
start(); | ||
@@ -340,9 +340,9 @@ }, 150); | ||
}, | ||
teardown: function() { | ||
deepEqual(this.foo, "bar"); | ||
teardown: function( assert ) { | ||
assert.deepEqual(this.foo, "bar"); | ||
} | ||
}); | ||
test("scope check", function() { | ||
test("scope check", function( assert ) { | ||
expect(2); | ||
deepEqual(this.foo, "bar"); | ||
assert.deepEqual(this.foo, "bar"); | ||
}); | ||
@@ -355,29 +355,36 @@ | ||
}); | ||
test("scope check", function() { | ||
deepEqual(this.foo, "bar"); | ||
test("scope check", function( assert ) { | ||
assert.deepEqual(this.foo, "bar"); | ||
}); | ||
test("modify testEnvironment",function() { | ||
test("modify testEnvironment", function() { | ||
expect(0); | ||
this.foo="hamster"; | ||
this.foo = "hamster"; | ||
}); | ||
test("testEnvironment reset for next test",function() { | ||
deepEqual(this.foo, "bar"); | ||
test("testEnvironment reset for next test", function( assert ) { | ||
assert.deepEqual(this.foo, "bar"); | ||
}); | ||
module("testEnvironment with object", { | ||
options:{ | ||
recipe:"soup", | ||
ingredients:["hamster","onions"] | ||
options: { | ||
recipe: "soup", | ||
ingredients: ["hamster", "onions"] | ||
} | ||
}); | ||
test("scope check", function() { | ||
deepEqual(this.options, {recipe:"soup",ingredients:["hamster","onions"]}) ; | ||
test("scope check", function( assert ) { | ||
assert.deepEqual(this.options, { | ||
recipe: "soup", | ||
ingredients: ["hamster", "onions"] | ||
}); | ||
}); | ||
test("modify testEnvironment",function() { | ||
expect(0); | ||
// since we do a shallow copy, the testEnvironment can be modified | ||
// since we only do a shallow copy, nested children of testEnvironment can be modified | ||
// and survice | ||
this.options.ingredients.push("carrots"); | ||
}); | ||
test("testEnvironment reset for next test",function() { | ||
deepEqual(this.options, {recipe:"soup",ingredients:["hamster","onions","carrots"]}, "Is this a bug or a feature? Could do a deep copy") ; | ||
test("testEnvironment reset for next test",function( assert ) { | ||
assert.deepEqual(this.options, { | ||
recipe: "soup", | ||
ingredients: ["hamster", "onions", "carrots"] | ||
}, "Is this a bug or a feature? Could do a deep copy") ; | ||
}); | ||
@@ -389,3 +396,3 @@ | ||
function makeurl() { | ||
var testEnv = QUnit.current_testEnvironment; | ||
var testEnv = QUnit.config.current.testEnvironment; | ||
var url = testEnv.url || 'http://example.com/search'; | ||
@@ -396,5 +403,8 @@ var q = testEnv.q || 'a search test'; | ||
test("makeurl working",function() { | ||
equal( QUnit.current_testEnvironment, this, 'The current testEnvironment is global'); | ||
equal( makeurl(), 'http://example.com/search?q=a%20search%20test', 'makeurl returns a default url if nothing specified in the testEnvironment'); | ||
test("makeurl working", 3, function( assert ) { | ||
assert.equal( QUnit.config.current.testEnvironment, this, 'The current testEnvironment QUnit.config'); | ||
/*jshint camelcase:false */ | ||
assert.equal( QUnit.current_testEnvironment, this, 'The current testEnvironment is in QUnit.config (old way)'); | ||
/*jshint camelcase:true */ | ||
assert.equal( makeurl(), 'http://example.com/search?q=a%20search%20test', 'makeurl returns a default url if nothing specified in the testEnvironment'); | ||
}); | ||
@@ -406,13 +416,13 @@ | ||
}); | ||
test("makeurl working with settings from testEnvironment", function() { | ||
equal( makeurl(), 'http://google.com/?q=another_search_test', 'rather than passing arguments, we use test metadata to from the url'); | ||
test("makeurl working with settings from testEnvironment", function( assert ) { | ||
assert.equal( makeurl(), 'http://google.com/?q=another_search_test', 'rather than passing arguments, we use test metadata to from the url'); | ||
}); | ||
module("jsDump"); | ||
test("jsDump output", function() { | ||
equal( QUnit.jsDump.parse([1, 2]), "[\n 1,\n 2\n]" ); | ||
equal( QUnit.jsDump.parse({top: 5, left: 0}), "{\n \"left\": 0,\n \"top\": 5\n}" ); | ||
test("jsDump output", function( assert ) { | ||
assert.equal( QUnit.jsDump.parse([1, 2]), "[\n 1,\n 2\n]" ); | ||
assert.equal( QUnit.jsDump.parse({top: 5, left: 0}), "{\n \"left\": 0,\n \"top\": 5\n}" ); | ||
if (typeof document !== 'undefined' && document.getElementById("qunit-header")) { | ||
equal( QUnit.jsDump.parse(document.getElementById("qunit-header")), "<h1 id=\"qunit-header\"></h1>" ); | ||
equal( QUnit.jsDump.parse(document.getElementsByTagName("h1")), "[\n <h1 id=\"qunit-header\"></h1>\n]" ); | ||
assert.equal( QUnit.jsDump.parse(document.getElementById("qunit-header")), "<h1 id=\"qunit-header\"></h1>" ); | ||
assert.equal( QUnit.jsDump.parse(document.getElementsByTagName("h1")), "[\n <h1 id=\"qunit-header\"></h1>\n]" ); | ||
} | ||
@@ -499,3 +509,4 @@ }); | ||
test("raises", 9, function() { | ||
test("raises", 9, function( assert ) { | ||
/*jshint es5:true */ | ||
function CustomError( message ) { | ||
@@ -509,3 +520,3 @@ this.message = message; | ||
throws( | ||
assert.throws( | ||
function() { | ||
@@ -516,3 +527,3 @@ throw "my error"; | ||
throws( | ||
assert.throws( | ||
function() { | ||
@@ -526,3 +537,3 @@ throw "my error"; | ||
// implement Error.prototype.toString | ||
throws( | ||
assert.throws( | ||
function() { | ||
@@ -535,3 +546,3 @@ throw new Error("error message"); | ||
throws( | ||
assert.throws( | ||
function() { | ||
@@ -544,3 +555,3 @@ throw new CustomError(); | ||
throws( | ||
assert.throws( | ||
function() { | ||
@@ -553,3 +564,3 @@ throw new CustomError("some error description"); | ||
throws( | ||
assert.throws( | ||
function() { | ||
@@ -566,3 +577,3 @@ throw new CustomError("some error description"); | ||
throws( | ||
assert.throws( | ||
function() { | ||
@@ -579,3 +590,3 @@ /*jshint evil:true */ | ||
throws( | ||
assert.throws( | ||
function() { | ||
@@ -605,7 +616,7 @@ throw new this.CustomError("some error description"); | ||
test("basics", function() { | ||
equal( document.getElementById("qunit-fixture").innerHTML, "test markup", "automatically reset" ); | ||
test("basics", function( assert ) { | ||
assert.equal( document.getElementById("qunit-fixture").innerHTML, "test markup", "automatically reset" ); | ||
}); | ||
test("running test name displayed", function() { | ||
test("running test name displayed", function( assert ) { | ||
expect(2); | ||
@@ -615,4 +626,4 @@ | ||
ok( /running test name displayed/.test(displaying.innerHTML), "Expect test name to be found in displayed text" ); | ||
ok( /fixture/.test(displaying.innerHTML), "Expect module name to be found in displayed text" ); | ||
assert.ok( /running test name displayed/.test(displaying.innerHTML), "Expect test name to be found in displayed text" ); | ||
assert.ok( /fixture/.test(displaying.innerHTML), "Expect module name to be found in displayed text" ); | ||
}); | ||
@@ -640,14 +651,14 @@ | ||
test("basics", 2, function() { | ||
test("basics", 2, function( assert ) { | ||
var previous = getPreviousTests(/^setup$/, /^timing$/)[0], | ||
runtime = previous.lastChild.previousSibling; | ||
ok( /(^| )runtime( |$)/.test( runtime.className ), "Runtime element exists" ); | ||
ok( /^\d+ ms$/.test( runtime.innerHTML ), "Runtime reported in ms" ); | ||
assert.ok( /(^| )runtime( |$)/.test( runtime.className ), "Runtime element exists" ); | ||
assert.ok( /^\d+ ms$/.test( runtime.innerHTML ), "Runtime reported in ms" ); | ||
}); | ||
test("values", 2, function() { | ||
test("values", 2, function( assert ) { | ||
var basics = getPreviousTests(/^setup$/, /^timing$/)[0], | ||
slow = getPreviousTests(/^basics$/, /^timing$/)[0]; | ||
ok( parseInt( basics.lastChild.previousSibling.innerHTML, 10 ) < 50, "Fast runtime for trivial test" ); | ||
ok( parseInt( slow.lastChild.previousSibling.innerHTML, 10 ) > 250, "Runtime includes setup" ); | ||
assert.ok( parseInt( basics.lastChild.previousSibling.innerHTML, 10 ) < 50, "Fast runtime for trivial test" ); | ||
assert.ok( parseInt( slow.lastChild.previousSibling.innerHTML, 10 ) > 250, "Runtime includes setup" ); | ||
}); | ||
@@ -660,9 +671,9 @@ })(); | ||
(function() { | ||
function mod2(value, expected, message) { | ||
QUnit.assert.mod2 = function( value, expected, message ) { | ||
var actual = value % 2; | ||
QUnit.push(actual == expected, actual, expected, message); | ||
} | ||
test("mod2", function() { | ||
mod2(2, 0, "2 % 2 == 0"); | ||
mod2(3, 1, "3 % 2 == 1"); | ||
QUnit.push(actual === expected, actual, expected, message); | ||
}; | ||
test("mod2", 2, function( assert ) { | ||
assert.mod2(2, 0, "2 % 2 == 0"); | ||
assert.mod2(3, 1, "3 % 2 == 1"); | ||
}); | ||
@@ -686,3 +697,3 @@ })(); | ||
if (depth == 1) { | ||
if (depth === 1) { | ||
first.wrap = last; | ||
@@ -697,3 +708,3 @@ } | ||
test("check jsDump recursion", function() { | ||
test("Check jsDump recursion", function( assert ) { | ||
expect(4); | ||
@@ -703,33 +714,33 @@ | ||
var nodump = QUnit.jsDump.parse(noref); | ||
equal(nodump, '{\n "first": true,\n "wrap": undefined\n}'); | ||
assert.equal(nodump, '{\n "first": true,\n "wrap": undefined\n}'); | ||
var selfref = chainwrap(1); | ||
var selfdump = QUnit.jsDump.parse(selfref); | ||
equal(selfdump, '{\n "first": true,\n "wrap": recursion(-1)\n}'); | ||
assert.equal(selfdump, '{\n "first": true,\n "wrap": recursion(-1)\n}'); | ||
var parentref = chainwrap(2); | ||
var parentdump = QUnit.jsDump.parse(parentref); | ||
equal(parentdump, '{\n "wrap": {\n "first": true,\n "wrap": recursion(-2)\n }\n}'); | ||
assert.equal(parentdump, '{\n "wrap": {\n "first": true,\n "wrap": recursion(-2)\n }\n}'); | ||
var circref = chainwrap(10); | ||
var circdump = QUnit.jsDump.parse(circref); | ||
ok(new RegExp("recursion\\(-10\\)").test(circdump), "(" +circdump + ") should show -10 recursion level"); | ||
assert.ok(new RegExp("recursion\\(-10\\)").test(circdump), "(" +circdump + ") should show -10 recursion level"); | ||
}); | ||
test("check (deep-)equal recursion", function() { | ||
test("Check equal/deepEqual recursion", function( assert ) { | ||
var noRecursion = chainwrap(0); | ||
equal(noRecursion, noRecursion, "I should be equal to me."); | ||
deepEqual(noRecursion, noRecursion, "... and so in depth."); | ||
assert.equal(noRecursion, noRecursion, "I should be equal to me."); | ||
assert.deepEqual(noRecursion, noRecursion, "... and so in depth."); | ||
var selfref = chainwrap(1); | ||
equal(selfref, selfref, "Even so if I nest myself."); | ||
deepEqual(selfref, selfref, "... into the depth."); | ||
assert.equal(selfref, selfref, "Even so if I nest myself."); | ||
assert.deepEqual(selfref, selfref, "... into the depth."); | ||
var circref = chainwrap(10); | ||
equal(circref, circref, "Or hide that through some levels of indirection."); | ||
deepEqual(circref, circref, "... and checked on all levels!"); | ||
assert.equal(circref, circref, "Or hide that through some levels of indirection."); | ||
assert.deepEqual(circref, circref, "... and checked on all levels!"); | ||
}); | ||
test('Circular reference with arrays', function() { | ||
test("Circular reference with arrays", function( assert ) { | ||
@@ -742,4 +753,4 @@ // pure array self-ref | ||
equal(arrdump, '[\n recursion(-1)\n]'); | ||
equal(arr, arr[0], 'no endless stack when trying to dump arrays with circular ref'); | ||
assert.equal(arrdump, '[\n recursion(-1)\n]'); | ||
assert.equal(arr, arr[0], 'no endless stack when trying to dump arrays with circular ref'); | ||
@@ -755,7 +766,7 @@ | ||
equal(objdump, '{\n "childarr": [\n recursion(-2)\n ]\n}'); | ||
equal(childarrdump, '[\n {\n "childarr": recursion(-2)\n }\n]'); | ||
assert.equal(objdump, '{\n "childarr": [\n recursion(-2)\n ]\n}'); | ||
assert.equal(childarrdump, '[\n {\n "childarr": recursion(-2)\n }\n]'); | ||
equal(obj.childarr, childarr, 'no endless stack when trying to dump array/object mix with circular ref'); | ||
equal(childarr[0], obj, 'no endless stack when trying to dump array/object mix with circular ref'); | ||
assert.equal(obj.childarr, childarr, 'no endless stack when trying to dump array/object mix with circular ref'); | ||
assert.equal(childarr[0], obj, 'no endless stack when trying to dump array/object mix with circular ref'); | ||
@@ -765,3 +776,3 @@ }); | ||
test('Circular reference - test reported by soniciq in #105', function() { | ||
test("Circular reference - test reported by soniciq in #105", function( assert ) { | ||
var MyObject = function() {}; | ||
@@ -784,4 +795,4 @@ MyObject.prototype.parent = function(obj) { | ||
equal(a.children(), barr); | ||
deepEqual(a.children(), [b]); | ||
assert.equal(a.children(), barr); | ||
assert.deepEqual(a.children(), [b]); | ||
}); | ||
@@ -792,6 +803,6 @@ | ||
module("reset"); | ||
test("reset runs assertions", function() { | ||
test("reset runs assertions", function( assert ) { | ||
expect(0); | ||
QUnit.reset = function() { | ||
ok( false, "reset should not modify test status" ); | ||
assert.ok( false, "reset should not modify test status" ); | ||
reset.apply( this, arguments ); | ||
@@ -814,7 +825,7 @@ }; | ||
module("check previous test's assertion counts"); | ||
test('count previous two test\'s assertions', function () { | ||
test('count previous two test\'s assertions', function ( assert ) { | ||
var tests = getPreviousTests(/^ensure has correct number of assertions/, /^Synchronous test after load of page$/); | ||
equal(tests[0].firstChild.lastChild.getElementsByTagName("b")[1].innerHTML, "99"); | ||
equal(tests[1].firstChild.lastChild.getElementsByTagName("b")[1].innerHTML, "99"); | ||
assert.equal(tests[0].firstChild.lastChild.getElementsByTagName("b")[1].innerHTML, "99"); | ||
assert.equal(tests[1].firstChild.lastChild.getElementsByTagName("b")[1].innerHTML, "99"); | ||
}); | ||
@@ -827,12 +838,12 @@ } | ||
asyncTest('Async test', function() { | ||
asyncTest('Async test', function( assert ) { | ||
start(); | ||
for (var i = 1; i < 100; i++) { | ||
ok(i); | ||
assert.ok(i); | ||
} | ||
}); | ||
test(testName, 99, function() { | ||
test(testName, 99, function( assert ) { | ||
for (var i = 1; i < 100; i++) { | ||
ok(i); | ||
assert.ok(i); | ||
} | ||
@@ -843,5 +854,5 @@ }); | ||
// don't move between tests. | ||
test(testName + ' 2', 99, function() { | ||
test(testName + ' 2', 99, function( assert ) { | ||
for (var i = 1; i < 100; i++) { | ||
ok(i); | ||
assert.ok(i); | ||
} | ||
@@ -848,0 +859,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
0
201752
6
30
4591
63