Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CB29FD004 for ; Tue, 11 Sep 2012 22:59:42 +0000 (UTC) Received: (qmail 589 invoked by uid 500); 11 Sep 2012 22:59:41 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 505 invoked by uid 500); 11 Sep 2012 22:59:41 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 187 invoked by uid 99); 11 Sep 2012 22:59:41 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2012 22:59:41 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B32993595F; Tue, 11 Sep 2012 22:59:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: steven@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [13/14] updated package.json Message-Id: <20120911225940.B32993595F@tyr.zones.apache.org> Date: Tue, 11 Sep 2012 22:59:40 +0000 (UTC) http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-assert/assert.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-assert/assert.js b/node_modules/nodeunit/node_modules/tap-assert/assert.js deleted file mode 100644 index 8d3bba0..0000000 --- a/node_modules/nodeunit/node_modules/tap-assert/assert.js +++ /dev/null @@ -1,396 +0,0 @@ -// an assert module that returns tappable data for each assertion. - -module.exports = assert - -var syns = {} - , id = 1 - -function assert (ok, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - - //console.error("assert %j", [ok, message, extra]) - //if (extra && extra.skip) return assert.skip(message, extra) - //console.error("assert", [ok, message, extra]) - ok = !!ok - var res = { id : id ++, ok: ok } - - var caller = getCaller(extra && extra.error) - if (extra && extra.error) { - res.type = extra.error.name - res.message = extra.error.message - res.code = extra.error.code - || extra.error.type - res.errno = extra.error.errno - delete extra.error - } - if (caller.file) { - res.file = caller.file - res.line = +caller.line - res.column = +caller.column - } - res.stack = caller.stack - - res.name = message || "(unnamed assert)" - - if (extra) Object.keys(extra).forEach(function (k) { - if (!res.hasOwnProperty(k)) res[k] = extra[k] - }) - - // strings and objects are hard to diff by eye - if (!ok && - res.hasOwnProperty("found") && - res.hasOwnProperty("wanted") && - res.found !== res.wanted) { - if (typeof res.wanted !== typeof res.found || - typeof res.wanted === "object" && (!res.found || !res.wanted)) { - res.type = { found: typeof found - , wanted: typeof wanted } - } else if (typeof res.wanted === "string") { - res.diff = diffString(res.found, res.wanted) - } else if (typeof res.wanted === "object") { - res.diff = diffObject(res.found, res.wanted) - } - } - - //console.error("assert return", res) - - return res -} -assert.ok = assert -syns.ok = [ "true", "assert" ] - - -function notOk (ok, message, extra) { - return assert(!ok, message, extra) -} -assert.notOk = notOk -syns.notOk = [ "false", "notok" ] - -function error (er, message, extra) { - if (!er) { - // just like notOk(er) - return assert(!er, message, extra) - } - message = message || er.message - extra = extra || {} - extra.error = er - return assert.fail(message, extra) -} -assert.error = error -syns.error = [ "ifError", "ifErr", "iferror" ] - - -function pass (message, extra) { - return assert(true, message, extra) -} -assert.pass = pass - -function fail (message, extra) { - //console.error("assert.fail", [message, extra]) - //if (extra && extra.skip) return assert.skip(message, extra) - return assert(false, message, extra) -} -assert.fail = fail - -function skip (message, extra) { - //console.error("assert.skip", message, extra) - if (!extra) extra = {} - return { id: id ++, skip: true, name: message || "" } -} -assert.skip = skip - -function throws (fn, wanted, message, extra) { - if (typeof wanted === "string") { - extra = message - message = wanted - wanted = null - } - - if (extra && extra.skip) return assert.skip(message, extra) - - var found = null - try { - fn() - } catch (e) { - found = { name: e.name, message: e.message } - } - - extra = extra || {} - - extra.found = found - if (wanted) { - wanted = { name: wanted.name, message: wanted.message } - extra.wanted = wanted - } - - if (!message) { - message = "Expected to throw" - if (wanted) message += ": "+wanted.name + " " + wanted.message - } - - return (wanted) ? assert.similar(found, wanted, message, extra) - : assert.ok(found, message, extra) -} -assert.throws = throws - - -function doesNotThrow (fn, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var found = null - try { - fn() - } catch (e) { - found = {name: e.name, message: e.message} - } - message = message || "Should not throw" - - return assert.equal(found, null, message, extra) -} -assert.doesNotThrow = doesNotThrow - - -function equal (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should be equal" - extra.found = a - extra.wanted = b - return assert(a === b, message, extra) -} -assert.equal = equal -syns.equal = ["equals" - ,"isEqual" - ,"is" - ,"strictEqual" - ,"strictEquals"] - - -function equivalent (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var extra = extra || {} - message = message || "should be equivalent" - extra.found = a - extra.wanted = b - return assert(stringify(a) === stringify(b), message, extra) -} -assert.equivalent = equivalent -syns.equivalent = ["isEquivalent" - ,"looseEqual" - ,"looseEquals" - ,"isDeeply" - ,"same" - ,"deepEqual" - ,"deepEquals"] - - -function inequal (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should not be equal" - extra.found = a - extra.doNotWant = b - return assert(a !== b, message, extra) -} -assert.inequal = inequal -syns.inequal = ["notEqual" - ,"notEquals" - ,"isNotEqual" - ,"isNot" - ,"not" - ,"doesNotEqual" - ,"isInequal"] - - -function inequivalent (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should not be equivalent" - extra.found = a - extra.doNotWant = b - return assert(stringify(a) !== stringify(b), message, extra) -} -assert.inequivalent = inequivalent -syns.inequivalent = ["notEquivalent" - ,"notDeepEqual" - ,"notDeeply" - ,"isNotDeepEqual" - ,"isNotDeeply" - ,"isNotEquivalent" - ,"isInequivalent"] - -function similar (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - // test that a has all the fields in b - message = message || "should be similar" - return equivalent(selectFields(a, b), b, message, extra) -} -assert.similar = similar -syns.similar = ["isSimilar" - ,"has" - ,"hasFields" - ,"like" - ,"isLike"] - -function dissimilar (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - // test that a has all the fields in b - message = message || "should be dissimilar" - return inequivalent(selectFields(a, b), b, message, extra) -} -assert.dissimilar = dissimilar -syns.dissimilar = ["unsimilar" - ,"notSimilar" - ,"unlike" - ,"isUnlike" - ,"notLike" - ,"isNotLike" - ,"doesNotHave" - ,"isNotSimilar" - ,"isDissimilar"] - -function type (thing, t, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var name = t - if (typeof name === "function") name = name.name || "(anonymous ctor)" - //console.error("name=%s", name) - message = message || "type is "+name - var type = typeof thing - //console.error("type=%s", type) - if (!thing && type === "object") type = "null" - if (type === "object" && t !== "object") { - if (typeof t === "function") { - //console.error("it is a function!") - extra = extra || {} - extra.found = Object.getPrototypeOf(thing).constructor.name - extra.wanted = name - //console.error(thing instanceof t, name) - return assert.ok(thing instanceof t, message, extra) - } - - //console.error("check prototype chain") - // check against classnames or objects in prototype chain, as well. - // type(new Error("asdf"), "Error") - // type(Object.create(foo), foo) - var p = thing - while (p = Object.getPrototypeOf(p)) { - if (p === t || p.constructor && p.constructor.name === t) { - type = name - break - } - } - } - //console.error(type, name, type === name) - return assert.equal(type, name, message, extra) -} -assert.type = type -syns.type = ["isa"] - -// synonyms are helpful. -Object.keys(syns).forEach(function (c) { - syns[c].forEach(function (s) { - Object.defineProperty(assert, s, { value: assert[c], enumerable: false }) - }) -}) - -// helpers below - -function selectFields (a, b) { - // get the values in A of the fields in B - var ret = Array.isArray(b) ? [] : {} - Object.keys(b).forEach(function (k) { - if (!a.hasOwnProperty(k)) return - var v = b[k] - , av = a[k] - if (v && av && typeof v === "object" && typeof av === "object") { - ret[k] = selectFields(av, v) - } else ret[k] = av - }) - return ret -} - -function stringify (a) { - return JSON.stringify(a, (function () { - var seen = [] - , keys = [] - return function (key, val) { - var s = seen.indexOf(val) - if (s !== -1) { - return "[Circular: "+keys[s]+"]" - } - if (val && typeof val === "object" || typeof val === "function") { - seen.push(val) - keys.push(val["!"] || val.name || key || "") - if (typeof val === "function") { - return val.toString().split(/\n/)[0] - } - var proto = Object.getPrototypeOf(val) - } - return val - }})()) -} - -function diffString (f, w) { - if (w === f) return null - var p = 0 - , l = w.length - while (p < l && w.charAt(p) === f.charAt(p)) p ++ - w = stringify(w).substr(1).replace(/"$/, "") - f = stringify(f).substr(1).replace(/"$/, "") - return diff(f, w, p) -} - -function diffObject (f, w) { - var f = stringify(f) - , w = stringify(w) - , l = w.length - if (f === w) return null - var p = 0 - while (p < l && f.charAt(p) === w.charAt(p)) p ++ - return diff(f, w, p) -} - -function diff (f, w, p) { - if (w === f) return null - var i = p || 0 // it's going to be at least p. JSON can only be bigger. - , l = w.length - while (i < l && w.charAt(i) === f.charAt(i)) i ++ - var pos = Math.max(0, i - 20) - w = w.substr(pos, 40) - f = f.substr(pos, 40) - var pointer = i - pos - return "FOUND: "+f+"\n" - + "WANTED: "+w+"\n" - + (new Array(pointer + 9).join(" ")) - + "^ (at position = "+p+")" -} - -function getCaller (er) { - // get the first file/line that isn't this file. - if (!er) er = new Error - var stack = er.stack || "" - stack = stack.split(/\n/) - for (var i = 1, l = stack.length; i < l; i ++) { - var s = stack[i].match(/\(([^):]+):([0-9]+):([0-9]+)\)$/) - if (!s) continue - var file = s[1] - , line = +s[2] - , col = +s[3] - if (file.indexOf(__dirname) === 0) continue - if (file.match(/tap-test\/test.js$/)) continue - else break - } - var res = {} - if (file && file !== __filename && !file.match(/tap-test\/test.js$/)) { - res.file = file - res.line = line - res.column = col - } - - res.stack = stack.slice(1).map(function (s) { - return s.replace(/^\s*at\s*/, "") - }) - - return res -} - - http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-assert/package.json ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-assert/package.json b/node_modules/nodeunit/node_modules/tap-assert/package.json deleted file mode 100644 index bfc2c5c..0000000 --- a/node_modules/nodeunit/node_modules/tap-assert/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "tap-assert", - "version": "0.0.10", - "description": "An assertion module that returns TAP result objects", - "main": "./assert.js", - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/tap-assert.git" - }, - "keywords": [ - "assert", - "test", - "tap" - ], - "license": { - "type": "MIT", - "url": "https://github.com/isaacs/tap-assert/raw/master/LICENSE" - }, - "contributors": [ - "Isaac Z. Schlueter (http://blog.izs.me)", - "baudehlo " - ], - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": "*" - } -} http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/README.md ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/README.md b/node_modules/nodeunit/node_modules/tap-producer/README.md deleted file mode 100644 index bd96254..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Sometimes, you need to produce some TAPs. - -Not like when you go to the store, and check to see if the melons are -ripe. That's tapping on produce. This is different. http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/README.md ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/README.md b/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/README.md deleted file mode 100644 index b2beaed..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/README.md +++ /dev/null @@ -1,51 +0,0 @@ -A dead simple way to do inheritance in JS. - - var inherits = require("inherits") - - function Animal () { - this.alive = true - } - Animal.prototype.say = function (what) { - console.log(what) - } - - inherits(Dog, Animal) - function Dog () { - Dog.super.apply(this) - } - Dog.prototype.sniff = function () { - this.say("sniff sniff") - } - Dog.prototype.bark = function () { - this.say("woof woof") - } - - inherits(Chihuahua, Dog) - function Chihuahua () { - Chihuahua.super.apply(this) - } - Chihuahua.prototype.bark = function () { - this.say("yip yip") - } - - // also works - function Cat () { - Cat.super.apply(this) - } - Cat.prototype.hiss = function () { - this.say("CHSKKSS!!") - } - inherits(Cat, Animal, { - meow: function () { this.say("miao miao") } - }) - Cat.prototype.purr = function () { - this.say("purr purr") - } - - - var c = new Chihuahua - assert(c instanceof Chihuahua) - assert(c instanceof Dog) - assert(c instanceof Animal) - -The actual function is laughably small. 10-lines small. http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/inherits.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/inherits.js b/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/inherits.js deleted file mode 100644 index 061b396..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/inherits.js +++ /dev/null @@ -1,29 +0,0 @@ -module.exports = inherits - -function inherits (c, p, proto) { - proto = proto || {} - var e = {} - ;[c.prototype, proto].forEach(function (s) { - Object.getOwnPropertyNames(s).forEach(function (k) { - e[k] = Object.getOwnPropertyDescriptor(s, k) - }) - }) - c.prototype = Object.create(p.prototype, e) - c.super = p -} - -//function Child () { -// Child.super.call(this) -// console.error([this -// ,this.constructor -// ,this.constructor === Child -// ,this.constructor.super === Parent -// ,Object.getPrototypeOf(this) === Child.prototype -// ,Object.getPrototypeOf(Object.getPrototypeOf(this)) -// === Parent.prototype -// ,this instanceof Child -// ,this instanceof Parent]) -//} -//function Parent () {} -//inherits(Child, Parent) -//new Child http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/package.json ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/package.json b/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/package.json deleted file mode 100644 index 5beb005..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/node_modules/inherits/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ "name" : "inherits" -, "description": "A tiny simple way to do classic inheritance in js" -, "version" : "1.0.0" -, "keywords" : ["inheritance", "class", "klass", "oop", "object-oriented"] -, "main" : "./inherits.js" -, "repository" : "https://github.com/isaacs/inherits" -, "author" : "Isaac Z. Schlueter (http://blog.izs.me/)" } http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/README.md ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/README.md b/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/README.md deleted file mode 100644 index 6a00fc9..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/README.md +++ /dev/null @@ -1,2 +0,0 @@ -This is a module for keeping track of tap result objects, counting them -up, etc. http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/package.json ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/package.json b/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/package.json deleted file mode 100644 index 1882b77..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "tap-results", - "version": "0.0.2", - "description": "A util for keeping track of tap result objects", - "main": "./results.js", - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", - "repository": "https://github.com/isaacs/tap-results", - "dependencies": { - "inherits": "~1.0.0" - } -} http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/results.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/results.js b/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/results.js deleted file mode 100644 index 46ef2e5..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/node_modules/tap-results/results.js +++ /dev/null @@ -1,68 +0,0 @@ -// A class for counting up results in a test harness. - -module.exports = Results - -var inherits = require("inherits") - , EventEmitter = require("events").EventEmitter - -inherits(Results, EventEmitter) - -function Results (r) { - //console.error("result constructor", r) - this.ok = true - this.addSet(r) -} - -Results.prototype.addSet = function (r) { - //console.error("add set of results", r) - r = r || {ok: true} - ; [ "todo" - , "todoPass" - , "todoFail" - , "skip" - , "skipPass" - , "skipFail" - , "pass" - , "passTotal" - , "fail" - , "failTotal" - , "tests" - , "testsTotal" ].forEach(function (k) { - this[k] = (this[k] || 0) + (r[k] || 0) - //console.error([k, this[k]]) - }, this) - - this.ok = this.ok && r.ok && true - this.bailedOut = this.bailedOut || r.bailedOut || false - this.list = (this.list || []).concat(r.list || []) - this.emit("set", this.list) - //console.error("after addSet", this) -} - -Results.prototype.add = function (r, addToList) { - //console.error("add result", r) - var pf = r.ok ? "pass" : "fail" - , PF = r.ok ? "Pass" : "Fail" - - this.testsTotal ++ - this[pf + "Total"] ++ - - if (r.skip) { - this["skip" + PF] ++ - this.skip ++ - } else if (r.todo) { - this["todo" + PF] ++ - this.todo ++ - } else { - this.tests ++ - this[pf] ++ - } - - if (r.bailout || typeof r.bailout === "string") this.bailedOut = true - this.ok = !!(this.ok && r.ok) - - if (addToList === false) return - this.list = this.list || [] - this.list.push(r) - this.emit("result", r) -} http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/LICENSE ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/LICENSE b/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/LICENSE deleted file mode 100644 index 187e8db..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2011 Isaac Z. Schlueter - -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 OR COPYRIGHT HOLDERS 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. http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/README.md ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/README.md b/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/README.md deleted file mode 100644 index 954d063..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/README.md +++ /dev/null @@ -1,20 +0,0 @@ -This is a thingie to parse the "yamlish" format used to serialize -objects in the TAP format. - -It's like yaml, but just a tiny little bit smaller. - -Usage: - - var yamlish = require("yamlish") - // returns a string like: - /* - some: - object: - - full - - of - pretty: things - */ - yamlish.encode({some:{object:["full", "of"]}, pretty:"things"}) - - // returns the object - yamlish.decode(someYamlishString) http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/package.json ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/package.json b/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/package.json deleted file mode 100644 index fb24483..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ "name" : "yamlish" -, "description" : "Parser/encoder for the yamlish format" -, "repository":"https://github.com/isaacs/yamlish" -, "version" : "0.0.2" -, "main" : "yamlish.js" -, "keywords" : [ "yaml", "yamlish", "test", "anything", "protocol", "tap"] -, "license" : { "type" : "MIT" - , "url" : "http://github.com/isaacs/yamlish/raw/master/LICENSE" } -, "author" : "Isaac Z. Schlueter (http://blog.izs.me/)" } http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/yamlish.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/yamlish.js b/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/yamlish.js deleted file mode 100644 index 7aec41f..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/node_modules/yamlish/yamlish.js +++ /dev/null @@ -1,221 +0,0 @@ -exports.encode = encode -exports.decode = decode - -var seen = [] -function encode (obj, indent) { - var deep = arguments[2] - if (!indent) indent = " " - - // take out the easy ones. - switch (typeof obj) { - case "string": - obj = obj.trim() - if (obj.indexOf("\n") !== -1) { - return "|\n" + indent + obj.split(/\r?\n/).join("\n"+indent) - } else return obj - - case "number": - return obj.toString(10) - - case "function": - return encode(obj.toString(), indent, true) - - case "boolean": - return obj.toString() - - case "undefined": - // fallthrough - case "object": - // at this point we know it types as an object - if (!obj) return "~" - - if (obj instanceof Date) return obj.toISOString() - - if (seen.indexOf(obj) !== -1) { - return "[Circular]" - } - seen.push(obj) - - if (typeof Buffer === "function" && - typeof Buffer.isBuffer === "function" && - Buffer.isBuffer(obj)) return obj.inspect() - - if (obj instanceof Error) { - var o = { name: obj.name - , message: obj.message - , type: obj.type } - - if (obj.code) o.code = obj.code - if (obj.errno) o.errno = obj.errno - if (obj.type) o.type = obj.type - obj = o - } - - var out = "" - - if (Array.isArray(obj)) { - var out = "\n" + indent + "- " +obj.map(function (item) { - return encode(item, indent + " ", true) - }).join("\n"+indent + "- ") - break - } - - // an actual object - var keys = Object.keys(obj) - , niceKeys = keys.map(function (k) { - return (k.match(/^[a-zA-Z0-9_]+$/) ? k : JSON.stringify(k)) + ": " - }) - //console.error(keys, niceKeys, obj) - var maxLength = Math.max.apply(Math, niceKeys.map(function (k) { - return k.length - }).concat(0)) - //console.error(niceKeys, maxLength) - - var spaces = new Array(maxLength + 1).join(" ") - - if (!deep) indent += " " - out = "\n" + indent + keys.map(function (k, i) { - var niceKey = niceKeys[i] - return niceKey + spaces.substr(niceKey.length) - + encode(obj[k], indent + " ", true) - }).join("\n" + indent) - break - - default: return "" - } - if (!deep) seen.length = 0 - return out -} - -function decode (str) { - var v = str.trim() - , d - if (v === "~") return null - if (v.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}/) - && (d = Date.parse(v))) { - return new Date(d) - } - if (v === "true" || v === "false") return JSON.parse(v) - if (v && !isNaN(v)) return parseInt(v, 10) - // something interesting. - var lines = str.split(/\r?\n/) - // check if it's some kind of string or something. - // if the first line is > or | then it's a wrapping indented string. - // if the first line is blank, and there are many lines, - // then it's an array or object. - // otherwise, it's just "" - var first = lines.shift().trim() - if (lines.length) lines = undent(lines) - switch (first) { - case "|": - return lines.join("\n") - case ">": - return lines.join("\n").split(/\n{2,}/).map(function (l) { - return l.split(/\n/).join(" ") - }).join("\n") - default: - if (!lines.length) return first - // array or object. - // the first line will be either "- value" or "key: value" - return lines[0].charAt(0) === "-" ? decodeArr(lines) : decodeObj(lines) - } -} - -function decodeArr (lines) { - var out = [] - , key = 0 - , val = [] - for (var i = 0, l = lines.length; i < l; i ++) { - // if it starts with a -, then it's a new thing - var line = lines[i] - if (line.charAt(0) === "-") { - if (val.length) { - out[key ++] = decode(val.join("\n")) - val.length = 0 - } - val.push(line.substr(1).trim()) - } else if (line.charAt(0) === " ") { - val.push(line) - } else return [] - } - if (val.length) { - out[key ++] = decode(val.join("\n")) - } - return out -} - -function decodeObj (lines) { - var out = {} - , val = [] - , key = null - - for (var i = 0, l = lines.length; i < l; i ++) { - var line = lines[i] - if (line.charAt(0) === " ") { - val.push(line) - continue - } - // some key:val - if (val.length) { - out[key] = decode(val.join("\n")) - val.length = 0 - } - // parse out the quoted key - var first - if (line.charAt(0) === "\"") { - for (var ii = 1, ll = line.length, esc = false; ii < ll; ii ++) { - var c = line.charAt(ii) - if (c === "\\") { - esc = !esc - } else if (c === "\"" && !esc) { - break - } - } - key = JSON.parse(line.substr(0, ii + 1)) - line = line.substr(ii + 1) - first = line.substr(line.indexOf(":") + 1).trim() - } else { - var kv = line.split(":") - key = kv.shift() - first = kv.join(":").trim() - } - // now we've set a key, and "first" has the first line of the value. - val.push(first.trim()) - } - if (val.length) out[key] = decode(val.join("\n")) - return out -} - -function undent (lines) { - var i = lines[0].match(/^\s*/)[0].length - return lines.map(function (line) { - return line.substr(i) - }) -} - - - -if (require.main === module) { -var obj = [{"bigstring":new Error().stack} - ,{ar:[{list:"of"},{some:"objects"}]} - ,{date:new Date()} - ,{"super huge string":new Error().stack} - ] - -Date.prototype.toJSON = function (k, val) { - console.error(k, val, this) - return this.toISOString() + " (it's a date)" -} -var enc = encode(obj) - , dec = decode(enc) - , encDec = encode(dec) - -console.error(JSON.stringify({ obj : obj - , enc : enc.split(/\n/) - , dec : dec }, null, 2), encDec === enc) - -var num = 100 - , encNum = encode(num) - , decEncNum = decode(encNum) -console.error([num, encNum, decEncNum]) -} http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/package.json ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/package.json b/node_modules/nodeunit/node_modules/tap-producer/package.json deleted file mode 100644 index 6e6238f..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ "name" : "tap-producer" -, "version" : "0.0.1" -, "description" : "A module for producing TAP output" -, "main" : "./tap-producer.js" -, "author" : "Isaac Z. Schlueter (http://blog.izs.me/)" -, "repository" : "https://github.com/isaacs/tap-producer" -, "dependencies" : - { "inherits" : "*" - , "tap-results" : "0.x" - , "yamlish" : "*" - } -} http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/node_modules/tap-producer/tap-producer.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/node_modules/tap-producer/tap-producer.js b/node_modules/nodeunit/node_modules/tap-producer/tap-producer.js deleted file mode 100644 index 6aaa8c1..0000000 --- a/node_modules/nodeunit/node_modules/tap-producer/tap-producer.js +++ /dev/null @@ -1,113 +0,0 @@ -module.exports = TapProducer - -var Results = require("tap-results") - , inherits = require("inherits") - , yamlish = require("yamlish") - -TapProducer.encode = function (result, diag) { - var tp = new TapProducer(diag) - , out = "" - tp.on("data", function (c) { out += c }) - if (Array.isArray(result)) { - result.forEach(tp.write, tp) - } else tp.write(result) - tp.end() - return out -} - -inherits(TapProducer, require("stream").Stream) -function TapProducer (diag) { - TapProducer.super.call(this) - this.diag = diag - this.count = 0 - this.readable = this.writable = true - this.results = new Results -} - -TapProducer.prototype.trailer = true - -TapProducer.prototype.write = function (res) { - // console.error("TapProducer.write", res) - if (typeof res === "function") throw new Error("wtf?") - if (!this.writable) this.emit("error", new Error("not writable")) - - var diag = res.diag - if (diag === undefined) diag = this.diag - - this.emit("data", encodeResult(res, this.count + 1, diag)) - - if (typeof res === "string") return true - - this.results.add(res, false) - this.count ++ -} - -TapProducer.prototype.end = function (res) { - if (res) this.write(res) - this.emit("data", "\n1.."+this.results.testsTotal+"\n") - if (this.trailer && typeof this.trailer !== "string") { - // summary trailer. - var trailer = "tests "+this.results.testsTotal + "\n" - if (this.results.pass) { - trailer += "pass " + this.results.pass + "\n" - } - if (this.results.fail) { - trailer += "fail " + this.results.fail + "\n" - } - if (this.results.skip) { - trailer += "skip "+this.results.skip + "\n" - } - if (this.results.todo) { - trailer += "todo "+this.results.todo + "\n" - } - if (this.results.bailedOut) { - trailer += "bailed out" + "\n" - } - - if (this.results.testsTotal === this.results.pass) { - trailer += "\nok\n" - } - this.trailer = trailer - } - if (this.trailer) this.write(this.trailer) - this.writable = false - this.emit("end", null, this.count, this.ok) -} - -function encodeResult (res, count, diag) { - if (typeof res === "string") { - res = res.split(/\r?\n/).map(function (l) { - if (!l.trim()) return l.trim() - return "# " + l - }).join("\n") - if (res.substr(-1) !== "\n") res += "\n" - return res - } - - if (!!process.env.TAP_NODIAG) diag = false - else if (!!process.env.TAP_DIAG) diag = true - else if (diag === undefined) diag = !res.ok - - var output = "" - res.name = res.name && res.name.trim() - output += ( !res.ok ? "not " : "") + "ok " + count - + ( !res.name ? "" - : " " + res.name.replace(/[\r\n]/, " ") ) - + ( res.skip ? " # SKIP" - : res.todo ? " # TODO" - : "" ) - + "\n" - - if (!diag) return output - var d = {} - , dc = 0 - Object.keys(res).filter(function (k) { - return k !== "ok" && k !== "name" && k !== "id" - }).forEach(function (k) { - dc ++ - d[k] = res[k] - }) - //console.error(d, "about to encode") - if (dc > 0) output += " ---"+yamlish.encode(d)+"\n ...\n" - return output -} http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/nodelint.cfg ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/nodelint.cfg b/node_modules/nodeunit/nodelint.cfg deleted file mode 100644 index d6a3aad..0000000 --- a/node_modules/nodeunit/nodelint.cfg +++ /dev/null @@ -1,7 +0,0 @@ -//See: http://www.jslint.com/lint.html#options -var options = { - //white: false, // if false, strict whitespace rules should be enforced. - indent: 4, - onevar: false, - vars: true // allow multiple var statement per function. -}; http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/package.json ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/package.json b/node_modules/nodeunit/package.json deleted file mode 100644 index 6a5d86e..0000000 --- a/node_modules/nodeunit/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ "name": "nodeunit" -, "description": "Easy unit testing for node.js and the browser." -, "maintainers": - [ { "name": "Caolan McMahon" - , "web": "https://github.com/caolan" - } - ] -, "contributors" : - [ { "name": "Romain Beauxis" - , "web": "https://github.com/toots" - } - , { "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 ", - "web": "http://tmpvar.com" - } - ] -, "version": "0.6.4" -, "repository" : - { "type" : "git" - , "url" : "http://github.com/caolan/nodeunit.git" - } -, "devDependencies": - { "uglify-js": ">=1.1.0" } -, "bugs" : { "url" : "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" } -, "dependencies" : - { "tap-assert": ">=0.0.9" - , "tap-producer": ">=0.0.1" - } -} http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/share/junit.xml.ejs ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/share/junit.xml.ejs b/node_modules/nodeunit/share/junit.xml.ejs deleted file mode 100644 index c1db5bb..0000000 --- a/node_modules/nodeunit/share/junit.xml.ejs +++ /dev/null @@ -1,19 +0,0 @@ - -<% for (var i=0; i < suites.length; i++) { %> - <% var suite=suites[i]; %> - - <% for (var j=0; j < suite.testcases.length; j++) { %> - <% var testcase=suites[i].testcases[j]; %> - - <% if (testcase.failure) { %> - - <% if (testcase.failure.backtrace) { %><%= testcase.failure.backtrace %><% } %> - - <% } %> - - <% } %> - -<% } %> http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/share/license.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/share/license.js b/node_modules/nodeunit/share/license.js deleted file mode 100644 index f0f326f..0000000 --- a/node_modules/nodeunit/share/license.js +++ /dev/null @@ -1,11 +0,0 @@ -/*! - * 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-coho/blob/1d113e44/node_modules/nodeunit/share/nodeunit.css ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/share/nodeunit.css b/node_modules/nodeunit/share/nodeunit.css deleted file mode 100644 index 274434a..0000000 --- a/node_modules/nodeunit/share/nodeunit.css +++ /dev/null @@ -1,70 +0,0 @@ -/*! - * 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-coho/blob/1d113e44/node_modules/nodeunit/test/fixtures/coffee/mock_coffee_module.coffee ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/fixtures/coffee/mock_coffee_module.coffee b/node_modules/nodeunit/test/fixtures/coffee/mock_coffee_module.coffee deleted file mode 100644 index a1c069b..0000000 --- a/node_modules/nodeunit/test/fixtures/coffee/mock_coffee_module.coffee +++ /dev/null @@ -1,4 +0,0 @@ -j = 0 -j += i for i in [0..5] - -exports.name = "mock_coffee_#{j}" http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/fixtures/dir/mock_module3.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/fixtures/dir/mock_module3.js b/node_modules/nodeunit/test/fixtures/dir/mock_module3.js deleted file mode 100644 index 3021776..0000000 --- a/node_modules/nodeunit/test/fixtures/dir/mock_module3.js +++ /dev/null @@ -1 +0,0 @@ -exports.name = 'mock_module3'; http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/fixtures/dir/mock_module4.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/fixtures/dir/mock_module4.js b/node_modules/nodeunit/test/fixtures/dir/mock_module4.js deleted file mode 100644 index 876f9ca..0000000 --- a/node_modules/nodeunit/test/fixtures/dir/mock_module4.js +++ /dev/null @@ -1 +0,0 @@ -exports.name = 'mock_module4'; http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/fixtures/mock_module1.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/fixtures/mock_module1.js b/node_modules/nodeunit/test/fixtures/mock_module1.js deleted file mode 100644 index 4c093ad..0000000 --- a/node_modules/nodeunit/test/fixtures/mock_module1.js +++ /dev/null @@ -1 +0,0 @@ -exports.name = 'mock_module1'; http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/fixtures/mock_module2.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/fixtures/mock_module2.js b/node_modules/nodeunit/test/fixtures/mock_module2.js deleted file mode 100644 index a63d012..0000000 --- a/node_modules/nodeunit/test/fixtures/mock_module2.js +++ /dev/null @@ -1 +0,0 @@ -exports.name = 'mock_module2'; http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/fixtures/raw_jscode1.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/fixtures/raw_jscode1.js b/node_modules/nodeunit/test/fixtures/raw_jscode1.js deleted file mode 100644 index 2ef7115..0000000 --- a/node_modules/nodeunit/test/fixtures/raw_jscode1.js +++ /dev/null @@ -1,3 +0,0 @@ -function hello_world(arg) { - return "_" + arg + "_"; -} http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/fixtures/raw_jscode2.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/fixtures/raw_jscode2.js b/node_modules/nodeunit/test/fixtures/raw_jscode2.js deleted file mode 100644 index 55a764e..0000000 --- a/node_modules/nodeunit/test/fixtures/raw_jscode2.js +++ /dev/null @@ -1,3 +0,0 @@ -function get_a_variable() { - return typeof a_variable; -} http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/fixtures/raw_jscode3.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/fixtures/raw_jscode3.js b/node_modules/nodeunit/test/fixtures/raw_jscode3.js deleted file mode 100644 index 1fd1e78..0000000 --- a/node_modules/nodeunit/test/fixtures/raw_jscode3.js +++ /dev/null @@ -1 +0,0 @@ -var t=t?t+1:1; http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/test-base.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/test-base.js b/node_modules/nodeunit/test/test-base.js deleted file mode 100644 index 64b8c8b..0000000 --- a/node_modules/nodeunit/test/test-base.js +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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-coho/blob/1d113e44/node_modules/nodeunit/test/test-failing-callbacks.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/test-failing-callbacks.js b/node_modules/nodeunit/test/test-failing-callbacks.js deleted file mode 100644 index 08f7eb5..0000000 --- a/node_modules/nodeunit/test/test-failing-callbacks.js +++ /dev/null @@ -1,114 +0,0 @@ -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-coho/blob/1d113e44/node_modules/nodeunit/test/test-httputil.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/test-httputil.js b/node_modules/nodeunit/test/test-httputil.js deleted file mode 100644 index e5ee25c..0000000 --- a/node_modules/nodeunit/test/test-httputil.js +++ /dev/null @@ -1,55 +0,0 @@ -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(); - }); - }); -}; http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/test-runfiles.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/test-runfiles.js b/node_modules/nodeunit/test/test-runfiles.js deleted file mode 100644 index ce1a4cd..0000000 --- a/node_modules/nodeunit/test/test-runfiles.js +++ /dev/null @@ -1,214 +0,0 @@ -var assert = require('assert'), - fs = require('fs'), - path = require('path'), - nodeunit = require('../lib/nodeunit'); - - -var setup = function (fn) { - return function (test) { - process.chdir(__dirname); - var env = { - mock_module1: require(__dirname + '/fixtures/mock_module1'), - mock_module2: require(__dirname + '/fixtures/mock_module2'), - mock_module3: require(__dirname + '/fixtures/dir/mock_module3'), - mock_module4: require(__dirname + '/fixtures/dir/mock_module4') - }; - fn.call(env, test); - }; -}; - - -exports.testRunFiles = setup(function (test) { - test.expect(24); - var runModule_copy = nodeunit.runModule; - - var runModule_calls = []; - var modules = []; - - var opts = { - moduleStart: function () { - return 'moduleStart'; - }, - testDone: function () { - return 'testDone'; - }, - testStart: function () { - return 'testStart'; - }, - log: function () { - return 'log'; - }, - done: function (assertions) { - test.equals(assertions.failures(), 0, 'failures'); - test.equals(assertions.length, 4, 'length'); - test.ok(typeof assertions.duration === "number"); - - var called_with = function (name) { - return runModule_calls.some(function (m) { - return m.name === name; - }); - }; - test.ok(called_with('mock_module1'), 'mock_module1 ran'); - test.ok(called_with('mock_module2'), 'mock_module2 ran'); - test.ok(called_with('mock_module3'), 'mock_module3 ran'); - test.ok(called_with('mock_module4'), 'mock_module4 ran'); - test.equals(runModule_calls.length, 4); - - nodeunit.runModule = runModule_copy; - test.done(); - } - }; - - nodeunit.runModule = function (name, mod, options, callback) { - test.equals(options.testDone, opts.testDone); - test.equals(options.testStart, opts.testStart); - test.equals(options.log, opts.log); - test.ok(typeof name === "string"); - runModule_calls.push(mod); - var m = [{failed: function () { - return false; - }}]; - modules.push(m); - callback(null, m); - }; - - nodeunit.runFiles( - [__dirname + '/fixtures/mock_module1.js', - __dirname + '/fixtures/mock_module2.js', - __dirname + '/fixtures/dir'], - opts - ); -}); - -exports.testRunFilesEmpty = function (test) { - test.expect(3); - nodeunit.runFiles([], { - moduleStart: function () { - test.ok(false, 'should not be called'); - }, - testDone: function () { - test.ok(false, 'should not be called'); - }, - testStart: function () { - test.ok(false, 'should not be called'); - }, - log: function () { - test.ok(false, 'should not be called'); - }, - done: function (assertions) { - test.equals(assertions.failures(), 0, 'failures'); - test.equals(assertions.length, 0, 'length'); - test.ok(typeof assertions.duration === "number"); - test.done(); - } - }); -}; - - -exports.testEmptyDir = function (test) { - var dir2 = __dirname + '/fixtures/dir2'; - - // git doesn't like empty directories, so we have to create one - path.exists(dir2, function (exists) { - if (!exists) { - fs.mkdirSync(dir2, 0777); - } - - // runFiles on empty directory: - nodeunit.runFiles([dir2], { - moduleStart: function () { - test.ok(false, 'should not be called'); - }, - testDone: function () { - test.ok(false, 'should not be called'); - }, - testStart: function () { - test.ok(false, 'should not be called'); - }, - log: function () { - test.ok(false, 'should not be called'); - }, - done: function (assertions) { - test.equals(assertions.failures(), 0, 'failures'); - test.equals(assertions.length, 0, 'length'); - test.ok(typeof assertions.duration === "number"); - test.done(); - } - }); - }); -}; - - -var CoffeeScript; -try { - CoffeeScript = require('coffee-script'); -} catch (e) { -} - -if (CoffeeScript) { - exports.testCoffeeScript = function (test) { - process.chdir(__dirname); - var env = { - mock_coffee_module: require(__dirname + - '/fixtures/coffee/mock_coffee_module') - }; - - test.expect(9); - var runModule_copy = nodeunit.runModule; - - var runModule_calls = []; - var modules = []; - - var opts = { - moduleStart: function () { - return 'moduleStart'; - }, - testDone: function () { - return 'testDone'; - }, - testStart: function () { - return 'testStart'; - }, - log: function () { - return 'log'; - }, - done: function (assertions) { - test.equals(assertions.failures(), 0, 'failures'); - test.equals(assertions.length, 1, 'length'); - test.ok(typeof assertions.duration === "number"); - - var called_with = function (name) { - return runModule_calls.some(function (m) { - return m.name === name; - }); - }; - test.ok( - called_with('mock_coffee_15'), - 'mock_coffee_module ran' - ); - test.equals(runModule_calls.length, 1); - - nodeunit.runModule = runModule_copy; - test.done(); - } - }; - - nodeunit.runModule = function (name, mod, options, callback) { - test.equals(options.testDone, opts.testDone); - test.equals(options.testStart, opts.testStart); - test.equals(options.log, opts.log); - test.ok(typeof name === "string"); - runModule_calls.push(mod); - var m = [{failed: function () { - return false; - }}]; - modules.push(m); - callback(null, m); - }; - - nodeunit.runFiles( - [__dirname + 'fixtures/coffee/mock_coffee_module.coffee'], - opts - ); - }; -} http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/test-runmodule.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/test-runmodule.js b/node_modules/nodeunit/test/test-runmodule.js deleted file mode 100644 index d07b47c..0000000 --- a/node_modules/nodeunit/test/test-runmodule.js +++ /dev/null @@ -1,177 +0,0 @@ -/* 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 nodeunit = require('../lib/nodeunit'); // @REMOVE_LINE_FOR_BROWSER - - -exports.testRunModule = function (test) { - test.expect(11); - var call_order = []; - var testmodule = { - test1: function (test) { - call_order.push('test1'); - test.ok(true, 'ok true'); - test.done(); - }, - test2: function (test) { - call_order.push('test2'); - test.ok(false, 'ok false'); - test.ok(false, 'ok false'); - test.done(); - }, - test3: function (test) { - call_order.push('test3'); - test.done(); - } - }; - nodeunit.runModule('testmodule', testmodule, { - log: function (assertion) { - call_order.push('log'); - }, - testStart: function (name) { - call_order.push('testStart'); - test.ok( - name.toString() === 'test1' || - name.toString() === 'test2' || - name.toString() === 'test3', - 'testStart called with test name ' - ); - }, - testDone: function (name, assertions) { - call_order.push('testDone'); - test.ok( - name.toString() === 'test1' || - name.toString() === 'test2' || - name.toString() === 'test3', - 'testDone called with test name' - ); - }, - moduleDone: function (name, assertions) { - call_order.push('moduleDone'); - test.equals(assertions.length, 3); - test.equals(assertions.failures(), 2); - test.equals(name, 'testmodule'); - test.ok(typeof assertions.duration === "number"); - test.same(call_order, [ - 'testStart', 'test1', 'log', 'testDone', - 'testStart', 'test2', 'log', 'log', 'testDone', - 'testStart', 'test3', 'testDone', - 'moduleDone' - ]); - } - }, test.done); -}; - - -exports.testRunModuleTestSpec = function (test) { - test.expect(6); - var call_order = []; - var testmodule = { - test1: function (test) { - test.ok(true, 'ok true'); - test.done(); - }, - test2: function (test) { - call_order.push('test2'); - test.ok(false, 'ok false'); - test.ok(false, 'ok false'); - test.done(); - }, - test3: function (test) { - test.done(); - } - }; - nodeunit.runModule('testmodule', testmodule, { - testspec: "test2", - log: function (assertion) { - call_order.push('log'); - }, - testStart: function (name) { - call_order.push('testStart'); - test.ok( - name.toString() === 'test2', - 'testStart called with test name ' - ); - }, - testDone: function (name, assertions) { - call_order.push('testDone'); - test.ok( - name.toString() === 'test2', - 'testDone called with test name' - ); - }, - moduleDone: function (name, assertions) { - call_order.push('moduleDone'); - test.equals(assertions.length, 2); - test.equals(name, 'testmodule'); - test.ok(typeof assertions.duration === "number"); - test.same(call_order, [ - 'testStart', 'test2', 'log', 'log', 'testDone', - 'moduleDone' - ]); - } - }, test.done); -}; - -exports.testRunModuleEmpty = function (test) { - nodeunit.runModule('module with no exports', {}, { - log: function (assertion) { - test.ok(false, 'log should not be called'); - }, - testStart: function (name) { - test.ok(false, 'testStart should not be called'); - }, - testDone: function (name, assertions) { - test.ok(false, 'testDone should not be called'); - }, - moduleDone: function (name, assertions) { - test.equals(assertions.length, 0); - test.equals(assertions.failures(), 0); - test.equals(name, 'module with no exports'); - test.ok(typeof assertions.duration === "number"); - } - }, test.done); -}; - - -exports.testNestedTests = function (test) { - var call_order = []; - var m = { - test1: function (test) { - test.done(); - }, - suite: { - t1: function (test) { - test.done(); - }, - t2: function (test) { - test.done(); - }, - another_suite: { - t3: function (test) { - test.done(); - } - } - } - }; - nodeunit.runModule('modulename', m, { - testStart: function (name) { - call_order.push(['testStart'].concat(name)); - }, - testDone: function (name, assertions) { - call_order.push(['testDone'].concat(name)); - } - }, function () { - test.same(call_order, [ - ['testStart', 'test1'], ['testDone', 'test1'], - ['testStart', 'suite', 't1'], ['testDone', 'suite', 't1'], - ['testStart', 'suite', 't2'], ['testDone', 'suite', 't2'], - ['testStart', 'suite', 'another_suite', 't3'], - ['testDone', 'suite', 'another_suite', 't3'] - ]); - test.done(); - }); -}; http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/test-runtest.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/test-runtest.js b/node_modules/nodeunit/test/test-runtest.js deleted file mode 100644 index 8fc3d52..0000000 --- a/node_modules/nodeunit/test/test-runtest.js +++ /dev/null @@ -1,46 +0,0 @@ -/* 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 nodeunit = require('../lib/nodeunit'); // @REMOVE_LINE_FOR_BROWSER - - -exports.testArgs = function (test) { - test.ok(test.expect instanceof Function, 'test.expect'); - test.ok(test.done instanceof Function, 'test.done'); - test.ok(test.ok instanceof Function, 'test.ok'); - test.ok(test.same instanceof Function, 'test.same'); - test.ok(test.equals instanceof Function, 'test.equals'); - test.done(); -}; - -exports.testDoneCallback = function (test) { - test.expect(4); - nodeunit.runTest('testname', exports.testArgs, { - testDone: function (name, assertions) { - test.equals(assertions.failures(), 0, 'failures'); - test.equals(assertions.length, 5, 'length'); - test.ok(typeof assertions.duration === "number"); - test.equals(name, 'testname'); - } - }, test.done); -}; - -exports.testThrowError = function (test) { - test.expect(3); - var err = new Error('test'); - var testfn = function (test) { - throw err; - }; - nodeunit.runTest('testname', testfn, { - log: function (assertion) { - test.same(assertion.error, err, 'assertion.error'); - }, - testDone: function (name, assertions) { - test.equals(assertions.failures(), 1); - test.equals(assertions.length, 1); - } - }, test.done); -}; http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/test-sandbox.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/test-sandbox.js b/node_modules/nodeunit/test/test-sandbox.js deleted file mode 100644 index 1b249d7..0000000 --- a/node_modules/nodeunit/test/test-sandbox.js +++ /dev/null @@ -1,31 +0,0 @@ -var nodeunit = require('../lib/nodeunit'); -var sandbox = require('../lib/utils').sandbox; -var testCase = nodeunit.testCase; - -exports.testSimpleSandbox = function (test) { - var raw_jscode1 = sandbox(__dirname + '/fixtures/raw_jscode1.js'); - test.equal(raw_jscode1.hello_world('foo'), '_foo_', 'evaluation ok'); - test.done(); -}; - -exports.testSandboxContext = function (test) { - var a_variable = 42; // should not be visible in the sandbox - var raw_jscode2 = sandbox(__dirname + '/fixtures/raw_jscode2.js'); - a_variable = 42; // again for the win - test.equal( - raw_jscode2.get_a_variable(), - 'undefined', - 'the variable should not be defined' - ); - test.done(); -}; - -exports.testSandboxMultiple = function (test) { - var raw_jscode3 = sandbox([ - __dirname + '/fixtures/raw_jscode3.js', - __dirname + '/fixtures/raw_jscode3.js', - __dirname + '/fixtures/raw_jscode3.js' - ]); - test.equal(raw_jscode3.t, 3, 'two files loaded'); - test.done(); -}; http://git-wip-us.apache.org/repos/asf/incubator-cordova-coho/blob/1d113e44/node_modules/nodeunit/test/test-testcase-legacy.js ---------------------------------------------------------------------- diff --git a/node_modules/nodeunit/test/test-testcase-legacy.js b/node_modules/nodeunit/test/test-testcase-legacy.js deleted file mode 100644 index 1dfd9a7..0000000 --- a/node_modules/nodeunit/test/test-testcase-legacy.js +++ /dev/null @@ -1,257 +0,0 @@ -/* 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 nodeunit = require('../lib/nodeunit'); // @REMOVE_LINE_FOR_BROWSER -var testCase = nodeunit.testCase; - -exports.testTestCase = function (test) { - test.expect(7); - var call_order = []; - var s = testCase({ - setUp: function (callback) { - call_order.push('setUp'); - test.equals(this.one, undefined); - this.one = 1; - callback(); - }, - tearDown: function (callback) { - call_order.push('tearDown'); - test.ok(true, 'tearDown called'); - callback(); - }, - test1: function (t) { - call_order.push('test1'); - test.equals(this.one, 1); - this.one = 2; - t.done(); - }, - test2: function (t) { - call_order.push('test2'); - test.equals(this.one, 1); - t.done(); - } - }); - nodeunit.runSuite(null, s, {}, function () { - test.same(call_order, [ - 'setUp', 'test1', 'tearDown', - 'setUp', 'test2', 'tearDown' - ]); - test.done(); - }); -}; - -exports.tearDownAfterError = function (test) { - test.expect(1); - var s = testCase({ - tearDown: function (callback) { - test.ok(true, 'tearDown called'); - callback(); - }, - test: function (t) { - throw new Error('some error'); - } - }); - nodeunit.runSuite(null, s, {}, function () { - test.done(); - }); -}; - -exports.catchSetUpError = function (test) { - test.expect(2); - var test_error = new Error('test error'); - var s = testCase({ - setUp: function (callback) { - throw test_error; - }, - test: function (t) { - test.ok(false, 'test function should not be called'); - t.done(); - } - }); - nodeunit.runSuite(null, s, {}, function (err, assertions) { - test.equal(assertions.length, 1); - test.equal(assertions[0].error, test_error); - test.done(); - }); -}; - -exports.setUpErrorCallback = function (test) { - test.expect(2); - var test_error = new Error('test error'); - var s = testCase({ - setUp: function (callback) { - callback(test_error); - }, - test: function (t) { - test.ok(false, 'test function should not be called'); - t.done(); - } - }); - nodeunit.runSuite(null, s, {}, function (err, assertions) { - test.equal(assertions.length, 1); - test.equal(assertions[0].error, test_error); - test.done(); - }); -}; - -exports.catchTearDownError = function (test) { - test.expect(2); - var test_error = new Error('test error'); - var s = testCase({ - tearDown: function (callback) { - throw test_error; - }, - test: function (t) { - t.done(); - } - }); - nodeunit.runSuite(null, s, {}, function (err, assertions) { - test.equal(assertions.length, 1); - test.equal(assertions[0].error, test_error); - test.done(); - }); -}; - -exports.tearDownErrorCallback = function (test) { - test.expect(2); - var test_error = new Error('test error'); - var s = testCase({ - tearDown: function (callback) { - callback(test_error); - }, - test: function (t) { - t.done(); - } - }); - nodeunit.runSuite(null, s, {}, function (err, assertions) { - test.equal(assertions.length, 1); - test.equal(assertions[0].error, test_error); - test.done(); - }); -}; - -exports.testErrorAndtearDownError = function (test) { - test.expect(3); - var error1 = new Error('test error one'); - var error2 = new Error('test error two'); - var s = testCase({ - tearDown: function (callback) { - callback(error2); - }, - test: function (t) { - t.done(error1); - } - }); - nodeunit.runSuite(null, s, {}, function (err, assertions) { - test.equal(assertions.length, 2); - test.equal(assertions[0].error, error1); - test.equal(assertions[1].error, error2); - test.done(); - }); -}; - -exports.testCaseGroups = function (test) { - var call_order = []; - var s = testCase({ - setUp: function (callback) { - call_order.push('setUp'); - callback(); - }, - tearDown: function (callback) { - call_order.push('tearDown'); - callback(); - }, - test1: function (test) { - call_order.push('test1'); - test.done(); - }, - group1: { - test2: function (test) { - call_order.push('group1.test2'); - test.done(); - } - } - }); - nodeunit.runSuite(null, s, {}, function (err, assertions) { - test.same(call_order, [ - 'setUp', - 'test1', - 'tearDown', - 'setUp', - 'group1.test2', - 'tearDown' - ]); - test.done(); - }); -}; - -exports.nestedTestCases = function (test) { - var call_order = []; - var s = testCase({ - setUp: function (callback) { - call_order.push('setUp'); - callback(); - }, - tearDown: function (callback) { - call_order.push('tearDown'); - callback(); - }, - test1: function (test) { - call_order.push('test1'); - test.done(); - }, - group1: testCase({ - setUp: function (callback) { - call_order.push('group1.setUp'); - callback(); - }, - tearDown: function (callback) { - call_order.push('group1.tearDown'); - callback(); - }, - test2: function (test) { - call_order.push('group1.test2'); - test.done(); - } - }) - }); - nodeunit.runSuite(null, s, {}, function (err, assertions) { - test.same(call_order, [ - 'setUp', - 'test1', - 'tearDown', - 'setUp', - 'group1.setUp', - 'group1.test2', - 'group1.tearDown', - 'tearDown' - ]); - test.done(); - }); -}; - -exports.deepNestedTestCases = function (test) { - var val = 'foo'; - var s = testCase({ - setUp: function (callback) { - val = 'bar'; - callback(); - }, - group1: testCase({ - test: testCase({ - test2: function (test) { - test.equal(val, 'bar'); - test.done(); - } - }) - }) - }); - nodeunit.runSuite(null, s, {}, function (err, assertions) { - test.ok(!assertions[0].failed()); - test.equal(assertions.length, 1); - test.done(); - }); -};