From b7f7ba06b9c4cee6e284c9ea966ed526db07af26 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 30 Nov 2013 15:17:53 -0600 Subject: [PATCH] Merge qunit clib and extras. --- test/asset/qunit-extras.js | 198 ------ test/backbone.html | 4 +- test/index.html | 2 +- test/test.js | 6 +- test/underscore.html | 2 +- vendor/qunit-clib/qunit-clib.js | 387 ------------ .../{qunit-clib => qunit-extras}/LICENSE.txt | 0 vendor/qunit-extras/qunit-extras.js | 563 ++++++++++++++++++ 8 files changed, 568 insertions(+), 594 deletions(-) delete mode 100644 test/asset/qunit-extras.js delete mode 100644 vendor/qunit-clib/qunit-clib.js rename vendor/{qunit-clib => qunit-extras}/LICENSE.txt (100%) create mode 100644 vendor/qunit-extras/qunit-extras.js diff --git a/test/asset/qunit-extras.js b/test/asset/qunit-extras.js deleted file mode 100644 index 3f54a8939..000000000 --- a/test/asset/qunit-extras.js +++ /dev/null @@ -1,198 +0,0 @@ -;(function(root, undefined) { - 'use strict'; - - /** Native method shortcut */ - var unshift = Array.prototype.unshift; - - /** Used to match HTML entities */ - var reEscapedHtml = /(&|<|>|"|')/g; - - /** Used to match parts of the assert message */ - var reDied = /^Died on test #\d+/, - reExpected = /Expected: *<\/th>
([\s\S]*?)<\/pre>/,
-      reMessage = /^([\s\S]*?)<\/span>/;
-
-  /** Used to convert HTML entities to characters */
-  var htmlUnescapes = {
-    '&': '&',
-    '<': '<',
-    '>': '>',
-    '"': '"',
-    ''': "'"
-  };
-
-  /** Detect free variable `exports` */
-  var freeExports = typeof exports == 'object' && exports;
-
-  /** Detect free variable `global`, from Node.js or Browserified code, and use it as `root` */
-  var freeGlobal = typeof global == 'object' && global;
-  if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
-    root = freeGlobal;
-  }
-
-  /*--------------------------------------------------------------------------*/
-
-  /**
-   * Checks if a given value is present in an array using strict equality
-   * for comparisons, i.e. `===`.
-   *
-   * @oruvate
-   * @param {Array} array The array to iterate over.
-   * @param {*} target The value to check for.
-   * @returns {boolean} Returns `true` if the `target` element is found, else `false`.
-   */
-  function contains(array, value) {
-    var index = -1,
-        length = array ? array.length : 0;
-
-    while (++index < length) {
-      if (array[index] === value) {
-        return true;
-      }
-    }
-    return false;
-  }
-
-  /**
-   * Resolves the value of `property` on `object`. If `object` is falsey then
-   * `undefined` is returned.
-   *
-   * @private
-   * @param {Object} object The object to inspect.
-   * @param {string} property The property to get the value of.
-   * @returns {*} Returns the resolved value.
-   */
-  function result(object, property) {
-    return object ? object[property] : undefined;
-  }
-
-  /**
-   * Converts the HTML entities `&`, `<`, `>`, `"`, and `'`
-   * in `string` to their corresponding characters.
-   *
-   * @private
-   * @param {string} string The string to unescape.
-   * @returns {string} Returns the unescaped string.
-   */
-  function unescape(string) {
-    return string == null ? '' : String(string).replace(reEscapedHtml, unescapeHtmlChar);
-  }
-
-  /**
-   * Used by `unescape` to convert HTML entities to characters.
-   *
-   * @private
-   * @param {string} match The matched character to unescape.
-   * @returns {string} Returns the unescaped character.
-   */
-  function unescapeHtmlChar(match) {
-    return htmlUnescapes[match];
-  }
-
-  /*--------------------------------------------------------------------------*/
-
-  /**
-   * Installs the QUnit additions on the given `context` object.
-   *
-   * @memberOf exports
-   * @param {Object} context The context object.
-   */
-  function runInContext(context) {
-    // exit early if no `context` is provided or if `QUnit` does not exist
-    if (!context || !context.QUnit) {
-      return;
-    }
-
-    /** Shorten `context.QUnit.QUnit` to `context.QUnit` */
-    var QUnit = context.QUnit = context.QUnit.QUnit || context.QUnit;
-
-    /** The number of retries async tests have to succeed */
-    QUnit.config.asyncRetries = 0;
-
-    /** An object of excused tests and assertions */
-    QUnit.config.excused = {};
-
-    /**
-     * A callback triggered at the start of every test.
-     *
-     * @memberOf QUnit
-     * @param {Object} details An object with `module` and `name` properties.
-     */
-    QUnit.testStart(function(details) {
-      var excused = QUnit.config.excused || {},
-          excusedTests = excused[details.module],
-          excusedAsserts = excusedTests && excusedTests[details.name];
-
-      var test = QUnit.config.current,
-          finish = test.finish;
-
-      // allow async tests to retry
-      if (test.async && !test.retries) {
-        test.retries = 0;
-        test.finish = function() {
-          var asserts = this.assertions,
-              index = -1,
-              length = asserts.length,
-              queue = QUnit.config.queue;
-
-          while (++index < length) {
-            var assert = asserts[index];
-            if (!assert.result && this.retries < QUnit.config.asyncRetries) {
-              this.retries++;
-              asserts.length = 0;
-
-              var oldLength = queue.length;
-              this.queue();
-              unshift.apply(queue, queue.splice(oldLength, queue.length - oldLength));
-              return;
-            }
-          }
-          finish.call(this);
-        };
-      }
-      // nothing to excuse
-      if (!excusedAsserts) {
-        return;
-      }
-      // excuse the entire test
-      if (excusedAsserts === true) {
-        test.async = false;
-        test.callback = function() {};
-        test.expected = 0;
-        return;
-      }
-      // excuse specific assertions
-      test.finish = function() {
-        var asserts = this.assertions,
-            index = -1,
-            length = asserts.length;
-
-        while (++index < length) {
-          var assert = asserts[index],
-              message = unescape(result(reMessage.exec(assert.message), 1)),
-              died = result(reDied.exec(message), 0),
-              expected = unescape(result(reExpected.exec(assert.message), 1));
-
-          if ((message && contains(excusedAsserts, message)) ||
-              (died && contains(excusedAsserts, died)) ||
-              (expected && (
-                contains(excusedAsserts, expected) ||
-                contains(excusedAsserts, expected.replace(/\s+/g, ''))
-              ))) {
-            assert.result = true;
-          }
-        }
-        finish.call(this);
-      };
-    });
-  }
-
-  /*--------------------------------------------------------------------------*/
-
-  // expose QUnit extras
-  if (freeExports && !freeExports.nodeType) {
-    freeExports.runInContext = runInContext;
-  } else {
-    runInContext(root);
-  }
-}(this));
diff --git a/test/backbone.html b/test/backbone.html
index e3ebac16a..4f7b03aa8 100644
--- a/test/backbone.html
+++ b/test/backbone.html
@@ -18,11 +18,11 @@
 				

Test

+ + - - + -
diff --git a/test/test.js b/test/test.js index ae6bcd185..ca6946670 100644 --- a/test/test.js +++ b/test/test.js @@ -83,7 +83,7 @@ root.addEventListener || (root.addEventListener = noop), root.setTimeout || (root.setTimeout = noop), root.QUnit = load('../vendor/qunit/qunit/qunit.js') || root.QUnit, - (load('../vendor/qunit-clib/qunit-clib.js') || { 'runInContext': noop }).runInContext(root), + (load('../vendor/qunit-extras/qunit-extras.js') || { 'runInContext': noop }).runInContext(root), addEventListener === noop && delete root.addEventListener, root.QUnit ); @@ -91,10 +91,6 @@ /*--------------------------------------------------------------------------*/ - // load QUnit extras - if (load) { - (load('./asset/qunit-extras.js') || { 'runInContext': noop }).runInContext(root); - } // log params passed to `test.js` if (params) { console.log('test.js invoked with arguments: ' + JSON.stringify(slice.call(params))); diff --git a/test/underscore.html b/test/underscore.html index e815b7aca..e492877ed 100644 --- a/test/underscore.html +++ b/test/underscore.html @@ -20,9 +20,9 @@ + -