aboutsummaryrefslogtreecommitdiffstats
path: root/addon/js_upload/file-uploader/tests/qunit
diff options
context:
space:
mode:
authorfabrixxm <fabrix.xm@gmail.com>2011-01-27 07:14:55 +0100
committerfabrixxm <fabrix.xm@gmail.com>2011-01-27 07:14:55 +0100
commit444d82a5328433fbe48e18b928d35218905a756c (patch)
tree84bd92072bf37eee3b54ebf7cb9ccaf408562e67 /addon/js_upload/file-uploader/tests/qunit
parent6558ee1e2210fb41b1f4d95f806ee441a565087d (diff)
parentd2dddd995abef2d0805901b278647bef0ce50f88 (diff)
downloadvolse-hubzilla-444d82a5328433fbe48e18b928d35218905a756c.tar.gz
volse-hubzilla-444d82a5328433fbe48e18b928d35218905a756c.tar.bz2
volse-hubzilla-444d82a5328433fbe48e18b928d35218905a756c.zip
Merge branch 'friendika-master'
Diffstat (limited to 'addon/js_upload/file-uploader/tests/qunit')
-rw-r--r--addon/js_upload/file-uploader/tests/qunit/package.json21
-rw-r--r--addon/js_upload/file-uploader/tests/qunit/qunit/qunit.css119
-rw-r--r--addon/js_upload/file-uploader/tests/qunit/qunit/qunit.js1069
-rw-r--r--addon/js_upload/file-uploader/tests/qunit/test/index.html17
-rw-r--r--addon/js_upload/file-uploader/tests/qunit/test/same.js1423
-rw-r--r--addon/js_upload/file-uploader/tests/qunit/test/test.js171
6 files changed, 2820 insertions, 0 deletions
diff --git a/addon/js_upload/file-uploader/tests/qunit/package.json b/addon/js_upload/file-uploader/tests/qunit/package.json
new file mode 100644
index 000000000..b6044c887
--- /dev/null
+++ b/addon/js_upload/file-uploader/tests/qunit/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "qunit",
+ "author": {
+ "name": "John Resig",
+ "email": "jeresig@gmail.com",
+ "url": "http://ejohn.org/"
+ },
+ "maintainer": {
+ "name": "Jörn Zaefferer",
+ "email": "joern.zaefferer@googlemail.com",
+ "url": "http://bassistance.de/"
+ },
+ "url": "http://docs.jquery.com/QUnit",
+ "license": {
+ "name": "MIT",
+ "url": "http://www.opensource.org/licenses/mit-license.php"
+ },
+ "description": "An easy-to-use JavaScript Unit Testing framework.",
+ "keywords": [ "testing", "unit", "jquery" ],
+ "lib": "qunit"
+}
diff --git a/addon/js_upload/file-uploader/tests/qunit/qunit/qunit.css b/addon/js_upload/file-uploader/tests/qunit/qunit/qunit.css
new file mode 100644
index 000000000..5714bf4a5
--- /dev/null
+++ b/addon/js_upload/file-uploader/tests/qunit/qunit/qunit.css
@@ -0,0 +1,119 @@
+
+ol#qunit-tests {
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
+ margin:0;
+ padding:0;
+ list-style-position:inside;
+
+ font-size: smaller;
+}
+ol#qunit-tests li{
+ padding:0.4em 0.5em 0.4em 2.5em;
+ border-bottom:1px solid #fff;
+ font-size:small;
+ list-style-position:inside;
+}
+ol#qunit-tests li ol{
+ box-shadow: inset 0px 2px 13px #999;
+ -moz-box-shadow: inset 0px 2px 13px #999;
+ -webkit-box-shadow: inset 0px 2px 13px #999;
+ margin-top:0.5em;
+ margin-left:0;
+ padding:0.5em;
+ background-color:#fff;
+ border-radius:15px;
+ -moz-border-radius: 15px;
+ -webkit-border-radius: 15px;
+}
+ol#qunit-tests li li{
+ border-bottom:none;
+ margin:0.5em;
+ background-color:#fff;
+ list-style-position: inside;
+ padding:0.4em 0.5em 0.4em 0.5em;
+}
+
+ol#qunit-tests li li.pass{
+ border-left:26px solid #C6E746;
+ background-color:#fff;
+ color:#5E740B;
+ }
+ol#qunit-tests li li.fail{
+ border-left:26px solid #EE5757;
+ background-color:#fff;
+ color:#710909;
+}
+ol#qunit-tests li.pass{
+ background-color:#D2E0E6;
+ color:#528CE0;
+}
+ol#qunit-tests li.fail{
+ background-color:#EE5757;
+ color:#000;
+}
+ol#qunit-tests li strong {
+ cursor:pointer;
+}
+h1#qunit-header{
+ background-color:#0d3349;
+ margin:0;
+ padding:0.5em 0 0.5em 1em;
+ color:#fff;
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
+ border-top-right-radius:15px;
+ border-top-left-radius:15px;
+ -moz-border-radius-topright:15px;
+ -moz-border-radius-topleft:15px;
+ -webkit-border-top-right-radius:15px;
+ -webkit-border-top-left-radius:15px;
+ text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px;
+}
+h2#qunit-banner{
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
+ height:5px;
+ margin:0;
+ padding:0;
+}
+h2#qunit-banner.qunit-pass{
+ background-color:#C6E746;
+}
+h2#qunit-banner.qunit-fail, #qunit-testrunner-toolbar {
+ background-color:#EE5757;
+}
+#qunit-testrunner-toolbar {
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
+ padding:0;
+ /*width:80%;*/
+ padding:0em 0 0.5em 2em;
+ font-size: small;
+}
+h2#qunit-userAgent {
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
+ background-color:#2b81af;
+ margin:0;
+ padding:0;
+ color:#fff;
+ font-size: small;
+ padding:0.5em 0 0.5em 2.5em;
+ text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
+}
+p#qunit-testresult{
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
+ margin:0;
+ font-size: small;
+ color:#2b81af;
+ border-bottom-right-radius:15px;
+ border-bottom-left-radius:15px;
+ -moz-border-radius-bottomright:15px;
+ -moz-border-radius-bottomleft:15px;
+ -webkit-border-bottom-right-radius:15px;
+ -webkit-border-bottom-left-radius:15px;
+ background-color:#D2E0E6;
+ padding:0.5em 0.5em 0.5em 2.5em;
+}
+strong b.fail{
+ color:#710909;
+ }
+strong b.pass{
+ color:#5E740B;
+ }
diff --git a/addon/js_upload/file-uploader/tests/qunit/qunit/qunit.js b/addon/js_upload/file-uploader/tests/qunit/qunit/qunit.js
new file mode 100644
index 000000000..9ef5f8d6f
--- /dev/null
+++ b/addon/js_upload/file-uploader/tests/qunit/qunit/qunit.js
@@ -0,0 +1,1069 @@
+/*
+ * QUnit - A JavaScript Unit Testing Framework
+ *
+ * http://docs.jquery.com/QUnit
+ *
+ * Copyright (c) 2009 John Resig, Jörn Zaefferer
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ */
+
+(function(window) {
+
+var QUnit = {
+
+ // Initialize the configuration options
+ init: function() {
+ config = {
+ stats: { all: 0, bad: 0 },
+ moduleStats: { all: 0, bad: 0 },
+ started: +new Date,
+ updateRate: 1000,
+ blocking: false,
+ autorun: false,
+ assertions: [],
+ filters: [],
+ queue: []
+ };
+
+ var tests = id("qunit-tests"),
+ banner = id("qunit-banner"),
+ result = id("qunit-testresult");
+
+ if ( tests ) {
+ tests.innerHTML = "";
+ }
+
+ if ( banner ) {
+ banner.className = "";
+ }
+
+ if ( result ) {
+ result.parentNode.removeChild( result );
+ }
+ },
+
+ // call on start of module test to prepend name to all tests
+ module: function(name, testEnvironment) {
+ config.currentModule = name;
+
+ synchronize(function() {
+ if ( config.currentModule ) {
+ QUnit.moduleDone( config.currentModule, config.moduleStats.bad, config.moduleStats.all );
+ }
+
+ config.currentModule = name;
+ config.moduleTestEnvironment = testEnvironment;
+ config.moduleStats = { all: 0, bad: 0 };
+
+ QUnit.moduleStart( name, testEnvironment );
+ });
+ },
+
+ asyncTest: function(testName, expected, callback) {
+ if ( arguments.length === 2 ) {
+ callback = expected;
+ expected = 0;
+ }
+
+ QUnit.test(testName, expected, callback, true);
+ },
+
+ test: function(testName, expected, callback, async) {
+ var name = testName, testEnvironment, testEnvironmentArg;
+
+ if ( arguments.length === 2 ) {
+ callback = expected;
+ expected = null;
+ }
+ // is 2nd argument a testEnvironment?
+ if ( expected && typeof expected === 'object') {
+ testEnvironmentArg = expected;
+ expected = null;
+ }
+
+ if ( config.currentModule ) {
+ name = config.currentModule + " module: " + name;
+ }
+
+ if ( !validTest(name) ) {
+ return;
+ }
+
+ synchronize(function() {
+ QUnit.testStart( testName );
+
+ testEnvironment = extend({
+ setup: function() {},
+ teardown: function() {}
+ }, config.moduleTestEnvironment);
+ if (testEnvironmentArg) {
+ extend(testEnvironment,testEnvironmentArg);
+ }
+
+ // allow utility functions to access the current test environment
+ QUnit.current_testEnvironment = testEnvironment;
+
+ config.assertions = [];
+ config.expected = expected;
+
+ try {
+ if ( !config.pollution ) {
+ saveGlobal();
+ }
+
+ testEnvironment.setup.call(testEnvironment);
+ } catch(e) {
+ QUnit.ok( false, "Setup failed on " + name + ": " + e.message );
+ }
+
+ if ( async ) {
+ QUnit.stop();
+ }
+
+ try {
+ callback.call(testEnvironment);
+ } catch(e) {
+ fail("Test " + name + " died, exception and test follows", e, callback);
+ QUnit.ok( false, "Died on test #" + (config.assertions.length + 1) + ": " + e.message );
+ // else next test will carry the responsibility
+ saveGlobal();
+
+ // Restart the tests if they're blocking
+ if ( config.blocking ) {
+ start();
+ }
+ }
+ });
+
+ synchronize(function() {
+ try {
+ checkPollution();
+ testEnvironment.teardown.call(testEnvironment);
+ } catch(e) {
+ QUnit.ok( false, "Teardown failed on " + name + ": " + e.message );
+ }
+
+ try {
+ QUnit.reset();
+ } catch(e) {
+ fail("reset() failed, following Test " + name + ", exception and reset fn follows", e, reset);
+ }
+
+ if ( config.expected && config.expected != config.assertions.length ) {
+ QUnit.ok( false, "Expected " + config.expected + " assertions, but " + config.assertions.length + " were run" );
+ }
+
+ var good = 0, bad = 0,
+ tests = id("qunit-tests");
+
+ config.stats.all += config.assertions.length;
+ config.moduleStats.all += config.assertions.length;
+
+ if ( tests ) {
+ var ol = document.createElement("ol");
+ ol.style.display = "none";
+
+ for ( var i = 0; i < config.assertions.length; i++ ) {
+ var assertion = config.assertions[i];
+
+ var li = document.createElement("li");
+ li.className = assertion.result ? "pass" : "fail";
+ li.appendChild(document.createTextNode(assertion.message || "(no message)"));
+ ol.appendChild( li );
+
+ if ( assertion.result ) {
+ good++;
+ } else {
+ bad++;
+ config.stats.bad++;
+ config.moduleStats.bad++;
+ }
+ }
+
+ var b = document.createElement("strong");
+ b.innerHTML = name + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + config.assertions.length + ")</b>";
+
+ addEvent(b, "click", function() {
+ var next = b.nextSibling, display = next.style.display;
+ next.style.display = display === "none" ? "block" : "none";
+ });
+
+ addEvent(b, "dblclick", function(e) {
+ var target = e && e.target ? e.target : window.event.srcElement;
+ if ( target.nodeName.toLowerCase() === "strong" ) {
+ var text = "", node = target.firstChild;
+
+ while ( node.nodeType === 3 ) {
+ text += node.nodeValue;
+ node = node.nextSibling;
+ }
+
+ text = text.replace(/(^\s*|\s*$)/g, "");
+
+ if ( window.location ) {
+ window.location.href = window.location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent(text);
+ }
+ }
+ });
+
+ var li = document.createElement("li");
+ li.className = bad ? "fail" : "pass";
+ li.appendChild( b );
+ li.appendChild( ol );
+ tests.appendChild( li );
+
+ if ( bad ) {
+ var toolbar = id("qunit-testrunner-toolbar");
+ if ( toolbar ) {
+ toolbar.style.display = "block";
+ id("qunit-filter-pass").disabled = null;
+ id("qunit-filter-missing").disabled = null;
+ }
+ }
+
+ } else {
+ for ( var i = 0; i < config.assertions.length; i++ ) {
+ if ( !config.assertions[i].result ) {
+ bad++;
+ config.stats.bad++;
+ config.moduleStats.bad++;
+ }
+ }
+ }
+
+ QUnit.testDone( testName, bad, config.assertions.length );
+
+ if ( !window.setTimeout && !config.queue.length ) {
+ done();
+ }
+ });
+
+ if ( window.setTimeout && !config.doneTimer ) {
+ config.doneTimer = window.setTimeout(function(){
+ if ( !config.queue.length ) {
+ done();
+ } else {
+ synchronize( done );
+ }
+ }, 13);
+ }
+ },
+
+ /**
+ * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
+ */
+ expect: function(asserts) {
+ config.expected = asserts;
+ },
+
+ /**
+ * Asserts true.
+ * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
+ */
+ ok: function(a, msg) {
+ QUnit.log(a, msg);
+
+ config.assertions.push({
+ result: !!a,
+ message: msg
+ });
+ },
+
+ /**
+ * Checks that the first two arguments are equal, with an optional message.
+ * Prints out both actual and expected values.
+ *
+ * Prefered to ok( actual == expected, message )
+ *
+ * @example equal( format("Received {0} bytes.", 2), "Received 2 bytes." );
+ *
+ * @param Object actual
+ * @param Object expected
+ * @param String message (optional)
+ */
+ equal: function(actual, expected, message) {
+ push(expected == actual, actual, expected, message);
+ },
+
+ notEqual: function(actual, expected, message) {
+ push(expected != actual, actual, expected, message);
+ },
+
+ deepEqual: function(a, b, message) {
+ push(QUnit.equiv(a, b), a, b, message);
+ },
+
+ notDeepEqual: function(a, b, message) {
+ push(!QUnit.equiv(a, b), a, b, message);
+ },
+
+ strictEqual: function(actual, expected, message) {
+ push(expected === actual, actual, expected, message);
+ },
+
+ notStrictEqual: function(actual, expected, message) {
+ push(expected !== actual, actual, expected, message);
+ },
+
+ start: function() {
+ // A slight delay, to avoid any current callbacks
+ if ( window.setTimeout ) {
+ window.setTimeout(function() {
+ if ( config.timeout ) {
+ clearTimeout(config.timeout);
+ }
+
+ config.blocking = false;
+ process();
+ }, 13);
+ } else {
+ config.blocking = false;
+ process();
+ }
+ },
+
+ stop: function(timeout) {
+ config.blocking = true;
+
+ if ( timeout && window.setTimeout ) {
+ config.timeout = window.setTimeout(function() {
+ QUnit.ok( false, "Test timed out" );
+ QUnit.start();
+ }, timeout);
+ }
+ },
+
+ /**
+ * Resets the test setup. Useful for tests that modify the DOM.
+ */
+ reset: function() {
+ if ( window.jQuery ) {
+ jQuery("#main").html( config.fixture );
+ jQuery.event.global = {};
+ jQuery.ajaxSettings = extend({}, config.ajaxSettings);
+ }
+ },
+
+ /**
+ * Trigger an event on an element.
+ *
+ * @example triggerEvent( document.body, "click" );
+ *
+ * @param DOMElement elem
+ * @param String type
+ */
+ triggerEvent: function( elem, type, event ) {
+ if ( document.createEvent ) {
+ event = document.createEvent("MouseEvents");
+ event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
+ 0, 0, 0, 0, 0, false, false, false, false, 0, null);
+ elem.dispatchEvent( event );
+
+ } else if ( elem.fireEvent ) {
+ elem.fireEvent("on"+type);
+ }
+ },
+
+ // Safe object type checking
+ is: function( type, obj ) {
+ return Object.prototype.toString.call( obj ) === "[object "+ type +"]";
+ },
+
+ // Logging callbacks
+ done: function(failures, total) {},
+ log: function(result, message) {},
+ testStart: function(name) {},
+ testDone: function(name, failures, total) {},
+ moduleStart: function(name, testEnvironment) {},
+ moduleDone: function(name, failures, total) {}
+};
+
+// Backwards compatibility, deprecated
+QUnit.equals = QUnit.equal;
+QUnit.same = QUnit.deepEqual;
+
+// Maintain internal state
+var config = {
+ // The queue of tests to run
+ queue: [],
+
+ // block until document ready
+ blocking: true
+};
+
+// Load paramaters
+(function() {
+ var location = window.location || { search: "", protocol: "file:" },
+ GETParams = location.search.slice(1).split('&');
+
+ for ( var i = 0; i < GETParams.length; i++ ) {
+ GETParams[i] = decodeURIComponent( GETParams[i] );
+ if ( GETParams[i] === "noglobals" ) {
+ GETParams.splice( i, 1 );
+ i--;
+ config.noglobals = true;
+ } else if ( GETParams[i].search('=') > -1 ) {
+ GETParams.splice( i, 1 );
+ i--;
+ }
+ }
+
+ // restrict modules/tests by get parameters
+ config.filters = GETParams;
+
+ // Figure out if we're running the tests from a server or not
+ QUnit.isLocal = !!(location.protocol === 'file:');
+})();
+
+// Expose the API as global variables, unless an 'exports'
+// object exists, in that case we assume we're in CommonJS
+if ( typeof exports === "undefined" || typeof require === "undefined" ) {
+ extend(window, QUnit);
+ window.QUnit = QUnit;
+} else {
+ extend(exports, QUnit);
+ exports.QUnit = QUnit;
+}
+
+if ( typeof document === "undefined" || document.readyState === "complete" ) {
+ config.autorun = true;
+}
+
+addEvent(window, "load", function() {
+ // Initialize the config, saving the execution queue
+ var oldconfig = extend({}, config);
+ QUnit.init();
+ extend(config, oldconfig);
+
+ config.blocking = false;
+
+ var userAgent = id("qunit-userAgent");
+ if ( userAgent ) {
+ userAgent.innerHTML = navigator.userAgent;
+ }
+
+ var toolbar = id("qunit-testrunner-toolbar");
+ if ( toolbar ) {
+ toolbar.style.display = "none";
+
+ var filter = document.createElement("input");
+ filter.type = "checkbox";
+ filter.id = "qunit-filter-pass";
+ filter.disabled = true;
+ addEvent( filter, "click", function() {
+ var li = document.getElementsByTagName("li");
+ for ( var i = 0; i < li.length; i++ ) {
+ if ( li[i].className.indexOf("pass") > -1 ) {
+ li[i].style.display = filter.checked ? "none" : "";
+ }
+ }
+ });
+ toolbar.appendChild( filter );
+
+ var label = document.createElement("label");
+ label.setAttribute("for", "qunit-filter-pass");
+ label.innerHTML = "Hide passed tests";
+ toolbar.appendChild( label );
+
+ var missing = document.createElement("input");
+ missing.type = "checkbox";
+ missing.id = "qunit-filter-missing";
+ missing.disabled = true;
+ addEvent( missing, "click", function() {
+ var li = document.getElementsByTagName("li");
+ for ( var i = 0; i < li.length; i++ ) {
+ if ( li[i].className.indexOf("fail") > -1 && li[i].innerHTML.indexOf('missing test - untested code is broken code') > - 1 ) {
+ li[i].parentNode.parentNode.style.display = missing.checked ? "none" : "block";
+ }
+ }
+ });
+ toolbar.appendChild( missing );
+
+ label = document.createElement("label");
+ label.setAttribute("for", "qunit-filter-missing");
+ label.innerHTML = "Hide missing tests (untested code is broken code)";
+ toolbar.appendChild( label );
+ }
+
+ var main = id('main');
+ if ( main ) {
+ config.fixture = main.innerHTML;
+ }
+
+ if ( window.jQuery ) {
+ config.ajaxSettings = window.jQuery.ajaxSettings;
+ }
+
+ QUnit.start();
+});
+
+function done() {
+ if ( config.doneTimer && window.clearTimeout ) {
+ window.clearTimeout( config.doneTimer );
+ config.doneTimer = null;
+ }
+
+ if ( config.queue.length ) {
+ config.doneTimer = window.setTimeout(function(){
+ if ( !config.queue.length ) {
+ done();
+ } else {
+ synchronize( done );
+ }
+ }, 13);
+
+ return;
+ }
+
+ config.autorun = true;
+
+ // Log the last module results
+ if ( config.currentModule ) {
+ QUnit.moduleDone( config.currentModule, config.moduleStats.bad, config.moduleStats.all );
+ }
+
+ var banner = id("qunit-banner"),
+ tests = id("qunit-tests"),
+ html = ['Tests completed in ',
+ +new Date - config.started, ' milliseconds.<br/>',
+ '<span class="passed">', config.stats.all - config.stats.bad, '</span> tests of <span class="total">', config.stats.all, '</span> passed, <span class="failed">', config.stats.bad,'</span> failed.'].join('');
+
+ if ( banner ) {
+ banner.className = (config.stats.bad ? "qunit-fail" : "qunit-pass");
+ }
+
+ if ( tests ) {
+ var result = id("qunit-testresult");
+
+ if ( !result ) {
+ result = document.createElement("p");
+ result.id = "qunit-testresult";
+ result.className = "result";
+ tests.parentNode.insertBefore( result, tests.nextSibling );
+ }
+
+ result.innerHTML = html;
+ }
+
+ QUnit.done( config.stats.bad, config.stats.all );
+}
+
+function validTest( name ) {
+ var i = config.filters.length,
+ run = false;
+
+ if ( !i ) {
+ return true;
+ }
+
+ while ( i-- ) {
+ var filter = config.filters[i],
+ not = filter.charAt(0) == '!';
+
+ if ( not ) {
+ filter = filter.slice(1);
+ }
+
+ if ( name.indexOf(filter) !== -1 ) {
+ return !not;
+ }
+
+ if ( not ) {
+ run = true;
+ }
+ }
+
+ return run;
+}
+
+function push(result, actual, expected, message) {
+ message = message || (result ? "okay" : "failed");
+ QUnit.ok( result, result ? message + ": " + QUnit.jsDump.parse(expected) : message + ", expected: " + QUnit.jsDump.parse(expected) + " result: " + QUnit.jsDump.parse(actual) );
+}
+
+function synchronize( callback ) {
+ config.queue.push( callback );
+
+ if ( config.autorun && !config.blocking ) {
+ process();
+ }
+}
+
+function process() {
+ var start = (new Date()).getTime();
+
+ while ( config.queue.length && !config.blocking ) {
+ if ( config.updateRate <= 0 || (((new Date()).getTime() - start) < config.updateRate) ) {
+ config.queue.shift()();
+
+ } else {
+ setTimeout( process, 13 );
+ break;
+ }
+ }
+}
+
+function saveGlobal() {
+ config.pollution = [];
+
+ if ( config.noglobals ) {
+ for ( var key in window ) {
+ config.pollution.push( key );
+ }
+ }
+}
+
+function checkPollution( name ) {
+ var old = config.pollution;
+ saveGlobal();
+
+ var newGlobals = diff( old, config.pollution );
+ if ( newGlobals.length > 0 ) {
+ ok( false, "Introduced global variable(s): " + newGlobals.join(", ") );
+ config.expected++;
+ }
+
+ var deletedGlobals = diff( config.pollution, old );
+ if ( deletedGlobals.length > 0 ) {
+ ok( false, "Deleted global variable(s): " + deletedGlobals.join(", ") );
+ config.expected++;
+ }
+}
+
+// returns a new Array with the elements that are in a but not in b
+function diff( a, b ) {
+ var result = a.slice();
+ for ( var i = 0; i < result.length; i++ ) {
+ for ( var j = 0; j < b.length; j++ ) {
+ if ( result[i] === b[j] ) {
+ result.splice(i, 1);
+ i--;
+ break;
+ }
+ }
+ }
+ return result;
+}
+
+function fail(message, exception, callback) {
+ if ( typeof console !== "undefined" && console.error && console.warn ) {
+ console.error(message);
+ console.error(exception);
+ console.warn(callback.toString());
+
+ } else if ( window.opera && opera.postError ) {
+ opera.postError(message, exception, callback.toString);
+ }
+}
+
+function extend(a, b) {
+ for ( var prop in b ) {
+ a[prop] = b[prop];
+ }
+
+ return a;
+}
+
+function addEvent(elem, type, fn) {
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, fn, false );
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, fn );
+ } else {
+ fn();
+ }
+}
+
+function id(name) {
+ return !!(typeof document !== "undefined" && document && document.getElementById) &&
+ document.getElementById( name );
+}
+
+// Test for equality any JavaScript type.
+// Discussions and reference: http://philrathe.com/articles/equiv
+// Test suites: http://philrathe.com/tests/equiv
+// Author: Philippe Rathé <prathe@gmail.com>
+QUnit.equiv = function () {
+
+ var innerEquiv; // the real equiv function
+ var callers = []; // stack to decide between skip/abort functions
+ var parents = []; // stack to avoiding loops from circular referencing
+
+
+ // Determine what is o.
+ function hoozit(o) {
+ if (QUnit.is("String", o)) {
+ return "string";
+
+ } else if (QUnit.is("Boolean", o)) {
+ return "boolean";
+
+ } else if (QUnit.is("Number", o)) {
+
+ if (isNaN(o)) {
+ return "nan";
+ } else {
+ return "number";
+ }
+
+ } else if (typeof o === "undefined") {
+ return "undefined";
+
+ // consider: typeof null === object
+ } else if (o === null) {
+ return "null";
+
+ // consider: typeof [] === object
+ } else if (QUnit.is( "Array", o)) {
+ return "array";
+
+ // consider: typeof new Date() === object
+ } else if (QUnit.is( "Date", o)) {
+ return "date";
+
+ // consider: /./ instanceof Object;
+ // /./ instanceof RegExp;
+ // typeof /./ === "function"; // => false in IE and Opera,
+ // true in FF and Safari
+ } else if (QUnit.is( "RegExp", o)) {
+ return "regexp";
+
+ } else if (typeof o === "object") {
+ return "object";
+
+ } else if (QUnit.is( "Function", o)) {
+ return "function";
+ } else {
+ return undefined;
+ }
+ }
+
+ // Call the o related callback with the given arguments.
+ function bindCallbacks(o, callbacks, args) {
+ var prop = hoozit(o);
+ if (prop) {
+ if (hoozit(callbacks[prop]) === "function") {
+ return callbacks[prop].apply(callbacks, args);
+ } else {
+ return callbacks[prop]; // or undefined
+ }
+ }
+ }
+
+ var callbacks = function () {
+
+ // for string, boolean, number and null
+ function useStrictEquality(b, a) {
+ if (b instanceof a.constructor || a instanceof b.constructor) {
+ // to catch short annotaion VS 'new' annotation of a declaration
+ // e.g. var i = 1;
+ // var j = new Number(1);
+ return a == b;
+ } else {
+ return a === b;
+ }
+ }
+
+ return {
+ "string": useStrictEquality,
+ "boolean": useStrictEquality,
+ "number": useStrictEquality,
+ "null": useStrictEquality,
+ "undefined": useStrictEquality,
+
+ "nan": function (b) {
+ return isNaN(b);
+ },
+
+ "date": function (b, a) {
+ return hoozit(b) === "date" && a.valueOf() === b.valueOf();
+ },
+
+ "regexp": function (b, a) {
+ return hoozit(b) === "regexp" &&
+ a.source === b.source && // the regex itself
+ a.global === b.global && // and its modifers (gmi) ...
+ a.ignoreCase === b.ignoreCase &&
+ a.multiline === b.multiline;
+ },
+
+ // - skip when the property is a method of an instance (OOP)
+ // - abort otherwise,
+ // initial === would have catch identical references anyway
+ "function": function () {
+ var caller = callers[callers.length - 1];
+ return caller !== Object &&
+ typeof caller !== "undefined";
+ },
+
+ "array": function (b, a) {
+ var i, j, loop;
+ var len;
+
+ // b could be an object literal here
+ if ( ! (hoozit(b) === "array")) {
+ return false;
+ }
+
+ len = a.length;
+ if (len !== b.length) { // safe and faster
+ return false;
+ }
+
+ //track reference to avoid circular references
+ parents.push(a);
+ 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
+ }
+ }
+ if (!loop && ! innerEquiv(a[i], b[i])) {
+ parents.pop();
+ return false;
+ }
+ }
+ parents.pop();
+ return true;
+ },
+
+ "object": function (b, a) {
+ var i, j, loop;
+ var eq = true; // unless we can proove it
+ var aProperties = [], bProperties = []; // collection of strings
+
+ // comparing constructors is more strict than using instanceof
+ if ( a.constructor !== b.constructor) {
+ return false;
+ }
+
+ // stack constructor before traversing properties
+ callers.push(a.constructor);
+ //track reference to avoid circular references
+ parents.push(a);
+
+ for (i in a) { // be strict: don't ensures hasOwnProperty and go deep
+ loop = false;
+ for(j=0;j<parents.length;j++){
+ if(parents[j] === a[i])
+ loop = true; //don't go down the same path twice
+ }
+ aProperties.push(i); // collect a's properties
+
+ if (!loop && ! innerEquiv(a[i], b[i])) {
+ eq = false;
+ break;
+ }
+ }
+
+ callers.pop(); // unstack, we are done
+ parents.pop();
+
+ for (i in b) {
+ bProperties.push(i); // collect b's properties
+ }
+
+ // Ensures identical properties name
+ return eq && innerEquiv(aProperties.sort(), bProperties.sort());
+ }
+ };
+ }();
+
+ innerEquiv = function () { // can take multiple arguments
+ var args = Array.prototype.slice.apply(arguments);
+ if (args.length < 2) {
+ return true; // end transition
+ }
+
+ return (function (a, b) {
+ if (a === b) {
+ return true; // catch the most you can
+ } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || hoozit(a) !== hoozit(b)) {
+ return false; // don't lose time with error prone cases
+ } else {
+ return bindCallbacks(a, callbacks, [b, a]);
+ }
+
+ // apply transition with (1..n) arguments
+ })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1));
+ };
+
+ return innerEquiv;
+
+}();
+
+/**
+ * jsDump
+ * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
+ * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
+ * Date: 5/15/2008
+ * @projectDescription Advanced and extensible data dumping for Javascript.
+ * @version 1.0.0
+ * @author Ariel Flesler
+ * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}
+ */
+QUnit.jsDump = (function() {
+ function quote( str ) {
+ return '"' + str.toString().replace(/"/g, '\\"') + '"';
+ };
+ function literal( o ) {
+ return o + '';
+ };
+ function join( pre, arr, post ) {
+ var s = jsDump.separator(),
+ base = jsDump.indent(),
+ inner = jsDump.indent(1);
+ if ( arr.join )
+ arr = arr.join( ',' + s + inner );
+ if ( !arr )
+ return pre + post;
+ return [ pre, inner + arr, base + post ].join(s);
+ };
+ function array( arr ) {
+ var i = arr.length, ret = Array(i);
+ this.up();
+ while ( i-- )
+ ret[i] = this.parse( arr[i] );
+ this.down();
+ return join( '[', ret, ']' );
+ };
+
+ var reName = /^function (\w+)/;
+
+ var jsDump = {
+ parse:function( obj, type ) { //type is used mostly internally, you can fix a (custom)type in advance
+ var parser = this.parsers[ type || this.typeOf(obj) ];
+ type = typeof parser;
+
+ return type == 'function' ? parser.call( this, obj ) :
+ type == 'string' ? parser :
+ this.parsers.error;
+ },
+ typeOf:function( obj ) {
+ var type;
+ if ( obj === null ) {
+ type = "null";
+ } else if (typeof obj === "undefined") {
+ type = "undefined";
+ } else if (QUnit.is("RegExp", obj)) {
+ type = "regexp";
+ } else if (QUnit.is("Date", obj)) {
+ type = "date";
+ } else if (QUnit.is("Function", obj)) {
+ type = "function";
+ } else if (obj.setInterval && obj.document && !obj.nodeType) {
+ type = "window";
+ } else if (obj.nodeType === 9) {
+ type = "document";
+ } else if (obj.nodeType) {
+ type = "node";
+ } else if (typeof obj === "object" && typeof obj.length === "number" && obj.length >= 0) {
+ type = "array";
+ } else {
+ type = typeof obj;
+ }
+ return type;
+ },
+ separator:function() {
+ return this.multiline ? this.HTML ? '<br />' : '\n' : this.HTML ? '&nbsp;' : ' ';
+ },
+ indent:function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing
+ if ( !this.multiline )
+ return '';
+ var chr = this.indentChar;
+ if ( this.HTML )
+ chr = chr.replace(/\t/g,' ').replace(/ /g,'&nbsp;');
+ return Array( this._depth_ + (extra||0) ).join(chr);
+ },
+ up:function( a ) {
+ this._depth_ += a || 1;
+ },
+ down:function( a ) {
+ this._depth_ -= a || 1;
+ },
+ setParser:function( name, parser ) {
+ this.parsers[name] = parser;
+ },
+ // The next 3 are exposed so you can use them
+ quote:quote,
+ literal:literal,
+ join:join,
+ //
+ _depth_: 1,
+ // This is the list of parsers, to modify them, use jsDump.setParser
+ parsers:{
+ window: '[Window]',
+ document: '[Document]',
+ error:'[ERROR]', //when no parser is found, shouldn't happen
+ unknown: '[Unknown]',
+ 'null':'null',
+ undefined:'undefined',
+ 'function':function( fn ) {
+ var ret = 'function',
+ name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE
+ if ( name )
+ ret += ' ' + name;
+ ret += '(';
+
+ ret = [ ret, this.parse( fn, 'functionArgs' ), '){'].join('');
+ return join( ret, this.parse(fn,'functionCode'), '}' );
+ },
+ array: array,
+ nodelist: array,
+ arguments: array,
+ object:function( map ) {
+ var ret = [ ];
+ this.up();
+ for ( var key in map )
+ ret.push( this.parse(key,'key') + ': ' + this.parse(map[key]) );
+ this.down();
+ return join( '{', ret, '}' );
+ },
+ node:function( node ) {
+ var open = this.HTML ? '&lt;' : '<',
+ close = this.HTML ? '&gt;' : '>';
+
+ var tag = node.nodeName.toLowerCase(),
+ ret = open + tag;
+
+ for ( var a in this.DOMAttrs ) {
+ var val = node[this.DOMAttrs[a]];
+ if ( val )
+ ret += ' ' + a + '=' + this.parse( val, 'attribute' );
+ }
+ return ret + close + open + '/' + tag + close;
+ },
+ functionArgs:function( fn ) {//function calls it internally, it's the arguments part of the function
+ var l = fn.length;
+ if ( !l ) return '';
+
+ var args = Array(l);
+ while ( l-- )
+ args[l] = String.fromCharCode(97+l);//97 is 'a'
+ return ' ' + args.join(', ') + ' ';
+ },
+ key:quote, //object calls it internally, the key part of an item in a map
+ functionCode:'[code]', //function calls it internally, it's the content of the function
+ attribute:quote, //node calls it internally, it's an html attribute value
+ string:quote,
+ date:quote,
+ regexp:literal, //regex
+ number:literal,
+ 'boolean':literal
+ },
+ DOMAttrs:{//attributes to dump from nodes, name=>realName
+ id:'id',
+ name:'name',
+ 'class':'className'
+ },
+ HTML:false,//if true, entities are escaped ( <, >, \t, space and \n )
+ indentChar:' ',//indentation unit
+ multiline:false //if true, items in a collection, are separated by a \n, else just a space.
+ };
+
+ return jsDump;
+})();
+
+})(this);
diff --git a/addon/js_upload/file-uploader/tests/qunit/test/index.html b/addon/js_upload/file-uploader/tests/qunit/test/index.html
new file mode 100644
index 000000000..8a9f86500
--- /dev/null
+++ b/addon/js_upload/file-uploader/tests/qunit/test/index.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>QUnit Test Suite</title>
+ <link rel="stylesheet" href="../qunit/qunit.css" type="text/css" media="screen">
+ <script type="text/javascript" src="../qunit/qunit.js"></script>
+ <script type="text/javascript" src="test.js"></script>
+ <script type="text/javascript" src="same.js"></script>
+</head>
+<body>
+ <h1 id="qunit-header">QUnit Test Suite</h1>
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+</body>
+</html>
diff --git a/addon/js_upload/file-uploader/tests/qunit/test/same.js b/addon/js_upload/file-uploader/tests/qunit/test/same.js
new file mode 100644
index 000000000..8f1b5630f
--- /dev/null
+++ b/addon/js_upload/file-uploader/tests/qunit/test/same.js
@@ -0,0 +1,1423 @@
+module("equiv");
+
+
+test("Primitive types and constants", function () {
+ equals(QUnit.equiv(null, null), true, "null");
+ equals(QUnit.equiv(null, {}), false, "null");
+ equals(QUnit.equiv(null, undefined), false, "null");
+ equals(QUnit.equiv(null, 0), false, "null");
+ equals(QUnit.equiv(null, false), false, "null");
+ equals(QUnit.equiv(null, ''), false, "null");
+ equals(QUnit.equiv(null, []), false, "null");
+
+ equals(QUnit.equiv(undefined, undefined), true, "undefined");
+ equals(QUnit.equiv(undefined, null), false, "undefined");
+ equals(QUnit.equiv(undefined, 0), false, "undefined");
+ equals(QUnit.equiv(undefined, false), false, "undefined");
+ equals(QUnit.equiv(undefined, {}), false, "undefined");
+ equals(QUnit.equiv(undefined, []), false, "undefined");
+ equals(QUnit.equiv(undefined, ""), false, "undefined");
+
+ // Nan usually doest not equal to Nan using the '==' operator.
+ // Only isNaN() is able to do it.
+ equals(QUnit.equiv(0/0, 0/0), true, "NaN"); // NaN VS NaN
+ equals(QUnit.equiv(1/0, 2/0), true, "Infinity"); // Infinity VS Infinity
+ equals(QUnit.equiv(-1/0, 2/0), false, "-Infinity, Infinity"); // -Infinity VS Infinity
+ equals(QUnit.equiv(-1/0, -2/0), true, "-Infinity, -Infinity"); // -Infinity VS -Infinity
+ equals(QUnit.equiv(0/0, 1/0), false, "NaN, Infinity"); // Nan VS Infinity
+ equals(QUnit.equiv(1/0, 0/0), false, "NaN, Infinity"); // Nan VS Infinity
+ equals(QUnit.equiv(0/0, null), false, "NaN");
+ equals(QUnit.equiv(0/0, undefined), false, "NaN");
+ equals(QUnit.equiv(0/0, 0), false, "NaN");
+ equals(QUnit.equiv(0/0, false), false, "NaN");
+ equals(QUnit.equiv(0/0, function () {}), false, "NaN");
+ equals(QUnit.equiv(1/0, null), false, "NaN, Infinity");
+ equals(QUnit.equiv(1/0, undefined), false, "NaN, Infinity");
+ equals(QUnit.equiv(1/0, 0), false, "NaN, Infinity");
+ equals(QUnit.equiv(1/0, 1), false, "NaN, Infinity");
+ equals(QUnit.equiv(1/0, false), false, "NaN, Infinity");
+ equals(QUnit.equiv(1/0, true), false, "NaN, Infinity");
+ equals(QUnit.equiv(1/0, function () {}), false, "NaN, Infinity");
+
+ equals(QUnit.equiv(0, 0), true, "number");
+ equals(QUnit.equiv(0, 1), false, "number");
+ equals(QUnit.equiv(1, 0), false, "number");
+ equals(QUnit.equiv(1, 1), true, "number");
+ equals(QUnit.equiv(1.1, 1.1), true, "number");
+ equals(QUnit.equiv(0.0000005, 0.0000005), true, "number");
+ equals(QUnit.equiv(0, ''), false, "number");
+ equals(QUnit.equiv(0, '0'), false, "number");
+ equals(QUnit.equiv(1, '1'), false, "number");
+ equals(QUnit.equiv(0, false), false, "number");
+ equals(QUnit.equiv(1, true), false, "number");
+
+ equals(QUnit.equiv(true, true), true, "boolean");
+ equals(QUnit.equiv(true, false), false, "boolean");
+ equals(QUnit.equiv(false, true), false, "boolean");
+ equals(QUnit.equiv(false, 0), false, "boolean");
+ equals(QUnit.equiv(false, null), false, "boolean");
+ equals(QUnit.equiv(false, undefined), false, "boolean");
+ equals(QUnit.equiv(true, 1), false, "boolean");
+ equals(QUnit.equiv(true, null), false, "boolean");
+ equals(QUnit.equiv(true, undefined), false, "boolean");
+
+ equals(QUnit.equiv('', ''), true, "string");
+ equals(QUnit.equiv('a', 'a'), true, "string");
+ equals(QUnit.equiv("foobar", "foobar"), true, "string");
+ equals(QUnit.equiv("foobar", "foo"), false, "string");
+ equals(QUnit.equiv('', 0), false, "string");
+ equals(QUnit.equiv('', false), false, "string");
+ equals(QUnit.equiv('', null), false, "string");
+ equals(QUnit.equiv('', undefined), false, "string");
+
+ // Short annotation VS new annotation
+ equals(QUnit.equiv(0, new Number()), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(new Number(), 0), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(1, new Number(1)), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(new Number(1), 1), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(new Number(0), 1), false, "short annotation VS new annotation");
+ equals(QUnit.equiv(0, new Number(1)), false, "short annotation VS new annotation");
+
+ equals(QUnit.equiv(new String(), ""), true, "short annotation VS new annotation");
+ equals(QUnit.equiv("", new String()), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(new String("My String"), "My String"), true, "short annotation VS new annotation");
+ equals(QUnit.equiv("My String", new String("My String")), true, "short annotation VS new annotation");
+ equals(QUnit.equiv("Bad String", new String("My String")), false, "short annotation VS new annotation");
+ equals(QUnit.equiv(new String("Bad String"), "My String"), false, "short annotation VS new annotation");
+
+ equals(QUnit.equiv(false, new Boolean()), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(new Boolean(), false), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(true, new Boolean(true)), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(new Boolean(true), true), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(true, new Boolean(1)), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(false, new Boolean(false)), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(new Boolean(false), false), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(false, new Boolean(0)), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(true, new Boolean(false)), false, "short annotation VS new annotation");
+ equals(QUnit.equiv(new Boolean(false), true), false, "short annotation VS new annotation");
+
+ equals(QUnit.equiv(new Object(), {}), true, "short annotation VS new annotation");
+ equals(QUnit.equiv({}, new Object()), true, "short annotation VS new annotation");
+ equals(QUnit.equiv(new Object(), {a:1}), false, "short annotation VS new annotation");
+ equals(QUnit.equiv({a:1}, new Object()), false, "short annotation VS new annotation");
+ equals(QUnit.equiv({a:undefined}, new Object()), false, "short annotation VS new annotation");
+ equals(QUnit.equiv(new Object(), {a:undefined}), false, "short annotation VS new annotation");
+});
+
+test("Objects Basics.", function() {
+ equals(QUnit.equiv({}, {}), true);
+ equals(QUnit.equiv({}, null), false);
+ equals(QUnit.equiv({}, undefined), false);
+ equals(QUnit.equiv({}, 0), false);
+ equals(QUnit.equiv({}, false), false);
+
+ // This test is a hard one, it is very important
+ // REASONS:
+ // 1) They are of the same type "object"
+ // 2) [] instanceof Object is true
+ // 3) Their properties are the same (doesn't exists)
+ equals(QUnit.equiv({}, []), false);
+
+ equals(QUnit.equiv({a:1}, {a:1}), true);
+ equals(QUnit.equiv({a:1}, {a:"1"}), false);
+ equals(QUnit.equiv({a:[]}, {a:[]}), true);
+ equals(QUnit.equiv({a:{}}, {a:null}), false);
+ equals(QUnit.equiv({a:1}, {}), false);
+ equals(QUnit.equiv({}, {a:1}), false);
+
+ // Hard ones
+ equals(QUnit.equiv({a:undefined}, {}), false);
+ equals(QUnit.equiv({}, {a:undefined}), false);
+ equals(QUnit.equiv(
+ {
+ a: [{ bar: undefined }]
+ },
+ {
+ a: [{ bat: undefined }]
+ }
+ ), false);
+});
+
+
+test("Arrays Basics.", function() {
+
+ equals(QUnit.equiv([], []), true);
+
+ // May be a hard one, can invoke a crash at execution.
+ // because their types are both "object" but null isn't
+ // like a true object, it doesn't have any property at all.
+ equals(QUnit.equiv([], null), false);
+
+ equals(QUnit.equiv([], undefined), false);
+ equals(QUnit.equiv([], false), false);
+ equals(QUnit.equiv([], 0), false);
+ equals(QUnit.equiv([], ""), false);
+
+ // May be a hard one, but less hard
+ // than {} with [] (note the order)
+ equals(QUnit.equiv([], {}), false);
+
+ equals(QUnit.equiv([null],[]), false);
+ equals(QUnit.equiv([undefined],[]), false);
+ equals(QUnit.equiv([],[null]), false);
+ equals(QUnit.equiv([],[undefined]), false);
+ equals(QUnit.equiv([null],[undefined]), false);
+ equals(QUnit.equiv([[]],[[]]), true);
+ equals(QUnit.equiv([[],[],[]],[[],[],[]]), true);
+ equals(QUnit.equiv(
+ [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
+ [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]),
+ true);
+ equals(QUnit.equiv(
+ [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
+ [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]), // shorter
+ false);
+ equals(QUnit.equiv(
+ [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{}]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
+ [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]), // deepest element not an array
+ false);
+
+ // same multidimensional
+ equals(QUnit.equiv(
+ [1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,[
+ [6,7,8,9, [
+ [
+ 1,2,3,4,[
+ 2,3,4,[
+ 1,2,[
+ 1,2,3,4,[
+ 1,2,3,4,5,6,7,8,9,[
+ 0
+ ],1,2,3,4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],5,6,7
+ ]
+ ]
+ ]
+ ]
+ ]]],
+ [1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,[
+ [6,7,8,9, [
+ [
+ 1,2,3,4,[
+ 2,3,4,[
+ 1,2,[
+ 1,2,3,4,[
+ 1,2,3,4,5,6,7,8,9,[
+ 0
+ ],1,2,3,4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],5,6,7
+ ]
+ ]
+ ]
+ ]
+ ]]]),
+ true, "Multidimensional");
+
+ // different multidimensional
+ equals(QUnit.equiv(
+ [1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,[
+ [6,7,8,9, [
+ [
+ 1,2,3,4,[
+ 2,3,4,[
+ 1,2,[
+ 1,2,3,4,[
+ 1,2,3,4,5,6,7,8,9,[
+ 0
+ ],1,2,3,4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],5,6,7
+ ]
+ ]
+ ]
+ ]
+ ]]],
+ [1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,[
+ [6,7,8,9, [
+ [
+ 1,2,3,4,[
+ 2,3,4,[
+ 1,2,[
+ '1',2,3,4,[ // string instead of number
+ 1,2,3,4,5,6,7,8,9,[
+ 0
+ ],1,2,3,4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],5,6,7
+ ]
+ ]
+ ]
+ ]
+ ]]]),
+ false, "Multidimensional");
+
+ // different multidimensional
+ equals(QUnit.equiv(
+ [1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,[
+ [6,7,8,9, [
+ [
+ 1,2,3,4,[
+ 2,3,4,[
+ 1,2,[
+ 1,2,3,4,[
+ 1,2,3,4,5,6,7,8,9,[
+ 0
+ ],1,2,3,4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],5,6,7
+ ]
+ ]
+ ]
+ ]
+ ]]],
+ [1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,6,7,8,9, [
+ 1,2,3,4,5,[
+ [6,7,8,9, [
+ [
+ 1,2,3,4,[
+ 2,3,[ // missing an element (4)
+ 1,2,[
+ 1,2,3,4,[
+ 1,2,3,4,5,6,7,8,9,[
+ 0
+ ],1,2,3,4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],4,5,6,7,8,9
+ ],5,6,7,8,9
+ ],5,6,7
+ ]
+ ]
+ ]
+ ]
+ ]]]),
+ false, "Multidimensional");
+});
+
+test("Functions.", function() {
+ var f0 = function () {};
+ var f1 = function () {};
+
+ // f2 and f3 have the same code, formatted differently
+ var f2 = function () {var i = 0;};
+ var f3 = function () {
+ var i = 0 // this comment and no semicoma as difference
+ };
+
+ equals(QUnit.equiv(function() {}, function() {}), false, "Anonymous functions"); // exact source code
+ equals(QUnit.equiv(function() {}, function() {return true;}), false, "Anonymous functions");
+
+ equals(QUnit.equiv(f0, f0), true, "Function references"); // same references
+ equals(QUnit.equiv(f0, f1), false, "Function references"); // exact source code, different references
+ equals(QUnit.equiv(f2, f3), false, "Function references"); // equivalent source code, different references
+ equals(QUnit.equiv(f1, f2), false, "Function references"); // different source code, different references
+ equals(QUnit.equiv(function() {}, true), false);
+ equals(QUnit.equiv(function() {}, undefined), false);
+ equals(QUnit.equiv(function() {}, null), false);
+ equals(QUnit.equiv(function() {}, {}), false);
+});
+
+
+test("Date instances.", function() {
+ // Date, we don't need to test Date.parse() because it returns a number.
+ // Only test the Date instances by setting them a fix date.
+ // The date use is midnight January 1, 1970
+
+ var d1 = new Date();
+ d1.setTime(0); // fix the date
+
+ var d2 = new Date();
+ d2.setTime(0); // fix the date
+
+ var d3 = new Date(); // The very now
+
+ // Anyway their types differs, just in case the code fails in the order in which it deals with date
+ equals(QUnit.equiv(d1, 0), false); // d1.valueOf() returns 0, but d1 and 0 are different
+ // test same values date and different instances equality
+ equals(QUnit.equiv(d1, d2), true);
+ // test different date and different instances difference
+ equals(QUnit.equiv(d1, d3), false);
+});
+
+
+test("RegExp.", function() {
+ // Must test cases that imply those traps:
+ // var a = /./;
+ // a instanceof Object; // Oops
+ // a instanceof RegExp; // Oops
+ // typeof a === "function"; // Oops, false in IE and Opera, true in FF and Safari ("object")
+
+ // Tests same regex with same modifiers in different order
+ var r = /foo/;
+ var r5 = /foo/gim;
+ var r6 = /foo/gmi;
+ var r7 = /foo/igm;
+ var r8 = /foo/img;
+ var r9 = /foo/mig;
+ var r10 = /foo/mgi;
+ var ri1 = /foo/i;
+ var ri2 = /foo/i;
+ var rm1 = /foo/m;
+ var rm2 = /foo/m;
+ var rg1 = /foo/g;
+ var rg2 = /foo/g;
+
+ equals(QUnit.equiv(r5, r6), true, "Modifier order");
+ equals(QUnit.equiv(r5, r7), true, "Modifier order");
+ equals(QUnit.equiv(r5, r8), true, "Modifier order");
+ equals(QUnit.equiv(r5, r9), true, "Modifier order");
+ equals(QUnit.equiv(r5, r10), true, "Modifier order");
+ equals(QUnit.equiv(r, r5), false, "Modifier");
+
+ equals(QUnit.equiv(ri1, ri2), true, "Modifier");
+ equals(QUnit.equiv(r, ri1), false, "Modifier");
+ equals(QUnit.equiv(ri1, rm1), false, "Modifier");
+ equals(QUnit.equiv(r, rm1), false, "Modifier");
+ equals(QUnit.equiv(rm1, ri1), false, "Modifier");
+ equals(QUnit.equiv(rm1, rm2), true, "Modifier");
+ equals(QUnit.equiv(rg1, rm1), false, "Modifier");
+ equals(QUnit.equiv(rm1, rg1), false, "Modifier");
+ equals(QUnit.equiv(rg1, rg2), true, "Modifier");
+
+ // Different regex, same modifiers
+ var r11 = /[a-z]/gi;
+ var r13 = /[0-9]/gi; // oops! different
+ equals(QUnit.equiv(r11, r13), false, "Regex pattern");
+
+ var r14 = /0/ig;
+ var r15 = /"0"/ig; // oops! different
+ equals(QUnit.equiv(r14, r15), false, "Regex pattern");
+
+ var r1 = /[\n\r\u2028\u2029]/g;
+ var r2 = /[\n\r\u2028\u2029]/g;
+ var r3 = /[\n\r\u2028\u2028]/g; // differs from r1
+ var r4 = /[\n\r\u2028\u2029]/; // differs from r1
+
+ equals(QUnit.equiv(r1, r2), true, "Regex pattern");
+ equals(QUnit.equiv(r1, r3), false, "Regex pattern");
+ equals(QUnit.equiv(r1, r4), false, "Regex pattern");
+
+ // More complex regex
+ var regex1 = "^[-_.a-z0-9]+@([-_a-z0-9]+\\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$";
+ var regex2 = "^[-_.a-z0-9]+@([-_a-z0-9]+\\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$";
+ // regex 3 is different: '.' not escaped
+ var regex3 = "^[-_.a-z0-9]+@([-_a-z0-9]+.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$";
+
+ var r21 = new RegExp(regex1);
+ var r22 = new RegExp(regex2);
+ var r23 = new RegExp(regex3); // diff from r21, not same pattern
+ var r23a = new RegExp(regex3, "gi"); // diff from r23, not same modifier
+ var r24a = new RegExp(regex3, "ig"); // same as r23a
+
+ equals(QUnit.equiv(r21, r22), true, "Complex Regex");
+ equals(QUnit.equiv(r21, r23), false, "Complex Regex");
+ equals(QUnit.equiv(r23, r23a), false, "Complex Regex");
+ equals(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 = / /;
+ equals(QUnit.equiv(re, function () {}), false, "Regex internal");
+ equals(QUnit.equiv(re, {}), false, "Regex internal");
+});
+
+
+test("Complex Objects.", function() {
+
+ function fn1() {
+ return "fn1";
+ }
+ function fn2() {
+ return "fn2";
+ }
+
+ // Try to invert the order of some properties to make sure it is covered.
+ // It can failed when properties are compared between unsorted arrays.
+ equals(QUnit.equiv(
+ {
+ a: 1,
+ b: null,
+ c: [{}],
+ d: {
+ a: 3.14159,
+ b: false,
+ c: {
+ e: fn1,
+ f: [[[]]],
+ g: {
+ j: {
+ k: {
+ n: {
+ r: "r",
+ s: [1,2,3],
+ t: undefined,
+ u: 0,
+ v: {
+ w: {
+ x: {
+ y: "Yahoo!",
+ z: null
+ }
+ }
+ }
+ },
+ q: [],
+ p: 1/0,
+ o: 99
+ },
+ l: undefined,
+ m: null
+ }
+ },
+ d: 0,
+ i: true,
+ h: "false"
+ }
+ },
+ e: undefined,
+ g: "",
+ h: "h",
+ f: {},
+ i: []
+ },
+ {
+ a: 1,
+ b: null,
+ c: [{}],
+ d: {
+ b: false,
+ a: 3.14159,
+ c: {
+ d: 0,
+ e: fn1,
+ f: [[[]]],
+ g: {
+ j: {
+ k: {
+ n: {
+ r: "r",
+ t: undefined,
+ u: 0,
+ s: [1,2,3],
+ v: {
+ w: {
+ x: {
+ z: null,
+ y: "Yahoo!"
+ }
+ }
+ }
+ },
+ o: 99,
+ p: 1/0,
+ q: []
+ },
+ l: undefined,
+ m: null
+ }
+ },
+ i: true,
+ h: "false"
+ }
+ },
+ e: undefined,
+ g: "",
+ f: {},
+ h: "h",
+ i: []
+ }
+ ), true);
+
+ equals(QUnit.equiv(
+ {
+ a: 1,
+ b: null,
+ c: [{}],
+ d: {
+ a: 3.14159,
+ b: false,
+ c: {
+ d: 0,
+ e: fn1,
+ f: [[[]]],
+ g: {
+ j: {
+ k: {
+ n: {
+ //r: "r", // different: missing a property
+ s: [1,2,3],
+ t: undefined,
+ u: 0,
+ v: {
+ w: {
+ x: {
+ y: "Yahoo!",
+ z: null
+ }
+ }
+ }
+ },
+ o: 99,
+ p: 1/0,
+ q: []
+ },
+ l: undefined,
+ m: null
+ }
+ },
+ h: "false",
+ i: true
+ }
+ },
+ e: undefined,
+ f: {},
+ g: "",
+ h: "h",
+ i: []
+ },
+ {
+ a: 1,
+ b: null,
+ c: [{}],
+ d: {
+ a: 3.14159,
+ b: false,
+ c: {
+ d: 0,
+ e: fn1,
+ f: [[[]]],
+ g: {
+ j: {
+ k: {
+ n: {
+ r: "r",
+ s: [1,2,3],
+ t: undefined,
+ u: 0,
+ v: {
+ w: {
+ x: {
+ y: "Yahoo!",
+ z: null
+ }
+ }
+ }
+ },
+ o: 99,
+ p: 1/0,
+ q: []
+ },
+ l: undefined,
+ m: null
+ }
+ },
+ h: "false",
+ i: true
+ }
+ },
+ e: undefined,
+ f: {},
+ g: "",
+ h: "h",
+ i: []
+ }
+ ), false);
+
+ equals(QUnit.equiv(
+ {
+ a: 1,
+ b: null,
+ c: [{}],
+ d: {
+ a: 3.14159,
+ b: false,
+ c: {
+ d: 0,
+ e: fn1,
+ f: [[[]]],
+ g: {
+ j: {
+ k: {
+ n: {
+ r: "r",
+ s: [1,2,3],
+ t: undefined,
+ u: 0,
+ v: {
+ w: {
+ x: {
+ y: "Yahoo!",
+ z: null
+ }
+ }
+ }
+ },
+ o: 99,
+ p: 1/0,
+ q: []
+ },
+ l: undefined,
+ m: null
+ }
+ },
+ h: "false",
+ i: true
+ }
+ },
+ e: undefined,
+ f: {},
+ g: "",
+ h: "h",
+ i: []
+ },
+ {
+ a: 1,
+ b: null,
+ c: [{}],
+ d: {
+ a: 3.14159,
+ b: false,
+ c: {
+ d: 0,
+ e: fn1,
+ f: [[[]]],
+ g: {
+ j: {
+ k: {
+ n: {
+ r: "r",
+ s: [1,2,3],
+ //t: undefined, // different: missing a property with an undefined value
+ u: 0,
+ v: {
+ w: {
+ x: {
+ y: "Yahoo!",
+ z: null
+ }
+ }
+ }
+ },
+ o: 99,
+ p: 1/0,
+ q: []
+ },
+ l: undefined,
+ m: null
+ }
+ },
+ h: "false",
+ i: true
+ }
+ },
+ e: undefined,
+ f: {},
+ g: "",
+ h: "h",
+ i: []
+ }
+ ), false);
+
+ equals(QUnit.equiv(
+ {
+ a: 1,
+ b: null,
+ c: [{}],
+ d: {
+ a: 3.14159,
+ b: false,
+ c: {
+ d: 0,
+ e: fn1,
+ f: [[[]]],
+ g: {
+ j: {
+ k: {
+ n: {
+ r: "r",
+ s: [1,2,3],
+ t: undefined,
+ u: 0,
+ v: {
+ w: {
+ x: {
+ y: "Yahoo!",
+ z: null
+ }
+ }
+ }
+ },
+ o: 99,
+ p: 1/0,
+ q: []
+ },
+ l: undefined,
+ m: null
+ }
+ },
+ h: "false",
+ i: true
+ }
+ },
+ e: undefined,
+ f: {},
+ g: "",
+ h: "h",
+ i: []
+ },
+ {
+ a: 1,
+ b: null,
+ c: [{}],
+ d: {
+ a: 3.14159,
+ b: false,
+ c: {
+ d: 0,
+ e: fn1,
+ f: [[[]]],
+ g: {
+ j: {
+ k: {
+ n: {
+ r: "r",
+ s: [1,2,3],
+ t: undefined,
+ u: 0,
+ v: {
+ w: {
+ x: {
+ y: "Yahoo!",
+ z: null
+ }
+ }
+ }
+ },
+ o: 99,
+ p: 1/0,
+ q: {} // different was []
+ },
+ l: undefined,
+ m: null
+ }
+ },
+ h: "false",
+ i: true
+ }
+ },
+ e: undefined,
+ f: {},
+ g: "",
+ h: "h",
+ i: []
+ }
+ ), false);
+
+ var same1 = {
+ a: [
+ "string", null, 0, "1", 1, {
+ prop: null,
+ foo: [1,2,null,{}, [], [1,2,3]],
+ bar: undefined
+ }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
+ ],
+ unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
+ b: "b",
+ c: fn1
+ };
+
+ var same2 = {
+ a: [
+ "string", null, 0, "1", 1, {
+ prop: null,
+ foo: [1,2,null,{}, [], [1,2,3]],
+ bar: undefined
+ }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
+ ],
+ unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
+ b: "b",
+ c: fn1
+ };
+
+ var diff1 = {
+ a: [
+ "string", null, 0, "1", 1, {
+ prop: null,
+ foo: [1,2,null,{}, [], [1,2,3,4]], // different: 4 was add to the array
+ bar: undefined
+ }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
+ ],
+ unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
+ b: "b",
+ c: fn1
+ };
+
+ var diff2 = {
+ a: [
+ "string", null, 0, "1", 1, {
+ prop: null,
+ foo: [1,2,null,{}, [], [1,2,3]],
+ newprop: undefined, // different: newprop was added
+ bar: undefined
+ }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
+ ],
+ unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
+ b: "b",
+ c: fn1
+ };
+
+ var diff3 = {
+ a: [
+ "string", null, 0, "1", 1, {
+ prop: null,
+ foo: [1,2,null,{}, [], [1,2,3]],
+ bar: undefined
+ }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ α" // different: missing last char
+ ],
+ unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
+ b: "b",
+ c: fn1
+ };
+
+ var diff4 = {
+ a: [
+ "string", null, 0, "1", 1, {
+ prop: null,
+ foo: [1,2,undefined,{}, [], [1,2,3]], // different: undefined instead of null
+ bar: undefined
+ }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
+ ],
+ unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
+ b: "b",
+ c: fn1
+ };
+
+ var diff5 = {
+ a: [
+ "string", null, 0, "1", 1, {
+ prop: null,
+ foo: [1,2,null,{}, [], [1,2,3]],
+ bat: undefined // different: property name not "bar"
+ }, 3, "Hey!", "Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας"
+ ],
+ unicode: "老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争",
+ b: "b",
+ c: fn1
+ };
+
+ equals(QUnit.equiv(same1, same2), true);
+ equals(QUnit.equiv(same2, same1), true);
+ equals(QUnit.equiv(same2, diff1), false);
+ equals(QUnit.equiv(diff1, same2), false);
+
+ equals(QUnit.equiv(same1, diff1), false);
+ equals(QUnit.equiv(same1, diff2), false);
+ equals(QUnit.equiv(same1, diff3), false);
+ equals(QUnit.equiv(same1, diff3), false);
+ equals(QUnit.equiv(same1, diff4), false);
+ equals(QUnit.equiv(same1, diff5), false);
+ equals(QUnit.equiv(diff5, diff1), false);
+});
+
+
+test("Complex Arrays.", function() {
+
+ function fn() {
+ }
+
+ equals(QUnit.equiv(
+ [1, 2, 3, true, {}, null, [
+ {
+ a: ["", '1', 0]
+ },
+ 5, 6, 7
+ ], "foo"],
+ [1, 2, 3, true, {}, null, [
+ {
+ a: ["", '1', 0]
+ },
+ 5, 6, 7
+ ], "foo"]),
+ true);
+
+ equals(QUnit.equiv(
+ [1, 2, 3, true, {}, null, [
+ {
+ a: ["", '1', 0]
+ },
+ 5, 6, 7
+ ], "foo"],
+ [1, 2, 3, true, {}, null, [
+ {
+ b: ["", '1', 0] // not same property name
+ },
+ 5, 6, 7
+ ], "foo"]),
+ false);
+
+ var a = [{
+ b: fn,
+ c: false,
+ "do": "reserved word",
+ "for": {
+ ar: [3,5,9,"hey!", [], {
+ ar: [1,[
+ 3,4,6,9, null, [], []
+ ]],
+ e: fn,
+ f: undefined
+ }]
+ },
+ e: 0.43445
+ }, 5, "string", 0, fn, false, null, undefined, 0, [
+ 4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[3]]]], "3"], {}, 1/0
+ ], [], [[[], "foo", null, {
+ n: 1/0,
+ z: {
+ a: [3,4,5,6,"yep!", undefined, undefined],
+ b: {}
+ }
+ }, {}]]];
+
+ equals(QUnit.equiv(a,
+ [{
+ b: fn,
+ c: false,
+ "do": "reserved word",
+ "for": {
+ ar: [3,5,9,"hey!", [], {
+ ar: [1,[
+ 3,4,6,9, null, [], []
+ ]],
+ e: fn,
+ f: undefined
+ }]
+ },
+ e: 0.43445
+ }, 5, "string", 0, fn, false, null, undefined, 0, [
+ 4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[3]]]], "3"], {}, 1/0
+ ], [], [[[], "foo", null, {
+ n: 1/0,
+ z: {
+ a: [3,4,5,6,"yep!", undefined, undefined],
+ b: {}
+ }
+ }, {}]]]), true);
+
+ equals(QUnit.equiv(a,
+ [{
+ b: fn,
+ c: false,
+ "do": "reserved word",
+ "for": {
+ ar: [3,5,9,"hey!", [], {
+ ar: [1,[
+ 3,4,6,9, null, [], []
+ ]],
+ e: fn,
+ f: undefined
+ }]
+ },
+ e: 0.43445
+ }, 5, "string", 0, fn, false, null, undefined, 0, [
+ 4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[2]]]], "3"], {}, 1/0 // different: [[[[[2]]]]] instead of [[[[[3]]]]]
+ ], [], [[[], "foo", null, {
+ n: 1/0,
+ z: {
+ a: [3,4,5,6,"yep!", undefined, undefined],
+ b: {}
+ }
+ }, {}]]]), false);
+
+ equals(QUnit.equiv(a,
+ [{
+ b: fn,
+ c: false,
+ "do": "reserved word",
+ "for": {
+ ar: [3,5,9,"hey!", [], {
+ ar: [1,[
+ 3,4,6,9, null, [], []
+ ]],
+ e: fn,
+ f: undefined
+ }]
+ },
+ e: 0.43445
+ }, 5, "string", 0, fn, false, null, undefined, 0, [
+ 4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[3]]]], "3"], {}, 1/0
+ ], [], [[[], "foo", null, {
+ n: -1/0, // different, -Infinity instead of Infinity
+ z: {
+ a: [3,4,5,6,"yep!", undefined, undefined],
+ b: {}
+ }
+ }, {}]]]), false);
+
+ equals(QUnit.equiv(a,
+ [{
+ b: fn,
+ c: false,
+ "do": "reserved word",
+ "for": {
+ ar: [3,5,9,"hey!", [], {
+ ar: [1,[
+ 3,4,6,9, null, [], []
+ ]],
+ e: fn,
+ f: undefined
+ }]
+ },
+ e: 0.43445
+ }, 5, "string", 0, fn, false, null, undefined, 0, [
+ 4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[3]]]], "3"], {}, 1/0
+ ], [], [[[], "foo", { // different: null is missing
+ n: 1/0,
+ z: {
+ a: [3,4,5,6,"yep!", undefined, undefined],
+ b: {}
+ }
+ }, {}]]]), false);
+
+ equals(QUnit.equiv(a,
+ [{
+ b: fn,
+ c: false,
+ "do": "reserved word",
+ "for": {
+ ar: [3,5,9,"hey!", [], {
+ ar: [1,[
+ 3,4,6,9, null, [], []
+ ]],
+ e: fn
+ // different: missing property f: undefined
+ }]
+ },
+ e: 0.43445
+ }, 5, "string", 0, fn, false, null, undefined, 0, [
+ 4,5,6,7,8,9,11,22,33,44,55,"66", null, [], [[[[[3]]]], "3"], {}, 1/0
+ ], [], [[[], "foo", null, {
+ n: 1/0,
+ z: {
+ a: [3,4,5,6,"yep!", undefined, undefined],
+ b: {}
+ }
+ }, {}]]]), false);
+});
+
+
+test("Prototypal inheritance", function() {
+ function Gizmo(id) {
+ this.id = id;
+ }
+
+ function Hoozit(id) {
+ this.id = id;
+ }
+ Hoozit.prototype = new Gizmo();
+
+ var gizmo = new Gizmo("ok");
+ var hoozit = new Hoozit("ok");
+
+ // Try this test many times after test on instances that hold function
+ // to make sure that our code does not mess with last object constructor memoization.
+ equals(QUnit.equiv(function () {}, function () {}), false);
+
+ // Hoozit inherit from Gizmo
+ // hoozit instanceof Hoozit; // true
+ // hoozit instanceof Gizmo; // true
+ equals(QUnit.equiv(hoozit, gizmo), true);
+
+ Gizmo.prototype.bar = true; // not a function just in case we skip them
+
+ // Hoozit inherit from Gizmo
+ // They are equivalent
+ equals(QUnit.equiv(hoozit, gizmo), true);
+
+ // Make sure this is still true !important
+ // The reason for this is that I forgot to reset the last
+ // caller to where it were called from.
+ equals(QUnit.equiv(function () {}, function () {}), false);
+
+ // Make sure this is still true !important
+ equals(QUnit.equiv(hoozit, gizmo), true);
+
+ Hoozit.prototype.foo = true; // not a function just in case we skip them
+
+ // Gizmo does not inherit from Hoozit
+ // gizmo instanceof Gizmo; // true
+ // gizmo instanceof Hoozit; // false
+ // They are not equivalent
+ equals(QUnit.equiv(hoozit, gizmo), false);
+
+ // Make sure this is still true !important
+ equals(QUnit.equiv(function () {}, function () {}), false);
+});
+
+
+test("Instances", function() {
+ function A() {}
+ var a1 = new A();
+ var a2 = new A();
+
+ function B() {
+ this.fn = function () {};
+ }
+ var b1 = new B();
+ var b2 = new B();
+
+ equals(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.
+ equals(QUnit.equiv(b1, b2), true, "Same property, same constructor");
+ equals(QUnit.equiv(a1, b1), false, "Same properties but different constructor"); // failed
+
+ function Car(year) {
+ var privateVar = 0;
+ this.year = year;
+ this.isOld = function() {
+ return year > 10;
+ };
+ }
+
+ function Human(year) {
+ var privateVar = 1;
+ this.year = year;
+ this.isOld = function() {
+ return year > 80;
+ };
+ }
+
+ var car = new Car(30);
+ var carSame = new Car(30);
+ var carDiff = new Car(10);
+ var human = new Human(30);
+
+ var diff = {
+ year: 30
+ };
+
+ var same = {
+ year: 30,
+ isOld: function () {}
+ };
+
+ equals(QUnit.equiv(car, car), true);
+ equals(QUnit.equiv(car, carDiff), false);
+ equals(QUnit.equiv(car, carSame), true);
+ equals(QUnit.equiv(car, human), false);
+});
+
+
+test("Complex Instances Nesting (with function value in literals and/or in nested instances)", function() {
+ function A(fn) {
+ this.a = {};
+ this.fn = fn;
+ this.b = {a: []};
+ this.o = {};
+ this.fn1 = fn;
+ }
+ function B(fn) {
+ this.fn = fn;
+ this.fn1 = function () {};
+ this.a = new A(function () {});
+ }
+
+ function fnOutside() {
+ }
+
+ function C(fn) {
+ function fnInside() {
+ }
+ this.x = 10;
+ this.fn = fn;
+ this.fn1 = function () {};
+ this.fn2 = fnInside;
+ this.fn3 = {
+ a: true,
+ b: fnOutside // ok make reference to a function in all instances scope
+ };
+ this.o1 = {};
+
+ // This function will be ignored.
+ // Even if it is not visible for all instances (e.g. locked in a closures),
+ // it is from a property that makes part of an instance (e.g. from the C constructor)
+ this.b1 = new B(function () {});
+ this.b2 = new B({
+ x: {
+ b2: new B(function() {})
+ }
+ });
+ }
+
+ function D(fn) {
+ function fnInside() {
+ }
+ this.x = 10;
+ this.fn = fn;
+ this.fn1 = function () {};
+ this.fn2 = fnInside;
+ this.fn3 = {
+ a: true,
+ b: fnOutside, // ok make reference to a function in all instances scope
+
+ // This function won't be ingored.
+ // It isn't visible for all C insances
+ // and it is not in a property of an instance. (in an Object instances e.g. the object literal)
+ c: fnInside
+ };
+ this.o1 = {};
+
+ // This function will be ignored.
+ // Even if it is not visible for all instances (e.g. locked in a closures),
+ // it is from a property that makes part of an instance (e.g. from the C constructor)
+ this.b1 = new B(function () {});
+ this.b2 = new B({
+ x: {
+ b2: new B(function() {})
+ }
+ });
+ }
+
+ function E(fn) {
+ function fnInside() {
+ }
+ this.x = 10;
+ this.fn = fn;
+ this.fn1 = function () {};
+ this.fn2 = fnInside;
+ this.fn3 = {
+ a: true,
+ b: fnOutside // ok make reference to a function in all instances scope
+ };
+ this.o1 = {};
+
+ // This function will be ignored.
+ // Even if it is not visible for all instances (e.g. locked in a closures),
+ // it is from a property that makes part of an instance (e.g. from the C constructor)
+ this.b1 = new B(function () {});
+ this.b2 = new B({
+ x: {
+ b1: new B({a: function() {}}),
+ b2: new B(function() {})
+ }
+ });
+ }
+
+
+ var a1 = new A(function () {});
+ var a2 = new A(function () {});
+ equals(QUnit.equiv(a1, a2), true);
+
+ equals(QUnit.equiv(a1, a2), true); // different instances
+
+ var b1 = new B(function () {});
+ var b2 = new B(function () {});
+ equals(QUnit.equiv(a1, a2), true);
+
+ var c1 = new C(function () {});
+ var c2 = new C(function () {});
+ equals(QUnit.equiv(c1, c2), true);
+
+ var d1 = new D(function () {});
+ var d2 = new D(function () {});
+ equals(QUnit.equiv(d1, d2), false);
+
+ var e1 = new E(function () {});
+ var e2 = new E(function () {});
+ equals(QUnit.equiv(e1, e2), false);
+
+});
+
+
+test('object with references to self wont loop', function(){
+ var circularA = {
+ abc:null
+ }, circularB = {
+ abc:null
+ };
+ circularA.abc = circularA;
+ circularB.abc = circularB;
+ equals(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object (ambigous test)");
+
+ circularA.def = 1;
+ circularB.def = 1;
+ equals(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object (ambigous test)");
+
+ circularA.def = 1;
+ circularB.def = 0;
+ equals(QUnit.equiv(circularA, circularB), false, "Should not repeat test on object (unambigous test)");
+});
+
+test('array with references to self wont loop', function(){
+ var circularA = [],
+ circularB = [];
+ circularA.push(circularA);
+ circularB.push(circularB);
+ equals(QUnit.equiv(circularA, circularB), true, "Should not repeat test on array (ambigous test)");
+
+ circularA.push( 'abc' );
+ circularB.push( 'abc' );
+ equals(QUnit.equiv(circularA, circularB), true, "Should not repeat test on array (ambigous test)");
+
+ circularA.push( 'hello' );
+ circularB.push( 'goodbye' );
+ equals(QUnit.equiv(circularA, circularB), false, "Should not repeat test on array (unambigous test)");
+});
+
+test('mixed object/array with references to self wont loop', function(){
+ var circularA = [{abc:null}],
+ circularB = [{abc:null}];
+ circularA[0].abc = circularA;
+ circularB[0].abc = circularB;
+
+ circularA.push(circularA);
+ circularB.push(circularB);
+ equals(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object/array (ambigous test)");
+
+ circularA[0].def = 1;
+ circularB[0].def = 1;
+ equals(QUnit.equiv(circularA, circularB), true, "Should not repeat test on object/array (ambigous test)");
+
+ circularA[0].def = 1;
+ circularB[0].def = 0;
+ equals(QUnit.equiv(circularA, circularB), false, "Should not repeat test on object/array (unambigous test)");
+});
+
+
+test("Test that must be done at the end because they extend some primitive's prototype", function() {
+ // Try that a function looks like our regular expression.
+ // This tests if we check that a and b are really both instance of RegExp
+ Function.prototype.global = true;
+ Function.prototype.multiline = true;
+ Function.prototype.ignoreCase = false;
+ Function.prototype.source = "my regex";
+ var re = /my regex/gm;
+ equals(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"
+ equals(QUnit.equiv(function () {}, re), false, "Same conversely, but ensures that function and regexp are distinct because their constructor are different");
+});
+
diff --git a/addon/js_upload/file-uploader/tests/qunit/test/test.js b/addon/js_upload/file-uploader/tests/qunit/test/test.js
new file mode 100644
index 000000000..8eb5213d1
--- /dev/null
+++ b/addon/js_upload/file-uploader/tests/qunit/test/test.js
@@ -0,0 +1,171 @@
+test("module without setup/teardown (default)", function() {
+ expect(1);
+ ok(true);
+});
+
+test("expect in test", 3, function() {
+ ok(true);
+ ok(true);
+ ok(true);
+});
+
+test("expect in test", 1, function() {
+ ok(true);
+});
+
+module("setup test", {
+ setup: function() {
+ ok(true);
+ }
+});
+
+test("module with setup", function() {
+ expect(2);
+ ok(true);
+});
+
+var state;
+
+module("setup/teardown test", {
+ setup: function() {
+ state = true;
+ ok(true);
+ },
+ teardown: function() {
+ ok(true);
+ }
+});
+
+test("module with setup/teardown", function() {
+ expect(3);
+ ok(true);
+});
+
+module("setup/teardown test 2");
+
+test("module without setup/teardown", function() {
+ expect(1);
+ ok(true);
+});
+
+if (typeof setTimeout !== 'undefined') {
+state = 'fail';
+
+module("teardown and stop", {
+ teardown: function() {
+ equals(state, "done", "Test teardown.");
+ }
+});
+
+test("teardown must be called after test ended", function() {
+ expect(1);
+ stop();
+ setTimeout(function() {
+ state = "done";
+ start();
+ }, 13);
+});
+} // end setTimeout tests
+
+if (typeof asyncTest !== 'undefined') {
+module("asyncTest");
+
+asyncTest("asyncTest", function() {
+ expect(2);
+ ok(true);
+ setTimeout(function() {
+ state = "done";
+ ok(true);
+ start();
+ }, 13);
+});
+
+asyncTest("asyncTest", 2, function() {
+ ok(true);
+ setTimeout(function() {
+ state = "done";
+ ok(true);
+ start();
+ }, 13);
+});
+} // end asyncTest tests
+
+module("save scope", {
+ setup: function() {
+ this.foo = "bar";
+ },
+ teardown: function() {
+ same(this.foo, "bar");
+ }
+});
+test("scope check", function() {
+ expect(2);
+ same(this.foo, "bar");
+});
+
+module("simple testEnvironment setup", {
+ foo: "bar",
+ bugid: "#5311" // example of meta-data
+});
+test("scope check", function() {
+ same(this.foo, "bar");
+});
+test("modify testEnvironment",function() {
+ this.foo="hamster";
+});
+test("testEnvironment reset for next test",function() {
+ same(this.foo, "bar");
+});
+
+module("testEnvironment with object", {
+ options:{
+ recipe:"soup",
+ ingredients:["hamster","onions"]
+ }
+});
+test("scope check", function() {
+ same(this.options, {recipe:"soup",ingredients:["hamster","onions"]}) ;
+});
+test("modify testEnvironment",function() {
+ // since we do a shallow copy, the testEnvironment can be modified
+ this.options.ingredients.push("carrots");
+});
+test("testEnvironment reset for next test",function() {
+ same(this.options, {recipe:"soup",ingredients:["hamster","onions","carrots"]}, "Is this a bug or a feature? Could do a deep copy") ;
+});
+
+
+module("testEnvironment tests");
+
+function makeurl() {
+ var testEnv = QUnit.current_testEnvironment;
+ var url = testEnv.url || 'http://example.com/search';
+ var q = testEnv.q || 'a search test';
+ return url + '?q='+encodeURIComponent(q);
+}
+
+test("makeurl working",function() {
+ equals( QUnit.current_testEnvironment, this, 'The current testEnvironment is global');
+ equals( makeurl(), 'http://example.com/search?q=a%20search%20test', 'makeurl returns a default url if nothing specified in the testEnvironment');
+});
+
+module("testEnvironment with makeurl settings",{
+ url:'http://google.com/',
+ q:'another_search_test'
+});
+test("makeurl working with settings from testEnvironment",function() {
+ equals( makeurl(), 'http://google.com/?q=another_search_test', 'rather than passing arguments, we use test metadata to form the url');
+});
+test("each test can extend the module testEnvironment", {
+ q:'hamstersoup'
+}, function() {
+ equals( makeurl(), 'http://google.com/?q=hamstersoup', 'url from module, q from test');
+});
+
+module("jsDump");
+test("jsDump output", function() {
+ equals( QUnit.jsDump.parse([1, 2]), "[ 1, 2 ]" );
+ equals( QUnit.jsDump.parse({top: 5, left: 0}), "{ \"top\": 5, \"left\": 0 }" );
+ equals( QUnit.jsDump.parse(document.getElementById("qunit-header")), "<h1 id=\"qunit-header\"></h1>" );
+ equals( QUnit.jsDump.parse(document.getElementsByTagName("h1")), "[ <h1 id=\"qunit-header\"></h1> ]" );
+})