You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/06/13 19:09:08 UTC
[15/19] [CB-606] Added create script for unix and windows
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/assert.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/assert.js b/bin/node_modules/nodeunit/lib/assert.js
new file mode 100644
index 0000000..8d9e0e3
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/assert.js
@@ -0,0 +1,316 @@
+/**
+ * This file is based on the node.js assert module, but with some small
+ * changes for browser-compatibility
+ * THIS FILE SHOULD BE BROWSER-COMPATIBLE JS!
+ */
+
+
+/**
+ * Added for browser compatibility
+ */
+
+var _keys = function(obj){
+ if(Object.keys) return Object.keys(obj);
+ var keys = [];
+ for(var k in obj){
+ if(obj.hasOwnProperty(k)) keys.push(k);
+ }
+ return keys;
+};
+
+
+
+// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
+//
+// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
+//
+// Originally from narwhal.js (http://narwhaljs.org)
+// Copyright (c) 2009 Thomas Robinson <280north.com>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the 'Software'), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+var pSlice = Array.prototype.slice;
+
+// 1. The assert module provides functions that throw
+// AssertionError's when particular conditions are not met. The
+// assert module must conform to the following interface.
+
+var assert = exports;
+
+// 2. The AssertionError is defined in assert.
+// new assert.AssertionError({message: message, actual: actual, expected: expected})
+
+assert.AssertionError = function AssertionError (options) {
+ this.name = "AssertionError";
+ this.message = options.message;
+ this.actual = options.actual;
+ this.expected = options.expected;
+ this.operator = options.operator;
+ var stackStartFunction = options.stackStartFunction || fail;
+
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, stackStartFunction);
+ }
+};
+// code from util.inherits in node
+assert.AssertionError.super_ = Error;
+
+
+// EDITED FOR BROWSER COMPATIBILITY: replaced Object.create call
+// TODO: test what effect this may have
+var ctor = function () { this.constructor = assert.AssertionError; };
+ctor.prototype = Error.prototype;
+assert.AssertionError.prototype = new ctor();
+
+
+assert.AssertionError.prototype.toString = function() {
+ if (this.message) {
+ return [this.name+":", this.message].join(' ');
+ } else {
+ return [ this.name+":"
+ , JSON.stringify(this.expected )
+ , this.operator
+ , JSON.stringify(this.actual)
+ ].join(" ");
+ }
+};
+
+// assert.AssertionError instanceof Error
+
+assert.AssertionError.__proto__ = Error.prototype;
+
+// At present only the three keys mentioned above are used and
+// understood by the spec. Implementations or sub modules can pass
+// other keys to the AssertionError's constructor - they will be
+// ignored.
+
+// 3. All of the following functions must throw an AssertionError
+// when a corresponding condition is not met, with a message that
+// may be undefined if not provided. All assertion methods provide
+// both the actual and expected values to the assertion error for
+// display purposes.
+
+function fail(actual, expected, message, operator, stackStartFunction) {
+ throw new assert.AssertionError({
+ message: message,
+ actual: actual,
+ expected: expected,
+ operator: operator,
+ stackStartFunction: stackStartFunction
+ });
+}
+
+// EXTENSION! allows for well behaved errors defined elsewhere.
+assert.fail = fail;
+
+// 4. Pure assertion tests whether a value is truthy, as determined
+// by !!guard.
+// assert.ok(guard, message_opt);
+// This statement is equivalent to assert.equal(true, guard,
+// message_opt);. To test strictly for the value true, use
+// assert.strictEqual(true, guard, message_opt);.
+
+assert.ok = function ok(value, message) {
+ if (!!!value) fail(value, true, message, "==", assert.ok);
+};
+
+// 5. The equality assertion tests shallow, coercive equality with
+// ==.
+// assert.equal(actual, expected, message_opt);
+
+assert.equal = function equal(actual, expected, message) {
+ if (actual != expected) fail(actual, expected, message, "==", assert.equal);
+};
+
+// 6. The non-equality assertion tests for whether two objects are not equal
+// with != assert.notEqual(actual, expected, message_opt);
+
+assert.notEqual = function notEqual(actual, expected, message) {
+ if (actual == expected) {
+ fail(actual, expected, message, "!=", assert.notEqual);
+ }
+};
+
+// 7. The equivalence assertion tests a deep equality relation.
+// assert.deepEqual(actual, expected, message_opt);
+
+assert.deepEqual = function deepEqual(actual, expected, message) {
+ if (!_deepEqual(actual, expected)) {
+ fail(actual, expected, message, "deepEqual", assert.deepEqual);
+ }
+};
+
+function _deepEqual(actual, expected) {
+ // 7.1. All identical values are equivalent, as determined by ===.
+ if (actual === expected) {
+ return true;
+ // 7.2. If the expected value is a Date object, the actual value is
+ // equivalent if it is also a Date object that refers to the same time.
+ } else if (actual instanceof Date && expected instanceof Date) {
+ return actual.getTime() === expected.getTime();
+
+ // 7.3. Other pairs that do not both pass typeof value == "object",
+ // equivalence is determined by ==.
+ } else if (typeof actual != 'object' && typeof expected != 'object') {
+ return actual == expected;
+
+ // 7.4. For all other Object pairs, including Array objects, equivalence is
+ // determined by having the same number of owned properties (as verified
+ // with Object.prototype.hasOwnProperty.call), the same set of keys
+ // (although not necessarily the same order), equivalent values for every
+ // corresponding key, and an identical "prototype" property. Note: this
+ // accounts for both named and indexed properties on Arrays.
+ } else {
+ return objEquiv(actual, expected);
+ }
+}
+
+function isUndefinedOrNull (value) {
+ return value === null || value === undefined;
+}
+
+function isArguments (object) {
+ return Object.prototype.toString.call(object) == '[object Arguments]';
+}
+
+function objEquiv (a, b) {
+ if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
+ return false;
+ // an identical "prototype" property.
+ if (a.prototype !== b.prototype) return false;
+ //~~~I've managed to break Object.keys through screwy arguments passing.
+ // Converting to array solves the problem.
+ if (isArguments(a)) {
+ if (!isArguments(b)) {
+ return false;
+ }
+ a = pSlice.call(a);
+ b = pSlice.call(b);
+ return _deepEqual(a, b);
+ }
+ try{
+ var ka = _keys(a),
+ kb = _keys(b),
+ key, i;
+ } catch (e) {//happens when one is a string literal and the other isn't
+ return false;
+ }
+ // having the same number of owned properties (keys incorporates hasOwnProperty)
+ if (ka.length != kb.length)
+ return false;
+ //the same set of keys (although not necessarily the same order),
+ ka.sort();
+ kb.sort();
+ //~~~cheap key test
+ for (i = ka.length - 1; i >= 0; i--) {
+ if (ka[i] != kb[i])
+ return false;
+ }
+ //equivalent values for every corresponding key, and
+ //~~~possibly expensive deep test
+ for (i = ka.length - 1; i >= 0; i--) {
+ key = ka[i];
+ if (!_deepEqual(a[key], b[key] ))
+ return false;
+ }
+ return true;
+}
+
+// 8. The non-equivalence assertion tests for any deep inequality.
+// assert.notDeepEqual(actual, expected, message_opt);
+
+assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
+ if (_deepEqual(actual, expected)) {
+ fail(actual, expected, message, "notDeepEqual", assert.notDeepEqual);
+ }
+};
+
+// 9. The strict equality assertion tests strict equality, as determined by ===.
+// assert.strictEqual(actual, expected, message_opt);
+
+assert.strictEqual = function strictEqual(actual, expected, message) {
+ if (actual !== expected) {
+ fail(actual, expected, message, "===", assert.strictEqual);
+ }
+};
+
+// 10. The strict non-equality assertion tests for strict inequality, as determined by !==.
+// assert.notStrictEqual(actual, expected, message_opt);
+
+assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
+ if (actual === expected) {
+ fail(actual, expected, message, "!==", assert.notStrictEqual);
+ }
+};
+
+function _throws (shouldThrow, block, err, message) {
+ var exception = null,
+ threw = false,
+ typematters = true;
+
+ message = message || "";
+
+ //handle optional arguments
+ if (arguments.length == 3) {
+ if (typeof(err) == "string") {
+ message = err;
+ typematters = false;
+ }
+ } else if (arguments.length == 2) {
+ typematters = false;
+ }
+
+ try {
+ block();
+ } catch (e) {
+ threw = true;
+ exception = e;
+ }
+
+ if (shouldThrow && !threw) {
+ fail( "Missing expected exception"
+ + (err && err.name ? " ("+err.name+")." : '.')
+ + (message ? " " + message : "")
+ );
+ }
+ if (!shouldThrow && threw && typematters && exception instanceof err) {
+ fail( "Got unwanted exception"
+ + (err && err.name ? " ("+err.name+")." : '.')
+ + (message ? " " + message : "")
+ );
+ }
+ if ((shouldThrow && threw && typematters && !(exception instanceof err)) ||
+ (!shouldThrow && threw)) {
+ throw exception;
+ }
+};
+
+// 11. Expected to throw an error:
+// assert.throws(block, Error_opt, message_opt);
+
+assert.throws = function(block, /*optional*/error, /*optional*/message) {
+ _throws.apply(this, [true].concat(pSlice.call(arguments)));
+};
+
+// EXTENSION! This is annoying to write outside this module.
+assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
+ _throws.apply(this, [false].concat(pSlice.call(arguments)));
+};
+
+assert.ifError = function (err) { if (err) {throw err;}};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/core.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/core.js b/bin/node_modules/nodeunit/lib/core.js
new file mode 100644
index 0000000..5be8e8f
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/core.js
@@ -0,0 +1,260 @@
+/*!
+ * Nodeunit
+ * Copyright (c) 2010 Caolan McMahon
+ * MIT Licensed
+ *
+ * THIS FILE SHOULD BE BROWSER-COMPATIBLE JS!
+ * You can use @REMOVE_LINE_FOR_BROWSER to remove code from the browser build.
+ * Only code on that line will be removed, its mostly to avoid requiring code
+ * that is node specific
+ */
+
+/**
+ * Module dependencies
+ */
+
+var async = require('../deps/async'), //@REMOVE_LINE_FOR_BROWSER
+ types = require('./types'); //@REMOVE_LINE_FOR_BROWSER
+
+
+/**
+ * Added for browser compatibility
+ */
+
+var _keys = function(obj){
+ if(Object.keys) return Object.keys(obj);
+ var keys = [];
+ for(var k in obj){
+ if(obj.hasOwnProperty(k)) keys.push(k);
+ }
+ return keys;
+};
+
+
+var _copy = function(obj){
+ var nobj = Object();
+ var keys = _keys(obj);
+ for (var i = 0; i < keys.length; i++){
+ nobj[keys[i]] = obj[keys[i]];
+ }
+ return nobj;
+}
+
+
+/**
+ * Runs a test function (fn) from a loaded module. After the test function
+ * calls test.done(), the callback is executed with an assertionList as its
+ * second argument.
+ *
+ * @param {String} name
+ * @param {Function} fn
+ * @param {Object} opt
+ * @param {Function} callback
+ * @api public
+ */
+
+exports.runTest = function (name, fn, opt, callback) {
+ var options = types.options(opt);
+
+ options.testStart(name);
+ var start = new Date().getTime();
+ var test = types.test(name, start, options, callback);
+
+ try {
+ fn(test);
+ }
+ catch (e) {
+ test.done(e);
+ }
+};
+
+/**
+ * Takes an object containing test functions or other test suites as properties
+ * and runs each in series. After all tests have completed, the callback is
+ * called with a list of all assertions as the second argument.
+ *
+ * If a name is passed to this function it is prepended to all test and suite
+ * names that run within it.
+ *
+ * @param {String} name
+ * @param {Object} suite
+ * @param {Object} opt
+ * @param {Function} callback
+ * @api public
+ */
+
+exports.runSuite = function (name, suite, opt, callback) {
+ var keys = _keys(suite);
+
+ async.concatSeries(keys, function (k, cb) {
+ var prop = suite[k], _name;
+
+ _name = name ? [].concat(name, k) : [k];
+
+ _name.toString = function () {
+ // fallback for old one
+ return this.join(' - ');
+ };
+
+ if (typeof prop === 'function') {
+ if (!opt.testspec || _name.indexOf(opt.testspec) != -1){
+ if (opt.moduleStart)
+ opt.moduleStart();
+ exports.runTest(_name, suite[k], opt, cb);
+ } else
+ return cb();
+ }
+ else {
+ exports.runSuite(_name, suite[k], opt, cb);
+ }
+ }, callback);
+};
+
+/**
+ * Run each exported test function or test suite from a loaded module.
+ *
+ * @param {String} name
+ * @param {Object} mod
+ * @param {Object} opt
+ * @param {Function} callback
+ * @api public
+ */
+
+exports.runModule = function (name, mod, opt, callback) {
+ var options = _copy(types.options(opt));
+
+ var _run = false;
+ var _moduleStart = options.moduleStart;
+ function run_once(){
+ if (!_run){
+ _run = true;
+ _moduleStart(name);
+ }
+ }
+ options.moduleStart = run_once;
+
+ var start = new Date().getTime();
+
+ exports.runSuite(null, mod, options, function (err, a_list) {
+ var end = new Date().getTime();
+ var assertion_list = types.assertionList(a_list, end - start);
+ options.moduleDone(name, assertion_list);
+ callback(null, a_list);
+ });
+};
+
+/**
+ * Treats an object literal as a list of modules keyed by name. Runs each
+ * module and finished with calling 'done'. You can think of this as a browser
+ * safe alternative to runFiles in the nodeunit module.
+ *
+ * @param {Object} modules
+ * @param {Object} opt
+ * @api public
+ */
+
+// TODO: add proper unit tests for this function
+exports.runModules = function (modules, opt) {
+ var all_assertions = [];
+ var options = types.options(opt);
+ var start = new Date().getTime();
+
+ async.concatSeries(_keys(modules), function (k, cb) {
+ exports.runModule(k, modules[k], options, cb);
+ },
+ function (err, all_assertions) {
+ var end = new Date().getTime();
+ options.done(types.assertionList(all_assertions, end - start));
+ });
+};
+
+
+/**
+ * Wraps a test function with setUp and tearDown functions.
+ * Used by testCase.
+ *
+ * @param {Function} setUp
+ * @param {Function} tearDown
+ * @param {Function} fn
+ * @api private
+ */
+
+var wrapTest = function (setUp, tearDown, fn) {
+ return function (test) {
+ var context = {};
+ if (tearDown) {
+ var done = test.done;
+ test.done = function (err) {
+ try {
+ tearDown.call(context, function (err2) {
+ if (err && err2) {
+ test._assertion_list.push(
+ types.assertion({error: err})
+ );
+ return done(err2);
+ }
+ done(err || err2);
+ });
+ }
+ catch (e) {
+ done(e);
+ }
+ };
+ }
+ if (setUp) {
+ setUp.call(context, function (err) {
+ if (err) {
+ return test.done(err);
+ }
+ fn.call(context, test);
+ });
+ }
+ else {
+ fn.call(context, test);
+ }
+ }
+};
+
+
+/**
+ * Wraps a group of tests with setUp and tearDown functions.
+ * Used by testCase.
+ *
+ * @param {Function} setUp
+ * @param {Function} tearDown
+ * @param {Object} group
+ * @api private
+ */
+
+var wrapGroup = function (setUp, tearDown, group) {
+ var tests = {};
+ var keys = _keys(group);
+ for (var i=0; i<keys.length; i++) {
+ var k = keys[i];
+ if (typeof group[k] === 'function') {
+ tests[k] = wrapTest(setUp, tearDown, group[k]);
+ }
+ else if (typeof group[k] === 'object') {
+ tests[k] = wrapGroup(setUp, tearDown, group[k]);
+ }
+ }
+ return tests;
+}
+
+
+/**
+ * Utility for wrapping a suite of test functions with setUp and tearDown
+ * functions.
+ *
+ * @param {Object} suite
+ * @return {Object}
+ * @api public
+ */
+
+exports.testCase = function (suite) {
+ var setUp = suite.setUp;
+ var tearDown = suite.tearDown;
+ delete suite.setUp;
+ delete suite.tearDown;
+ return wrapGroup(setUp, tearDown, suite);
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/nodeunit.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/nodeunit.js b/bin/node_modules/nodeunit/lib/nodeunit.js
new file mode 100644
index 0000000..ac3794b
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/nodeunit.js
@@ -0,0 +1,82 @@
+/*!
+ * Nodeunit
+ * Copyright (c) 2010 Caolan McMahon
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies
+ */
+
+var async = require('../deps/async'),
+ types = require('./types'),
+ utils = require('./utils'),
+ core = require('./core'),
+ reporters = require('./reporters'),
+ assert = require('./assert'),
+ path = require('path');
+
+
+/**
+ * Export sub-modules.
+ */
+
+exports.types = types;
+exports.utils = utils;
+exports.reporters = reporters;
+exports.assert = assert;
+
+// backwards compatibility
+exports.testrunner = {
+ run: function () {
+ console.log(
+ 'WARNING: nodeunit.testrunner is going to be deprecated, please ' +
+ 'use nodeunit.reporters.default instead!'
+ );
+ return reporters['default'].run.apply(this, arguments);
+ }
+};
+
+
+/**
+ * Export all core functions
+ */
+
+for (var k in core) {
+ exports[k] = core[k];
+};
+
+
+/**
+ * Load modules from paths array and run all exported tests in series. If a path
+ * is a directory, load all supported file types inside it as modules. This only
+ * reads 1 level deep in the directory and does not recurse through
+ * sub-directories.
+ *
+ * @param {Array} paths
+ * @param {Object} opt
+ * @api public
+ */
+
+exports.runFiles = function (paths, opt) {
+ var all_assertions = [];
+ var options = types.options(opt);
+ var start = new Date().getTime();
+
+ if (!paths.length) {
+ return options.done(types.assertionList(all_assertions));
+ }
+
+ utils.modulePaths(paths, function (err, files) {
+ if (err) throw err;
+ async.concatSeries(files, function (file, cb) {
+ var name = path.basename(file);
+ exports.runModule(name, require(file), options, cb);
+ },
+ function (err, all_assertions) {
+ var end = new Date().getTime();
+ options.done(types.assertionList(all_assertions, end - start));
+ });
+ });
+
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/reporters/browser.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/reporters/browser.js b/bin/node_modules/nodeunit/lib/reporters/browser.js
new file mode 100644
index 0000000..a169406
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/reporters/browser.js
@@ -0,0 +1,119 @@
+/*!
+ * Nodeunit
+ * Copyright (c) 2010 Caolan McMahon
+ * MIT Licensed
+ *
+ * THIS FILE SHOULD BE BROWSER-COMPATIBLE JS!
+ * You can use @REMOVE_LINE_FOR_BROWSER to remove code from the browser build.
+ * Only code on that line will be removed, its mostly to avoid requiring code
+ * that is node specific
+ */
+
+
+/**
+ * NOTE: this test runner is not listed in index.js because it cannot be
+ * used with the command-line tool, only inside the browser.
+ */
+
+
+/**
+ * Reporter info string
+ */
+
+exports.info = "Browser-based test reporter";
+
+
+/**
+ * Run all tests within each module, reporting the results
+ *
+ * @param {Array} files
+ * @api public
+ */
+
+exports.run = function (modules, options) {
+ var start = new Date().getTime();
+
+ function setText(el, txt) {
+ if ('innerText' in el) {
+ el.innerText = txt;
+ }
+ else if ('textContent' in el){
+ el.textContent = txt;
+ }
+ }
+
+ function getOrCreate(tag, id) {
+ var el = document.getElementById(id);
+ if (!el) {
+ el = document.createElement(tag);
+ el.id = id;
+ document.body.appendChild(el);
+ }
+ return el;
+ };
+
+ var header = getOrCreate('h1', 'nodeunit-header');
+ var banner = getOrCreate('h2', 'nodeunit-banner');
+ var userAgent = getOrCreate('h2', 'nodeunit-userAgent');
+ var tests = getOrCreate('ol', 'nodeunit-tests');
+ var result = getOrCreate('p', 'nodeunit-testresult');
+
+ setText(userAgent, navigator.userAgent);
+
+ nodeunit.runModules(modules, {
+ moduleStart: function (name) {
+ /*var mheading = document.createElement('h2');
+ mheading.innerText = name;
+ results.appendChild(mheading);
+ module = document.createElement('ol');
+ results.appendChild(module);*/
+ },
+ testDone: function (name, assertions) {
+ var test = document.createElement('li');
+ var strong = document.createElement('strong');
+ strong.innerHTML = name + ' <b style="color: black;">(' +
+ '<b class="fail">' + assertions.failures() + '</b>, ' +
+ '<b class="pass">' + assertions.passes() + '</b>, ' +
+ assertions.length +
+ ')</b>';
+ test.className = assertions.failures() ? 'fail': 'pass';
+ test.appendChild(strong);
+
+ var aList = document.createElement('ol');
+ aList.style.display = 'none';
+ test.onclick = function () {
+ var d = aList.style.display;
+ aList.style.display = (d == 'none') ? 'block': 'none';
+ };
+ for (var i=0; i<assertions.length; i++) {
+ var li = document.createElement('li');
+ var a = assertions[i];
+ if (a.failed()) {
+ li.innerHTML = (a.message || a.method || 'no message') +
+ '<pre>' + (a.error.stack || a.error) + '</pre>';
+ li.className = 'fail';
+ }
+ else {
+ li.innerHTML = a.message || a.method || 'no message';
+ li.className = 'pass';
+ }
+ aList.appendChild(li);
+ }
+ test.appendChild(aList);
+ tests.appendChild(test);
+ },
+ done: function (assertions) {
+ var end = new Date().getTime();
+ var duration = end - start;
+
+ var failures = assertions.failures();
+ banner.className = failures ? 'fail': 'pass';
+
+ result.innerHTML = 'Tests completed in ' + duration +
+ ' milliseconds.<br/><span class="passed">' +
+ assertions.passes() + '</span> assertions of ' +
+ '<span class="all">' + assertions.length + '<span> passed, ' +
+ assertions.failures() + ' failed.';
+ }
+ });
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/reporters/default.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/reporters/default.js b/bin/node_modules/nodeunit/lib/reporters/default.js
new file mode 100644
index 0000000..279f560
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/reporters/default.js
@@ -0,0 +1,123 @@
+/*!
+ * Nodeunit
+ * Copyright (c) 2010 Caolan McMahon
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies
+ */
+
+var nodeunit = require('../nodeunit'),
+ utils = require('../utils'),
+ fs = require('fs'),
+ track = require('../track'),
+ path = require('path');
+ AssertionError = require('../assert').AssertionError;
+
+/**
+ * Reporter info string
+ */
+
+exports.info = "Default tests reporter";
+
+
+/**
+ * Run all tests within each module, reporting the results to the command-line.
+ *
+ * @param {Array} files
+ * @api public
+ */
+
+exports.run = function (files, options) {
+
+ if (!options) {
+ // load default options
+ var content = fs.readFileSync(
+ __dirname + '/../../bin/nodeunit.json', 'utf8'
+ );
+ options = JSON.parse(content);
+ }
+
+ var error = function (str) {
+ return options.error_prefix + str + options.error_suffix;
+ };
+ var ok = function (str) {
+ return options.ok_prefix + str + options.ok_suffix;
+ };
+ var bold = function (str) {
+ return options.bold_prefix + str + options.bold_suffix;
+ };
+ var assertion_message = function (str) {
+ return options.assertion_prefix + str + options.assertion_suffix;
+ };
+
+ var start = new Date().getTime();
+ var paths = files.map(function (p) {
+ return path.join(process.cwd(), p);
+ });
+ var tracker = track.createTracker(function (tracker) {
+ if (tracker.unfinished()) {
+ console.log('');
+ console.log(error(bold(
+ 'FAILURES: Undone tests (or their setups/teardowns): '
+ )));
+ var names = tracker.names();
+ for (var i = 0; i < names.length; i += 1) {
+ console.log('- ' + names[i]);
+ }
+ console.log('');
+ console.log('To fix this, make sure all tests call test.done()');
+ process.reallyExit(tracker.unfinished());
+ }
+ });
+
+ nodeunit.runFiles(paths, {
+ testspec: options.testspec,
+ moduleStart: function (name) {
+ console.log('\n' + bold(name));
+ },
+ testDone: function (name, assertions) {
+ tracker.remove(name);
+
+ if (!assertions.failures()) {
+ console.log('✔ ' + name);
+ }
+ else {
+ console.log(error('✖ ' + name) + '\n');
+ assertions.forEach(function (a) {
+ if (a.failed()) {
+ a = utils.betterErrors(a);
+ if (a.error instanceof AssertionError && a.message) {
+ console.log(
+ 'Assertion Message: ' +
+ assertion_message(a.message)
+ );
+ }
+ console.log(a.error.stack + '\n');
+ }
+ });
+ }
+ },
+ done: function (assertions, end) {
+ var end = end || new Date().getTime();
+ var duration = end - start;
+ if (assertions.failures()) {
+ console.log(
+ '\n' + bold(error('FAILURES: ')) + assertions.failures() +
+ '/' + assertions.length + ' assertions failed (' +
+ assertions.duration + 'ms)'
+ );
+ }
+ else {
+ console.log(
+ '\n' + bold(ok('OK: ')) + assertions.length +
+ ' assertions (' + assertions.duration + 'ms)'
+ );
+ }
+ },
+ testStart: function(name) {
+ tracker.put(name);
+ }
+ });
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/reporters/html.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/reporters/html.js b/bin/node_modules/nodeunit/lib/reporters/html.js
new file mode 100644
index 0000000..05fb403
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/reporters/html.js
@@ -0,0 +1,107 @@
+/*!
+ * Nodeunit
+ * Copyright (c) 2010 Caolan McMahon
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies
+ */
+
+var nodeunit = require('../nodeunit'),
+ utils = require('../utils'),
+ fs = require('fs'),
+ path = require('path'),
+ AssertionError = require('assert').AssertionError;
+
+/**
+ * Reporter info string
+ */
+
+exports.info = "Report tests result as HTML";
+
+/**
+ * Run all tests within each module, reporting the results to the command-line.
+ *
+ * @param {Array} files
+ * @api public
+ */
+
+exports.run = function (files, options) {
+
+ var start = new Date().getTime();
+ var paths = files.map(function (p) {
+ return path.join(process.cwd(), p);
+ });
+
+ console.log('<html>');
+ console.log('<head>');
+ console.log('<title></title>');
+ console.log('<style type="text/css">');
+ console.log('body { font: 12px Helvetica Neue }');
+ console.log('h2 { margin:0 ; padding:0 }');
+ console.log('pre { font: 11px Andale Mono; margin-left: 1em; padding-left: 1em; margin-top:0; font-size:smaller;}');
+ console.log('.assertion_message { margin-left: 1em; }');
+ console.log(' ol {' +
+ ' list-style: none;' +
+ ' margin-left: 1em;' +
+ ' padding-left: 1em;' +
+ ' text-indent: -1em;' +
+ '}');
+ console.log(' ol li.pass:before { content: "\\2714 \\0020"; }');
+ console.log(' ol li.fail:before { content: "\\2716 \\0020"; }');
+ console.log('</style>');
+ console.log('</head>');
+ console.log('<body>');
+ nodeunit.runFiles(paths, {
+ testspec: options.testspec,
+ moduleStart: function (name) {
+ console.log('<h2>' + name + '</h2>');
+ console.log('<ol>');
+ },
+ testDone: function (name, assertions) {
+ if (!assertions.failures()) {
+ console.log('<li class="pass">' + name + '</li>');
+ }
+ else {
+ console.log('<li class="fail">' + name);
+ assertions.forEach(function (a) {
+ if (a.failed()) {
+ a = utils.betterErrors(a);
+ if (a.error instanceof AssertionError && a.message) {
+ console.log('<div class="assertion_message">' +
+ 'Assertion Message: ' + a.message +
+ '</div>');
+ }
+ console.log('<pre>');
+ console.log(a.error.stack);
+ console.log('</pre>');
+ }
+ });
+ console.log('</li>');
+ }
+ },
+ moduleDone: function () {
+ console.log('</ol>');
+ },
+ done: function (assertions) {
+ var end = new Date().getTime();
+ var duration = end - start;
+ if (assertions.failures()) {
+ console.log(
+ '<h3>FAILURES: ' + assertions.failures() +
+ '/' + assertions.length + ' assertions failed (' +
+ assertions.duration + 'ms)</h3>'
+ );
+ }
+ else {
+ console.log(
+ '<h3>OK: ' + assertions.length +
+ ' assertions (' + assertions.duration + 'ms)</h3>'
+ );
+ }
+ console.log('</body>');
+ }
+ });
+
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/reporters/index.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/reporters/index.js b/bin/node_modules/nodeunit/lib/reporters/index.js
new file mode 100644
index 0000000..bbaf800
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/reporters/index.js
@@ -0,0 +1,9 @@
+module.exports = {
+ 'junit': require('./junit'),
+ 'default': require('./default'),
+ 'skip_passed': require('./skip_passed'),
+ 'minimal': require('./minimal'),
+ 'html': require('./html')
+ // browser test reporter is not listed because it cannot be used
+ // with the command line tool, only inside a browser.
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/reporters/junit.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/reporters/junit.js b/bin/node_modules/nodeunit/lib/reporters/junit.js
new file mode 100644
index 0000000..a542c69
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/reporters/junit.js
@@ -0,0 +1,183 @@
+/*!
+ * Nodeunit
+ * Copyright (c) 2010 Caolan McMahon
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies
+ */
+
+var nodeunit = require('../nodeunit'),
+ utils = require('../utils'),
+ fs = require('fs'),
+ path = require('path'),
+ async = require('../../deps/async'),
+ AssertionError = require('assert').AssertionError,
+ child_process = require('child_process'),
+ ejs = require('../../deps/ejs');
+
+
+/**
+ * Reporter info string
+ */
+
+exports.info = "jUnit XML test reports";
+
+
+/**
+ * Ensures a directory exists using mkdir -p.
+ *
+ * @param {String} path
+ * @param {Function} callback
+ * @api private
+ */
+
+var ensureDir = function (path, callback) {
+ var mkdir = child_process.spawn('mkdir', ['-p', path]);
+ mkdir.on('error', function (err) {
+ callback(err);
+ callback = function(){};
+ });
+ mkdir.on('exit', function (code) {
+ if (code === 0) callback();
+ else callback(new Error('mkdir exited with code: ' + code));
+ });
+};
+
+
+/**
+ * Returns absolute version of a path. Relative paths are interpreted
+ * relative to process.cwd() or the cwd parameter. Paths that are already
+ * absolute are returned unaltered.
+ *
+ * @param {String} p
+ * @param {String} cwd
+ * @return {String}
+ * @api public
+ */
+
+var abspath = function (p, /*optional*/cwd) {
+ if (p[0] === '/') return p;
+ cwd = cwd || process.cwd();
+ return path.normalize(path.join(cwd, p));
+};
+
+
+/**
+ * Run all tests within each module, reporting the results to the command-line,
+ * then writes out junit-compatible xml documents.
+ *
+ * @param {Array} files
+ * @api public
+ */
+
+exports.run = function (files, opts, callback) {
+ if (!opts.output) {
+ console.error(
+ 'Error: No output directory defined.\n' +
+ '\tEither add an "output" property to your nodeunit.json config ' +
+ 'file, or\n\tuse the --output command line option.'
+ );
+ return;
+ }
+ opts.output = abspath(opts.output);
+ var error = function (str) {
+ return opts.error_prefix + str + opts.error_suffix;
+ };
+ var ok = function (str) {
+ return opts.ok_prefix + str + opts.ok_suffix;
+ };
+ var bold = function (str) {
+ return opts.bold_prefix + str + opts.bold_suffix;
+ };
+
+ var start = new Date().getTime();
+ var paths = files.map(function (p) {
+ return path.join(process.cwd(), p);
+ });
+
+ var modules = {}
+ var curModule;
+
+ nodeunit.runFiles(paths, {
+ testspec: opts.testspec,
+ moduleStart: function (name) {
+ curModule = {
+ errorCount: 0,
+ failureCount: 0,
+ tests: 0,
+ testcases: [],
+ name: name
+ };
+ modules[name] = curModule;
+ },
+ testDone: function (name, assertions) {
+ var testcase = {name: name};
+ for (var i=0; i<assertions.length; i++) {
+ var a = assertions[i];
+ if (a.failed()) {
+ a = utils.betterErrors(a);
+ testcase.failure = {
+ message: a.message,
+ backtrace: a.error.stack
+ };
+
+ if (a.error instanceof AssertionError) {
+ curModule.failureCount++;
+ }
+ else {
+ curModule.errorCount++;
+ }
+ break;
+ }
+ }
+ curModule.tests++;
+ curModule.testcases.push(testcase);
+ },
+ done: function (assertions) {
+ var end = new Date().getTime();
+ var duration = end - start;
+
+ ensureDir(opts.output, function (err) {
+ var tmpl = __dirname + "/../../share/junit.xml.ejs";
+ fs.readFile(tmpl, function (err, data) {
+ if (err) throw err;
+ var tmpl = data.toString();
+
+ async.forEach(Object.keys(modules), function (k, cb) {
+ var module = modules[k];
+ var rendered = ejs.render(tmpl, {
+ locals: {suites: [module]}
+ });
+ var filename = path.join(
+ opts.output,
+ module.name + '.xml'
+ );
+ console.log('Writing ' + filename);
+ fs.writeFile(filename, rendered, cb);
+ },
+ function (err) {
+ if (err) throw err;
+ else if (assertions.failures()) {
+ console.log(
+ '\n' + bold(error('FAILURES: ')) +
+ assertions.failures() + '/' +
+ assertions.length + ' assertions failed (' +
+ assertions.duration + 'ms)'
+ );
+ }
+ else {
+ console.log(
+ '\n' + bold(ok('OK: ')) + assertions.length +
+ ' assertions (' + assertions.duration + 'ms)'
+ );
+ }
+ });
+
+ });
+ });
+
+ }
+ });
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/reporters/minimal.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/reporters/minimal.js b/bin/node_modules/nodeunit/lib/reporters/minimal.js
new file mode 100644
index 0000000..2ac5a6b
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/reporters/minimal.js
@@ -0,0 +1,112 @@
+/*!
+ * Nodeunit
+ * Copyright (c) 2010 Caolan McMahon
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies
+ */
+
+var nodeunit = require('../nodeunit'),
+ utils = require('../utils'),
+ fs = require('fs'),
+ path = require('path'),
+ AssertionError = require('assert').AssertionError;
+
+/**
+ * Reporter info string
+ */
+
+exports.info = "Pretty minimal output";
+
+/**
+ * Run all tests within each module, reporting the results to the command-line.
+ *
+ * @param {Array} files
+ * @api public
+ */
+
+exports.run = function (files, options) {
+
+ if (!options) {
+ // load default options
+ var content = fs.readFileSync(
+ __dirname + '/../../bin/nodeunit.json', 'utf8'
+ );
+ options = JSON.parse(content);
+ }
+
+ var red = function (str) {
+ return options.error_prefix + str + options.error_suffix;
+ };
+ var green = function (str) {
+ return options.ok_prefix + str + options.ok_suffix;
+ };
+ var magenta = function (str) {
+ return options.assertion_prefix + str + options.assertion_suffix;
+ };
+ var bold = function (str) {
+ return options.bold_prefix + str + options.bold_suffix;
+ };
+
+ var start = new Date().getTime();
+ var paths = files.map(function (p) {
+ return path.join(process.cwd(), p);
+ });
+
+ nodeunit.runFiles(paths, {
+ testspec: options.testspec,
+ moduleStart: function (name) {
+ process.stdout.write(bold(name) + ': ');
+ },
+ moduleDone: function (name, assertions) {
+ console.log('');
+ if (assertions.failures()) {
+ assertions.forEach(function (a) {
+ if (a.failed()) {
+ a = utils.betterErrors(a);
+ if (a.error instanceof AssertionError && a.message) {
+ console.log(
+ 'Assertion in test ' + bold(a.testname) + ': ' +
+ magenta(a.message)
+ );
+ }
+ console.log(a.error.stack + '\n');
+ }
+ });
+ }
+
+ },
+ testStart: function () {
+ },
+ testDone: function (name, assertions) {
+ if (!assertions.failures()) {
+ process.stdout.write('.');
+ }
+ else {
+ process.stdout.write(red('F'));
+ assertions.forEach(function (assertion) {
+ assertion.testname = name;
+ });
+ }
+ },
+ done: function (assertions) {
+ var end = new Date().getTime();
+ var duration = end - start;
+ if (assertions.failures()) {
+ console.log(
+ '\n' + bold(red('FAILURES: ')) + assertions.failures() +
+ '/' + assertions.length + ' assertions failed (' +
+ assertions.duration + 'ms)'
+ );
+ }
+ else {
+ console.log(
+ '\n' + bold(green('OK: ')) + assertions.length +
+ ' assertions (' + assertions.duration + 'ms)'
+ );
+ }
+ }
+ });
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/reporters/skip_passed.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/reporters/skip_passed.js b/bin/node_modules/nodeunit/lib/reporters/skip_passed.js
new file mode 100644
index 0000000..598dbb1
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/reporters/skip_passed.js
@@ -0,0 +1,105 @@
+/*!
+ * Nodeunit
+ * Copyright (c) 2010 Caolan McMahon
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies
+ */
+
+var nodeunit = require('../nodeunit'),
+ utils = require('../utils'),
+ fs = require('fs'),
+ path = require('path'),
+ AssertionError = require('assert').AssertionError;
+
+/**
+ * Reporter info string
+ */
+
+exports.info = "Skip passed tests output";
+
+/**
+ * Run all tests within each module, reporting the results to the command-line.
+ *
+ * @param {Array} files
+ * @api public
+ */
+
+exports.run = function (files, options) {
+
+ if (!options) {
+ // load default options
+ var content = fs.readFileSync(
+ __dirname + '/../../bin/nodeunit.json', 'utf8'
+ );
+ options = JSON.parse(content);
+ }
+
+ var error = function (str) {
+ return options.error_prefix + str + options.error_suffix;
+ };
+ var ok = function (str) {
+ return options.ok_prefix + str + options.ok_suffix;
+ };
+ var bold = function (str) {
+ return options.bold_prefix + str + options.bold_suffix;
+ };
+ var assertion_message = function (str) {
+ return options.assertion_prefix + str + options.assertion_suffix;
+ };
+
+ var start = new Date().getTime();
+ var paths = files.map(function (p) {
+ return path.join(process.cwd(), p);
+ });
+
+ nodeunit.runFiles(paths, {
+ testspec: options.testspec,
+ moduleStart: function (name) {
+ console.log('\n' + bold(name));
+ },
+ testDone: function (name, assertions) {
+ if (assertions.failures()) {
+ console.log(error('✖ ' + name) + '\n');
+ assertions.forEach(function (a) {
+ if (a.failed()) {
+ a = utils.betterErrors(a);
+ if (a.error instanceof AssertionError && a.message) {
+ console.log(
+ 'Assertion Message: ' + assertion_message(a.message)
+ );
+ }
+ console.log(a.error.stack + '\n');
+ }
+ });
+ }
+ },
+ moduleDone: function (name, assertions) {
+ if (!assertions.failures()) {
+ console.log('✔ all tests passed');
+ }
+ else {
+ console.log(error('✖ some tests failed'));
+ }
+ },
+ done: function (assertions) {
+ var end = new Date().getTime();
+ var duration = end - start;
+ if (assertions.failures()) {
+ console.log(
+ '\n' + bold(error('FAILURES: ')) + assertions.failures() +
+ '/' + assertions.length + ' assertions failed (' +
+ assertions.duration + 'ms)'
+ );
+ }
+ else {
+ console.log(
+ '\n' + bold(ok('OK: ')) + assertions.length +
+ ' assertions (' + assertions.duration + 'ms)'
+ );
+ }
+ }
+ });
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/track.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/track.js b/bin/node_modules/nodeunit/lib/track.js
new file mode 100644
index 0000000..5af98ad
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/track.js
@@ -0,0 +1,48 @@
+/*!
+ * Simple util module to track tests. Adds a process.exit hook to print
+ * the undone tests.
+ */
+
+
+exports.createTracker = function (on_exit) {
+ var names = {};
+ var tracker = {
+ names: function () {
+ var arr = [];
+ for (var k in names) {
+ if (names.hasOwnProperty(k)) {
+ arr.push(k);
+ }
+ }
+ return arr;
+ },
+ unfinished: function () {
+ return tracker.names().length;
+ },
+ put: function (testname) {
+ names[testname] = testname;
+ },
+ remove: function (testname) {
+ delete names[testname];
+ }
+ };
+
+ process.on('exit', function() {
+ on_exit = on_exit || exports.default_on_exit;
+ on_exit(tracker);
+ });
+
+ return tracker;
+};
+
+exports.default_on_exit = function (tracker) {
+ if (tracker.unfinished()) {
+ console.log('');
+ console.log('Undone tests (or their setups/teardowns): ');
+ var names = tracker.names();
+ for (var i = 0; i < names.length; i += 1) {
+ console.log(names[i]);
+ }
+ process.reallyExit(tracker.unfinished());
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/types.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/types.js b/bin/node_modules/nodeunit/lib/types.js
new file mode 100644
index 0000000..1f9b12d
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/types.js
@@ -0,0 +1,187 @@
+/*!
+ * Nodeunit
+ * Copyright (c) 2010 Caolan McMahon
+ * MIT Licensed
+ *
+ * THIS FILE SHOULD BE BROWSER-COMPATIBLE JS!
+ * You can use @REMOVE_LINE_FOR_BROWSER to remove code from the browser build.
+ * Only code on that line will be removed, its mostly to avoid requiring code
+ * that is node specific
+ */
+
+/**
+ * Module dependencies
+ */
+
+var assert = require('./assert'), //@REMOVE_LINE_FOR_BROWSER
+ async = require('../deps/async'); //@REMOVE_LINE_FOR_BROWSER
+
+
+/**
+ * Creates assertion objects representing the result of an assert call.
+ * Accepts an object or AssertionError as its argument.
+ *
+ * @param {object} obj
+ * @api public
+ */
+
+exports.assertion = function (obj) {
+ return {
+ method: obj.method || '',
+ message: obj.message || (obj.error && obj.error.message) || '',
+ error: obj.error,
+ passed: function () {
+ return !this.error;
+ },
+ failed: function () {
+ return Boolean(this.error);
+ }
+ };
+};
+
+/**
+ * Creates an assertion list object representing a group of assertions.
+ * Accepts an array of assertion objects.
+ *
+ * @param {Array} arr
+ * @param {Number} duration
+ * @api public
+ */
+
+exports.assertionList = function (arr, duration) {
+ var that = arr || [];
+ that.failures = function () {
+ var failures = 0;
+ for (var i=0; i<this.length; i++) {
+ if (this[i].failed()) failures++;
+ }
+ return failures;
+ };
+ that.passes = function () {
+ return that.length - that.failures();
+ };
+ that.duration = duration || 0;
+ return that;
+};
+
+/**
+ * Create a wrapper function for assert module methods. Executes a callback
+ * after the it's complete with an assertion object representing the result.
+ *
+ * @param {Function} callback
+ * @api private
+ */
+
+var assertWrapper = function (callback) {
+ return function (new_method, assert_method, arity) {
+ return function () {
+ var message = arguments[arity-1];
+ var a = exports.assertion({method: new_method, message: message});
+ try {
+ assert[assert_method].apply(null, arguments);
+ }
+ catch (e) {
+ a.error = e;
+ }
+ callback(a);
+ };
+ };
+};
+
+/**
+ * Creates the 'test' object that gets passed to every test function.
+ * Accepts the name of the test function as its first argument, followed by
+ * the start time in ms, the options object and a callback function.
+ *
+ * @param {String} name
+ * @param {Number} start
+ * @param {Object} options
+ * @param {Function} callback
+ * @api public
+ */
+
+exports.test = function (name, start, options, callback) {
+ var expecting;
+ var a_list = [];
+
+ var wrapAssert = assertWrapper(function (a) {
+ a_list.push(a);
+ if (options.log) {
+ async.nextTick(function () {
+ options.log(a);
+ });
+ }
+ });
+
+ var test = {
+ done: function (err) {
+ if (expecting !== undefined && expecting !== a_list.length) {
+ var e = new Error(
+ 'Expected ' + expecting + ' assertions, ' +
+ a_list.length + ' ran'
+ );
+ var a1 = exports.assertion({method: 'expect', error: e});
+ a_list.push(a1);
+ if (options.log) {
+ async.nextTick(function () {
+ options.log(a1);
+ });
+ }
+ }
+ if (err) {
+ var a2 = exports.assertion({error: err});
+ a_list.push(a2);
+ if (options.log) {
+ async.nextTick(function () {
+ options.log(a2);
+ });
+ }
+ }
+ var end = new Date().getTime();
+ async.nextTick(function () {
+ var assertion_list = exports.assertionList(a_list, end - start);
+ options.testDone(name, assertion_list);
+ callback(null, a_list);
+ });
+ },
+ ok: wrapAssert('ok', 'ok', 2),
+ same: wrapAssert('same', 'deepEqual', 3),
+ equals: wrapAssert('equals', 'equal', 3),
+ expect: function (num) {
+ expecting = num;
+ },
+ _assertion_list: a_list
+ };
+ // add all functions from the assert module
+ for (var k in assert) {
+ if (assert.hasOwnProperty(k)) {
+ test[k] = wrapAssert(k, k, assert[k].length);
+ }
+ }
+ return test;
+};
+
+/**
+ * Ensures an options object has all callbacks, adding empty callback functions
+ * if any are missing.
+ *
+ * @param {Object} opt
+ * @return {Object}
+ * @api public
+ */
+
+exports.options = function (opt) {
+ var optionalCallback = function (name) {
+ opt[name] = opt[name] || function () {};
+ };
+
+ optionalCallback('moduleStart');
+ optionalCallback('moduleDone');
+ optionalCallback('testStart');
+ optionalCallback('testDone');
+ //optionalCallback('log');
+
+ // 'done' callback is not optional.
+
+ return opt;
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/lib/utils.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/lib/utils.js b/bin/node_modules/nodeunit/lib/utils.js
new file mode 100644
index 0000000..8797b43
--- /dev/null
+++ b/bin/node_modules/nodeunit/lib/utils.js
@@ -0,0 +1,209 @@
+/*!
+ * Nodeunit
+ * Copyright (c) 2010 Caolan McMahon
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies
+ */
+
+var async = require('../deps/async'),
+ fs = require('fs'),
+ util = require('util'),
+ Script = process.binding('evals').Script,
+ http = require('http');
+
+
+/**
+ * Detect if coffee-script is available and search for .coffee as an
+ * extension in modulePaths if it is.
+ */
+
+var extensionPattern;
+try {
+ require('coffee-script');
+ extensionPattern = /\.(?:js|coffee)$/;
+}
+catch (e) {
+ extensionPattern = /\.js$/;
+}
+
+
+/**
+ * Finds all modules at each path in an array, If a path is a directory, it
+ * returns all supported file types inside it. This only reads 1 level deep in
+ * the directory and does not recurse through sub-directories.
+ *
+ * The extension (.js, .coffee etc) is stripped from the filenames so they can
+ * simply be require()'ed.
+ *
+ * @param {Array} paths
+ * @param {Function} callback
+ * @api public
+ */
+
+exports.modulePaths = function (paths, callback) {
+ async.concat(paths, function (p, cb) {
+ fs.stat(p, function (err, stats) {
+ if (err) {
+ return cb(err);
+ }
+ if (stats.isFile()) {
+ return cb(null, [p]);
+ }
+ if (stats.isDirectory()) {
+ fs.readdir(p, function (err, files) {
+ if (err) {
+ return cb(err);
+ }
+
+ // filter out any filenames with unsupported extensions
+ var modules = files.filter(function (filename) {
+ return extensionPattern.exec(filename);
+ });
+
+ // remove extension from module name and prepend the
+ // directory path
+ var fullpaths = modules.map(function (filename) {
+ var mod_name = filename.replace(extensionPattern, '');
+ return [p, mod_name].join('/');
+ });
+
+ // sort filenames here, because Array.map changes order
+ fullpaths.sort();
+
+ cb(null, fullpaths);
+ });
+ }
+ });
+ }, callback);
+};
+
+/**
+ * Evaluates JavaScript files in a sandbox, returning the context. The first
+ * argument can either be a single filename or an array of filenames. If
+ * multiple filenames are given their contents are concatenated before
+ * evalution. The second argument is an optional context to use for the sandbox.
+ *
+ * @param files
+ * @param {Object} sandbox
+ * @return {Object}
+ * @api public
+ */
+
+exports.sandbox = function (files, /*optional*/sandbox) {
+ var source, script, result;
+ if (!(files instanceof Array)) {
+ files = [files];
+ }
+ source = files.map(function (file) {
+ return fs.readFileSync(file, 'utf8');
+ }).join('');
+
+ if (!sandbox) {
+ sandbox = {};
+ }
+ script = new Script(source);
+ result = script.runInNewContext(sandbox);
+ return sandbox;
+};
+
+/**
+ * Provides a http request, response testing environment.
+ *
+ * Example:
+ *
+ * var httputil = require('nodeunit').utils.httputil
+ * exports.testSomething = function(test) {
+ * httputil(function (req, resp) {
+ * resp.writeHead(200, {});
+ * resp.end('test data');
+ * },
+ * function(server, client) {
+ * client.fetch('GET', '/', {}, function(resp) {
+ * test.equal('test data', resp.body);
+ * server.close();
+ * test.done();
+ * })
+ * });
+ * };
+ *
+ * @param {Function} cgi
+ * @param {Function} envReady
+ * @api public
+ */
+exports.httputil = function (cgi, envReady) {
+ var hostname = process.env.HOSTNAME || 'localhost';
+ var port = process.env.PORT || 3000;
+
+ var server = http.createServer(cgi);
+ server.listen(port, hostname);
+
+ var client = http.createClient(port, hostname);
+ client.fetch = function (method, path, headers, respReady) {
+ var request = this.request(method, path, headers);
+ request.end();
+ request.on('response', function (response) {
+ response.setEncoding('utf8');
+ response.on('data', function (chunk) {
+ if (response.body) {
+ response.body += chunk;
+ } else {
+ response.body = chunk;
+ }
+ });
+ response.on('end', function () {
+ if (response.headers['content-type'] === 'application/json') {
+ response.bodyAsObject = JSON.parse(response.body);
+ }
+ respReady(response);
+ });
+ });
+ };
+
+ process.nextTick(function () {
+ if (envReady && typeof envReady === 'function') {
+ envReady(server, client);
+ }
+ });
+};
+
+
+/**
+ * Improves formatting of AssertionError messages to make deepEqual etc more
+ * readable.
+ *
+ * @param {Object} assertion
+ * @return {Object}
+ * @api public
+ */
+
+exports.betterErrors = function (assertion) {
+ if (!assertion.error) return;
+
+ var e = assertion.error;
+ // deepEqual error message is a bit sucky, lets improve it!
+ // e.actual and e.expected could be null or undefined, so
+ // using getOwnPropertyDescriptor to see if they exist:
+ if (Object.getOwnPropertyDescriptor(e, 'actual') &&
+ Object.getOwnPropertyDescriptor(e, 'expected')) {
+
+ // alexgorbatchev 2010-10-22 :: Added a bit of depth to inspection
+ var actual = util.inspect(e.actual, false, 10).replace(/\n$/, '');
+ var expected = util.inspect(e.expected, false, 10).replace(/\n$/, '');
+ var multiline = (
+ actual.indexOf('\n') !== -1 ||
+ expected.indexOf('\n') !== -1
+ );
+ var spacing = (multiline ? '\n' : ' ');
+ e._message = e.message;
+ e.stack = (
+ e.name + ':' + spacing +
+ actual + spacing + e.operator + spacing +
+ expected + '\n' +
+ e.stack.split('\n').slice(1).join('\n')
+ );
+ }
+ return assertion;
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/man1/nodeunit.1
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/man1/nodeunit.1 b/bin/node_modules/nodeunit/man1/nodeunit.1
new file mode 100644
index 0000000..450772d
--- /dev/null
+++ b/bin/node_modules/nodeunit/man1/nodeunit.1
@@ -0,0 +1,95 @@
+.\" Generated with Ronnjs/v0.1
+.\" http://github.com/kapouer/ronnjs/
+.
+.TH "NODEUNIT" "1" "October 2010" "" ""
+.
+.SH "NAME"
+\fBnodeunit\fR \-\- simple node\.js unit testing tool
+.
+.SH "SYNOPSIS"
+.
+.nf
+nodeunit [options] <file\-or\-directory> [<file\-or\-directory> \.\.\.]
+.
+.fi
+.
+.SH "DESCRIPTION"
+Nodeunit is a simple unit testing tool based on the node\.js assert module\.
+.
+.IP "\(bu" 4
+Simple to use
+.
+.IP "\(bu" 4
+Just export the tests from a module
+.
+.IP "\(bu" 4
+Helps you avoid common pitfalls when testing asynchronous code
+.
+.IP "\(bu" 4
+Easy to add test cases with setUp and tearDown functions if you wish
+.
+.IP "\(bu" 4
+Allows the use of mocks and stubs
+.
+.IP "" 0
+.
+.SH "OPTIONS"
+ \fB\-\-config FILE\fR:
+.
+.br
+ Load config options from a JSON file, allows the customisation
+ of color schemes for the default test reporter etc\.
+ See bin/nodeunit\.json for current available options\.
+.
+.P
+ \fB\-\-reporter FILE\fR:
+.
+.br
+ You can set the test reporter to a custom module or on of the modules
+ in nodeunit/lib/reporters, when omitted, the default test runner is used\.
+.
+.P
+ \fB\-\-list\-reporters\fR:
+.
+.br
+ List available build\-in reporters\.
+.
+.P
+ \fB\-h\fR, \fB\-\-help\fR:
+.
+.br
+ Display the help and exit\.
+.
+.P
+ \fB\-v\fR, \fB\-\-version\fR:
+.
+.br
+ Output version information and exit\.
+.
+.P
+ \fB<file\-or\-directory>\fR:
+ You can run nodeunit on specific files or on all \fI*\.js\fR files inside
+.
+.br
+ a directory\.
+.
+.SH "AUTHORS"
+Written by Caolan McMahon and other nodeunit contributors\.
+.
+.br
+Contributors list: \fIhttp://github\.com/caolan/nodeunit/contributors\fR\|\.
+.
+.SH "REPORTING BUGS"
+Report nodeunit bugs to \fIhttp://github\.com/caolan/nodeunit/issues\fR\|\.
+.
+.SH "COPYRIGHT"
+Copyright © 2010 Caolan McMahon\.
+.
+.br
+Nodeunit has been released under the MIT license:
+.
+.br
+\fIhttp://github\.com/caolan/nodeunit/raw/master/LICENSE\fR\|\.
+.
+.SH "SEE ALSO"
+node(1)
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/nodelint.cfg
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/nodelint.cfg b/bin/node_modules/nodeunit/nodelint.cfg
new file mode 100644
index 0000000..457a967
--- /dev/null
+++ b/bin/node_modules/nodeunit/nodelint.cfg
@@ -0,0 +1,4 @@
+var options = {
+ indent: 4,
+ onevar: false
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/package.json
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/package.json b/bin/node_modules/nodeunit/package.json
new file mode 100644
index 0000000..63d723f
--- /dev/null
+++ b/bin/node_modules/nodeunit/package.json
@@ -0,0 +1,56 @@
+{ "name": "nodeunit"
+, "description": "Easy unit testing for node.js and the browser."
+, "maintainers":
+ [ { "name": "Caolan McMahon"
+ , "web": "https://github.com/caolan"
+ }
+ ]
+, "contributors" :
+ [ { "name": "Alex Gorbatchev"
+ , "web": "https://github.com/alexgorbatchev"
+ }
+ , { "name": "Alex Wolfe"
+ , "web": "https://github.com/alexkwolfe"
+ }
+ , { "name": "Carl Fürstenberg"
+ , "web": "https://github.com/azatoth"
+ }
+ , { "name": "Gerad Suyderhoud"
+ , "web": "https://github.com/gerad"
+ }
+ , { "name": "Kadir Pekel"
+ , "web": "https://github.com/coffeemate"
+ }
+ , { "name": "Oleg Efimov"
+ , "web": "https://github.com/Sannis"
+ }
+ , { "name": "Orlando Vazquez"
+ , "web": "https://github.com/orlandov"
+ }
+ , { "name": "Ryan Dahl"
+ , "web": "https://github.com/ry"
+ }
+ , { "name": "Sam Stephenson"
+ , "web": "https://github.com/sstephenson"
+ }
+ , { "name": "Thomas Mayfield"
+ , "web": "https://github.com/thegreatape"
+ }
+ , { "name": "Elijah Insua <tm...@gmail.com>",
+ "web": "http://tmpvar.com"
+ }
+ ]
+, "version": "0.5.3"
+, "repository" :
+ { "type" : "git"
+ , "url" : "http://github.com/caolan/nodeunit.git"
+ }
+, "bugs" : { "web" : "http://github.com/caolan/nodeunit/issues" }
+, "licenses" :
+ [ { "type" : "MIT"
+ , "url" : "http://github.com/caolan/nodeunit/raw/master/LICENSE"
+ }
+ ]
+, "directories" : { "lib": "./lib", "doc" : "./doc", "man" : "./man1" }
+, "bin" : { "nodeunit" : "./bin/nodeunit" }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/share/junit.xml.ejs
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/share/junit.xml.ejs b/bin/node_modules/nodeunit/share/junit.xml.ejs
new file mode 100644
index 0000000..c1db5bb
--- /dev/null
+++ b/bin/node_modules/nodeunit/share/junit.xml.ejs
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<% for (var i=0; i < suites.length; i++) { %>
+ <% var suite=suites[i]; %>
+ <testsuite name="<%= suite.name %>"
+ errors="<%= suite.errorCount %>"
+ failures="<%= suite.failureCount %>"
+ tests="<%= suite.tests %>">
+ <% for (var j=0; j < suite.testcases.length; j++) { %>
+ <% var testcase=suites[i].testcases[j]; %>
+ <testcase name="<%= testcase.name %>">
+ <% if (testcase.failure) { %>
+ <failure message="<%= testcase.failure.message %>">
+ <% if (testcase.failure.backtrace) { %><%= testcase.failure.backtrace %><% } %>
+ </failure>
+ <% } %>
+ </testcase>
+ <% } %>
+ </testsuite>
+<% } %>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/share/license.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/share/license.js b/bin/node_modules/nodeunit/share/license.js
new file mode 100644
index 0000000..f0f326f
--- /dev/null
+++ b/bin/node_modules/nodeunit/share/license.js
@@ -0,0 +1,11 @@
+/*!
+ * Nodeunit
+ * https://github.com/caolan/nodeunit
+ * Copyright (c) 2010 Caolan McMahon
+ * MIT Licensed
+ *
+ * json2.js
+ * http://www.JSON.org/json2.js
+ * Public Domain.
+ * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+ */
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/share/nodeunit.css
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/share/nodeunit.css b/bin/node_modules/nodeunit/share/nodeunit.css
new file mode 100644
index 0000000..274434a
--- /dev/null
+++ b/bin/node_modules/nodeunit/share/nodeunit.css
@@ -0,0 +1,70 @@
+/*!
+ * Styles taken from qunit.css
+ */
+
+h1#nodeunit-header, h1.nodeunit-header {
+ padding: 15px;
+ font-size: large;
+ background-color: #06b;
+ color: white;
+ font-family: 'trebuchet ms', verdana, arial;
+ margin: 0;
+}
+
+h1#nodeunit-header a {
+ color: white;
+}
+
+h2#nodeunit-banner {
+ height: 2em;
+ border-bottom: 1px solid white;
+ background-color: #eee;
+ margin: 0;
+ font-family: 'trebuchet ms', verdana, arial;
+}
+h2#nodeunit-banner.pass {
+ background-color: green;
+}
+h2#nodeunit-banner.fail {
+ background-color: red;
+}
+
+h2#nodeunit-userAgent, h2.nodeunit-userAgent {
+ padding: 10px;
+ background-color: #eee;
+ color: black;
+ margin: 0;
+ font-size: small;
+ font-weight: normal;
+ font-family: 'trebuchet ms', verdana, arial;
+ font-size: 10pt;
+}
+
+div#nodeunit-testrunner-toolbar {
+ background: #eee;
+ border-top: 1px solid black;
+ padding: 10px;
+ font-family: 'trebuchet ms', verdana, arial;
+ margin: 0;
+ font-size: 10pt;
+}
+
+ol#nodeunit-tests {
+ font-family: 'trebuchet ms', verdana, arial;
+ font-size: 10pt;
+}
+ol#nodeunit-tests li strong {
+ cursor:pointer;
+}
+ol#nodeunit-tests .pass {
+ color: green;
+}
+ol#nodeunit-tests .fail {
+ color: red;
+}
+
+p#nodeunit-testresult {
+ margin-left: 1em;
+ font-size: 10pt;
+ font-family: 'trebuchet ms', verdana, arial;
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/test/fixtures/coffee/mock_coffee_module.coffee
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/test/fixtures/coffee/mock_coffee_module.coffee b/bin/node_modules/nodeunit/test/fixtures/coffee/mock_coffee_module.coffee
new file mode 100644
index 0000000..a1c069b
--- /dev/null
+++ b/bin/node_modules/nodeunit/test/fixtures/coffee/mock_coffee_module.coffee
@@ -0,0 +1,4 @@
+j = 0
+j += i for i in [0..5]
+
+exports.name = "mock_coffee_#{j}"
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/test/fixtures/dir/mock_module3.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/test/fixtures/dir/mock_module3.js b/bin/node_modules/nodeunit/test/fixtures/dir/mock_module3.js
new file mode 100644
index 0000000..3021776
--- /dev/null
+++ b/bin/node_modules/nodeunit/test/fixtures/dir/mock_module3.js
@@ -0,0 +1 @@
+exports.name = 'mock_module3';
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/test/fixtures/dir/mock_module4.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/test/fixtures/dir/mock_module4.js b/bin/node_modules/nodeunit/test/fixtures/dir/mock_module4.js
new file mode 100644
index 0000000..876f9ca
--- /dev/null
+++ b/bin/node_modules/nodeunit/test/fixtures/dir/mock_module4.js
@@ -0,0 +1 @@
+exports.name = 'mock_module4';
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/test/fixtures/mock_module1.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/test/fixtures/mock_module1.js b/bin/node_modules/nodeunit/test/fixtures/mock_module1.js
new file mode 100644
index 0000000..4c093ad
--- /dev/null
+++ b/bin/node_modules/nodeunit/test/fixtures/mock_module1.js
@@ -0,0 +1 @@
+exports.name = 'mock_module1';
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/test/fixtures/mock_module2.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/test/fixtures/mock_module2.js b/bin/node_modules/nodeunit/test/fixtures/mock_module2.js
new file mode 100644
index 0000000..a63d012
--- /dev/null
+++ b/bin/node_modules/nodeunit/test/fixtures/mock_module2.js
@@ -0,0 +1 @@
+exports.name = 'mock_module2';
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/test/fixtures/raw_jscode1.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/test/fixtures/raw_jscode1.js b/bin/node_modules/nodeunit/test/fixtures/raw_jscode1.js
new file mode 100644
index 0000000..2ef7115
--- /dev/null
+++ b/bin/node_modules/nodeunit/test/fixtures/raw_jscode1.js
@@ -0,0 +1,3 @@
+function hello_world(arg) {
+ return "_" + arg + "_";
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/test/fixtures/raw_jscode2.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/test/fixtures/raw_jscode2.js b/bin/node_modules/nodeunit/test/fixtures/raw_jscode2.js
new file mode 100644
index 0000000..55a764e
--- /dev/null
+++ b/bin/node_modules/nodeunit/test/fixtures/raw_jscode2.js
@@ -0,0 +1,3 @@
+function get_a_variable() {
+ return typeof a_variable;
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/test/fixtures/raw_jscode3.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/test/fixtures/raw_jscode3.js b/bin/node_modules/nodeunit/test/fixtures/raw_jscode3.js
new file mode 100644
index 0000000..1fd1e78
--- /dev/null
+++ b/bin/node_modules/nodeunit/test/fixtures/raw_jscode3.js
@@ -0,0 +1 @@
+var t=t?t+1:1;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/test/test-base.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/test/test-base.js b/bin/node_modules/nodeunit/test/test-base.js
new file mode 100644
index 0000000..64b8c8b
--- /dev/null
+++ b/bin/node_modules/nodeunit/test/test-base.js
@@ -0,0 +1,219 @@
+/*
+ * This module is not a plain nodeunit test suite, but instead uses the
+ * assert module to ensure a basic level of functionality is present,
+ * allowing the rest of the tests to be written using nodeunit itself.
+ *
+ * THIS FILE SHOULD BE BROWSER-COMPATIBLE JS!
+ * You can use @REMOVE_LINE_FOR_BROWSER to remove code from the browser build.
+ * Only code on that line will be removed, its mostly to avoid requiring code
+ * that is node specific
+ */
+
+var assert = require('assert'), // @REMOVE_LINE_FOR_BROWSER
+ async = require('../deps/async'), // @REMOVE_LINE_FOR_BROWSER
+ nodeunit = require('../lib/nodeunit'); // @REMOVE_LINE_FOR_BROWSER
+
+
+// NOT A TEST - util function to make testing faster.
+// retries the assertion until it passes or the timeout is reached,
+// at which point it throws the assertion error
+var waitFor = function (fn, timeout, callback, start) {
+ start = start || new Date().getTime();
+ callback = callback || function () {};
+ try {
+ fn();
+ callback();
+ }
+ catch (e) {
+ if (e instanceof assert.AssertionError) {
+ var now = new Date().getTime();
+ if (now - start >= timeout) {
+ throw e;
+ }
+ else {
+ async.nextTick(function () {
+ waitFor(fn, timeout, callback, start);
+ });
+ }
+ }
+ else {
+ throw e;
+ }
+ }
+};
+
+
+// TESTS:
+
+// Are exported tests actually run? - store completed tests in this variable
+// for checking later
+var tests_called = {};
+
+// most basic test that should run, the tests_called object is tested
+// at the end of this module to ensure the tests were actually run by nodeunit
+exports.testCalled = function (test) {
+ tests_called.testCalled = true;
+ test.done();
+};
+
+// generates test functions for nodeunit assertions
+var makeTest = function (method, args_pass, args_fail) {
+ return function (test) {
+ var test1_called = false;
+ var test2_called = false;
+
+ // test pass
+ nodeunit.runTest(
+ 'testname',
+ function (test) {
+ test[method].apply(test, args_pass);
+ test.done();
+ },
+ {testDone: function (name, assertions) {
+ assert.equal(assertions.length, 1);
+ assert.equal(assertions.failures(), 0);
+ }},
+ function () {
+ test1_called = true;
+ }
+ );
+
+ // test failure
+ nodeunit.runTest(
+ 'testname',
+ function (test) {
+ test[method].apply(test, args_fail);
+ test.done();
+ },
+ {testDone: function (name, assertions) {
+ assert.equal(assertions.length, 1);
+ assert.equal(assertions.failures(), 1);
+ }},
+ function () {
+ test2_called = true;
+ }
+ );
+
+ // ensure tests were run
+ waitFor(function () {
+ assert.ok(test1_called);
+ assert.ok(test2_called);
+ tests_called[method] = true;
+ }, 500, test.done);
+ };
+};
+
+// ensure basic assertions are working:
+exports.testOk = makeTest('ok', [true], [false]);
+exports.testEquals = makeTest('equals', [1, 1], [1, 2]);
+exports.testSame = makeTest('same',
+ [{test: 'test'}, {test: 'test'}],
+ [{test: 'test'}, {monkey: 'penguin'}]
+);
+
+// from the assert module:
+exports.testEqual = makeTest('equal', [1, 1], [1, 2]);
+exports.testNotEqual = makeTest('notEqual', [1, 2], [1, 1]);
+exports.testDeepEqual = makeTest('deepEqual',
+ [{one: 1}, {one: 1}], [{one: 1}, {two: 2}]
+);
+exports.testNotDeepEqual = makeTest('notDeepEqual',
+ [{one: 1}, {two: 2}], [{one: 1}, {one: 1}]
+);
+exports.testStrictEqual = makeTest('strictEqual', [1, 1], [1, true]);
+exports.testNotStrictEqual = makeTest('notStrictEqual', [true, 1], [1, 1]);
+exports.testThrows = makeTest('throws',
+ [function () {
+ throw new Error('test');
+ }],
+ [function () {
+ return;
+ }]
+);
+exports.testDoesNotThrows = makeTest('doesNotThrow',
+ [function () {
+ return;
+ }],
+ [function () {
+ throw new Error('test');
+ }]
+);
+exports.testIfError = makeTest('ifError', [false], [new Error('test')]);
+
+
+exports.testExpect = function (test) {
+ var test1_called = false,
+ test2_called = false,
+ test3_called = false;
+
+ // correct number of tests run
+ nodeunit.runTest(
+ 'testname',
+ function (test) {
+ test.expect(2);
+ test.ok(true);
+ test.ok(true);
+ test.done();
+ },
+ {testDone: function (name, assertions) {
+ test.equals(assertions.length, 2);
+ test.equals(assertions.failures(), 0);
+ }},
+ function () {
+ test1_called = true;
+ }
+ );
+
+ // no tests run
+ nodeunit.runTest(
+ 'testname',
+ function (test) {
+ test.expect(2);
+ test.done();
+ },
+ {testDone: function (name, assertions) {
+ test.equals(assertions.length, 1);
+ test.equals(assertions.failures(), 1);
+ }},
+ function () {
+ test2_called = true;
+ }
+ );
+
+ // incorrect number of tests run
+ nodeunit.runTest(
+ 'testname',
+ function (test) {
+ test.expect(2);
+ test.ok(true);
+ test.ok(true);
+ test.ok(true);
+ test.done();
+ },
+ {testDone: function (name, assertions) {
+ test.equals(assertions.length, 4);
+ test.equals(assertions.failures(), 1);
+ }},
+ function () {
+ test3_called = true;
+ }
+ );
+
+ // ensure callbacks fired
+ waitFor(function () {
+ assert.ok(test1_called);
+ assert.ok(test2_called);
+ assert.ok(test3_called);
+ tests_called.expect = true;
+ }, 500, test.done);
+};
+
+
+// tests are async, so wait for them to be called
+waitFor(function () {
+ assert.ok(tests_called.testCalled);
+ assert.ok(tests_called.ok);
+ assert.ok(tests_called.equals);
+ assert.ok(tests_called.same);
+ assert.ok(tests_called.expect);
+}, 10000);
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/test/test-failing-callbacks.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/test/test-failing-callbacks.js b/bin/node_modules/nodeunit/test/test-failing-callbacks.js
new file mode 100644
index 0000000..08f7eb5
--- /dev/null
+++ b/bin/node_modules/nodeunit/test/test-failing-callbacks.js
@@ -0,0 +1,114 @@
+var nodeunit = require('../lib/nodeunit');
+
+
+exports.testFailingLog = function (test) {
+ test.expect(3);
+
+ // this is meant to bubble to the top, and will be ignored for the purposes
+ // of testing:
+ var ignored_error = new Error('ignore this callback error');
+ var err_handler = function (err) {
+ if (err && err.message !== ignored_error.message) {
+ throw err;
+ }
+ };
+ process.addListener('uncaughtException', err_handler);
+
+ // A failing callback should not affect the test outcome
+ var testfn = function (test) {
+ test.ok(true, 'test.ok');
+ test.done();
+ };
+ nodeunit.runTest('testname', testfn, {
+ log: function (assertion) {
+ test.ok(true, 'log called');
+ throw ignored_error;
+ },
+ testDone: function (name, assertions) {
+ test.equals(assertions.failures(), 0, 'failures');
+ test.equals(assertions.length, 1, 'total');
+ process.removeListener('uncaughtException', err_handler);
+ }
+ }, test.done);
+};
+
+exports.testFailingTestDone = function (test) {
+ test.expect(2);
+
+ var ignored_error = new Error('ignore this callback error');
+ var err_handler = function (err) {
+ if (err && err.message !== ignored_error.message) {
+ throw err;
+ }
+ };
+ process.addListener('uncaughtException', err_handler);
+
+ // A failing callback should not affect the test outcome
+ var testfn = function (test) {
+ test.done();
+ };
+ nodeunit.runTest('testname', testfn, {
+ log: function (assertion) {
+ test.ok(false, 'log should not be called');
+ },
+ testDone: function (name, assertions) {
+ test.equals(assertions.failures(), 0, 'failures');
+ test.equals(assertions.length, 0, 'total');
+ process.nextTick(function () {
+ process.removeListener('uncaughtException', err_handler);
+ test.done();
+ });
+ throw ignored_error;
+ }
+ }, function () {});
+};
+
+exports.testAssertionObj = function (test) {
+ test.expect(4);
+ var testfn = function (test) {
+ test.ok(true, 'ok true');
+ test.done();
+ };
+ nodeunit.runTest('testname', testfn, {
+ log: function (assertion) {
+ test.ok(assertion.passed() === true, 'assertion.passed');
+ test.ok(assertion.failed() === false, 'assertion.failed');
+ },
+ testDone: function (name, assertions) {
+ test.equals(assertions.failures(), 0, 'failures');
+ test.equals(assertions.length, 1, 'total');
+ }
+ }, test.done);
+};
+
+exports.testLogOptional = function (test) {
+ test.expect(2);
+ var testfn = function (test) {
+ test.ok(true, 'ok true');
+ test.done();
+ };
+ nodeunit.runTest('testname', testfn, {
+ testDone: function (name, assertions) {
+ test.equals(assertions.failures(), 0, 'failures');
+ test.equals(assertions.length, 1, 'total');
+ }
+ }, test.done);
+};
+
+exports.testExpectWithFailure = function (test) {
+ test.expect(3);
+ var testfn = function (test) {
+ test.expect(1);
+ test.ok(false, 'test.ok');
+ test.done();
+ };
+ nodeunit.runTest('testname', testfn, {
+ log: function (assertion) {
+ test.equals(assertion.method, 'ok', 'assertion.method');
+ },
+ testDone: function (name, assertions) {
+ test.equals(assertions.failures(), 1, 'failures');
+ test.equals(assertions.length, 1, 'total');
+ }
+ }, test.done);
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/bin/node_modules/nodeunit/test/test-httputil.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nodeunit/test/test-httputil.js b/bin/node_modules/nodeunit/test/test-httputil.js
new file mode 100644
index 0000000..e5ee25c
--- /dev/null
+++ b/bin/node_modules/nodeunit/test/test-httputil.js
@@ -0,0 +1,55 @@
+var nodeunit = require('../lib/nodeunit');
+var httputil = require('../lib/utils').httputil;
+
+exports.testHttpUtilBasics = function (test) {
+
+ test.expect(6);
+
+ httputil(function (req, resp) {
+ test.equal(req.method, 'PUT');
+ test.equal(req.url, '/newpair');
+ test.equal(req.headers.foo, 'bar');
+
+ resp.writeHead(500, {'content-type': 'text/plain'});
+ resp.end('failed');
+ }, function (server, client) {
+ client.fetch('PUT', '/newpair', {'foo': 'bar'}, function (resp) {
+ test.equal(resp.statusCode, 500);
+ test.equal(resp.headers['content-type'], 'text/plain');
+ test.equal(resp.body, 'failed');
+
+ server.close();
+ test.done();
+ });
+ });
+};
+
+exports.testHttpUtilJsonHandling = function (test) {
+
+ test.expect(9);
+
+ httputil(function (req, resp) {
+ test.equal(req.method, 'GET');
+ test.equal(req.url, '/');
+ test.equal(req.headers.foo, 'bar');
+
+ var testdata = {foo1: 'bar', foo2: 'baz'};
+
+ resp.writeHead(200, {'content-type': 'application/json'});
+ resp.end(JSON.stringify(testdata));
+
+ }, function (server, client) {
+ client.fetch('GET', '/', {'foo': 'bar'}, function (resp) {
+ test.equal(resp.statusCode, 200);
+ test.equal(resp.headers['content-type'], 'application/json');
+
+ test.ok(resp.bodyAsObject);
+ test.equal(typeof resp.bodyAsObject, 'object');
+ test.equal(resp.bodyAsObject.foo1, 'bar');
+ test.equal(resp.bodyAsObject.foo2, 'baz');
+
+ server.close();
+ test.done();
+ });
+ });
+};