From c6f5313217bc0b553ccab9a70a195b26881b63d8 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 7 May 2018 23:53:20 -0700 Subject: [PATCH] [Tests] add eclint and eslint, to enforce a consistent style --- .editorconfig | 33 ++++ .eslintrc | 6 + .travis.yml | 16 +- bin/tape | 9 +- example/array.js | 8 +- example/fail.js | 8 +- example/nested.js | 12 +- example/nested_fail.js | 12 +- example/not_enough.js | 8 +- example/throw.js | 2 +- example/timing.js | 4 +- example/too_many.js | 8 +- index.js | 32 ++-- lib/default_stream.js | 4 +- lib/results.js | 24 +-- lib/test.js | 157 +++++++++-------- package.json | 134 +++++++------- readme.markdown | 47 +++-- test/add-subtest-async.js | 14 +- test/anonymous-fn.js | 6 +- test/anonymous-fn/test-wrapper.js | 14 +- test/array.js | 14 +- test/bound.js | 12 +- test/comment.js | 104 +++++------ test/common.js | 48 +++--- test/deep-equal-failure.js | 36 ++-- test/default-messages.js | 2 +- test/double_end.js | 10 +- test/end-as-callback.js | 30 ++-- test/exit/fail.js | 8 +- test/exit/ok.js | 8 +- test/exit/too_few.js | 8 +- test/exposed-harness.js | 7 +- test/fail.js | 14 +- test/has spaces.js | 6 +- test/messages/defaults.js | 16 +- test/nested-async-plan-noend.js | 54 +++--- test/nested-sync-noplan-noend.js | 10 +- test/nested.js | 18 +- test/only-twice.js | 25 ++- test/require.js | 16 +- test/require/a.js | 6 +- test/require/b.js | 6 +- test/require/test-a.js | 8 +- test/require/test-b.js | 8 +- test/skip.js | 2 +- test/stackTrace.js | 12 +- test/subtest_and_async.js | 30 ++-- test/throws.js | 278 +++++++++++++++--------------- test/timeoutAfter.js | 6 +- test/too_many.js | 14 +- test/undef.js | 4 +- 52 files changed, 720 insertions(+), 658 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintrc diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..227b4a34 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,33 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 140 +block_comment_start = /* +block_comment = * +block_comment_end = */ + +[*.md] +indent_style = space +indent_size = 4 + +[readme.markdown] +indent_size = off +max_line_length = off + +[*.json] +max_line_length = off + +[*.yml] +max_line_length = off + +[Makefile] +max_line_length = off + +[.travis.yml] +indent_size = 2 diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..e93835c3 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,6 @@ +{ + "root": true, + "rules": { + "indent": ["error", 4], + }, +} diff --git a/.travis.yml b/.travis.yml index b5d69d31..1a8c8e67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: node_js -sudo: false +os: + - linux node_js: + - "10" - "9" - "8" - "7" @@ -12,11 +14,23 @@ node_js: - "0.10" - "0.8" before_install: + - 'case "${TRAVIS_NODE_VERSION}" in 0.*) export NPM_CONFIG_STRICT_SSL=false ;; esac' - 'nvm install-latest-npm' install: - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' +script: + - 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi' + - 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi' + - 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi' + - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi' +sudo: false +env: + - TEST=true matrix: fast_finish: true + include: + - node_js: "lts/*" + env: PRETEST=true allow_failures: - node_js: "9" - node_js: "7" diff --git a/bin/tape b/bin/tape index d0b3bec5..c479c03b 100755 --- a/bin/tape +++ b/bin/tape @@ -19,9 +19,10 @@ if (typeof opts.require === 'string') { opts.require.forEach(function(module) { if (module) { - /* This check ensures we ignore `-r ""`, trailing `-r`, or - * other silly things the user might (inadvertently) be doing. */ - require(resolveModule(module, { basedir: cwd })); + /* This check ensures we ignore `-r ""`, trailing `-r`, or + * other silly things the user might (inadvertently) be doing. + */ + require(resolveModule(module, { basedir: cwd })); } }); @@ -31,7 +32,7 @@ opts._.forEach(function (arg) { var files = glob.sync(arg); if (!Array.isArray(files)) { - throw new TypeError('unknown error: glob.sync did not return an array or throw. Please report this.'); + throw new TypeError('unknown error: glob.sync did not return an array or throw. Please report this.'); } files.forEach(function (file) { diff --git a/example/array.js b/example/array.js index d36857d4..bec161f4 100644 --- a/example/array.js +++ b/example/array.js @@ -3,26 +3,26 @@ var test = require('../'); test('array', function (t) { t.plan(5); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/example/fail.js b/example/fail.js index a7bf4444..a0db0b11 100644 --- a/example/fail.js +++ b/example/fail.js @@ -3,26 +3,26 @@ var test = require('../'); test('array', function (t) { t.plan(5); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/example/nested.js b/example/nested.js index 0e233d3f..2a36f25e 100644 --- a/example/nested.js +++ b/example/nested.js @@ -3,35 +3,35 @@ var test = require('../'); test('nested array test', function (t) { t.plan(5); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + t.test('inside test', function (q) { q.plan(2); q.ok(true, 'inside ok'); - + setTimeout(function () { q.ok(true, 'inside delayed'); }, 3000); }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/example/nested_fail.js b/example/nested_fail.js index 3ab5cb3a..ba168c7e 100644 --- a/example/nested_fail.js +++ b/example/nested_fail.js @@ -3,35 +3,35 @@ var test = require('../'); test('nested array test', function (t) { t.plan(5); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + t.test('inside test', function (q) { q.plan(2); q.ok(true); - + setTimeout(function () { q.equal(3, 4); }, 3000); }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/example/not_enough.js b/example/not_enough.js index 13b682be..fffc714f 100644 --- a/example/not_enough.js +++ b/example/not_enough.js @@ -3,26 +3,26 @@ var test = require('../'); test('array', function (t) { t.plan(8); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/example/throw.js b/example/throw.js index 9a69ec0f..5fa8b94c 100644 --- a/example/throw.js +++ b/example/throw.js @@ -3,7 +3,7 @@ var test = require('../'); test('throw', function (t) { t.plan(2); - + setTimeout(function () { throw new Error('doom'); }, 100); diff --git a/example/timing.js b/example/timing.js index 0268dc78..614c1441 100644 --- a/example/timing.js +++ b/example/timing.js @@ -2,10 +2,10 @@ var test = require('../'); test('timing test', function (t) { t.plan(2); - + t.equal(typeof Date.now, 'function'); var start = new Date; - + setTimeout(function () { t.equal(new Date - start, 100); }, 100); diff --git a/example/too_many.js b/example/too_many.js index ee285fba..cdcb5ee9 100644 --- a/example/too_many.js +++ b/example/too_many.js @@ -3,26 +3,26 @@ var test = require('../'); test('array', function (t) { t.plan(3); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/index.js b/index.js index 64d2d0c9..48528eb9 100644 --- a/index.js +++ b/index.js @@ -21,11 +21,11 @@ exports = module.exports = (function () { var lazyLoad = function () { return getHarness().apply(this, arguments); }; - + lazyLoad.only = function () { return getHarness().only.apply(this, arguments); }; - + lazyLoad.createStream = function (opts) { if (!opts) opts = {}; if (!harness) { @@ -35,11 +35,11 @@ exports = module.exports = (function () { } return harness.createStream(opts); }; - + lazyLoad.onFinish = function () { return getHarness().onFinish.apply(this, arguments); }; - + lazyLoad.onFailure = function() { return getHarness().onFailure.apply(this, arguments); }; @@ -61,16 +61,16 @@ function createExitHarness (conf) { var harness = createHarness({ autoclose: defined(conf.autoclose, false) }); - + var stream = harness.createStream({ objectMode: conf.objectMode }); var es = stream.pipe(conf.stream || createDefaultStream()); if (canEmitExit) { es.on('error', function (err) { harness._exitCode = 1 }); } - + var ended = false; stream.on('end', function () { ended = true }); - + if (conf.exit === false) return harness; if (!canEmitExit || !canExit) return harness; @@ -93,7 +93,7 @@ function createExitHarness (conf) { harness.close(); process.exit(code || harness._exitCode); }); - + return harness; } @@ -110,11 +110,11 @@ function createHarness (conf_) { if (conf_.autoclose !== false) { results.once('done', function () { results.close() }); } - + var test = function (name, conf, cb) { var t = new Test(name, conf, cb); test._tests.push(t); - + (function inspectCode (st) { st.on('test', function sub (st_) { inspectCode(st_); @@ -123,14 +123,14 @@ function createHarness (conf_) { if (!r.ok && typeof r !== 'string') test._exitCode = 1 }); })(t); - + results.push(t); return t; }; test._results = results; - + test._tests = []; - + test.createStream = function (opts) { return results.createStream(opts); }; @@ -142,7 +142,7 @@ function createHarness (conf_) { test.onFailure = function (cb) { results.on('fail', cb); }; - + var only = false; test.only = function () { if (only) throw new Error('there can only be one only test'); @@ -152,8 +152,8 @@ function createHarness (conf_) { return t; }; test._exitCode = 0; - + test.close = function () { results.close() }; - + return test; } diff --git a/lib/default_stream.js b/lib/default_stream.js index 12051773..8e9f4c76 100644 --- a/lib/default_stream.js +++ b/lib/default_stream.js @@ -5,7 +5,7 @@ module.exports = function () { var line = ''; var stream = through(write, flush); return stream; - + function write (buf) { for (var i = 0; i < buf.length; i++) { var c = typeof buf === 'string' @@ -16,7 +16,7 @@ module.exports = function () { else line += c; } } - + function flush () { if (fs.writeSync && /^win/.test(process.platform)) { try { fs.writeSync(1, line + '\n'); } diff --git a/lib/results.js b/lib/results.js index 305ae6bc..56fdc4ba 100644 --- a/lib/results.js +++ b/lib/results.js @@ -64,7 +64,7 @@ Results.prototype.createStream = function (opts) { output.queue('TAP version 13\n'); self._stream.pipe(output); } - + nextTick(function next() { var t; while (t = getNextTest(self)) { @@ -73,7 +73,7 @@ Results.prototype.createStream = function (opts) { } self.emit('done'); }); - + return output; }; @@ -94,7 +94,7 @@ Results.prototype._watch = function (t) { t.once('prerun', function () { write('# ' + t.name + '\n'); }); - + t.on('result', function (res) { if (typeof res === 'string') { write('# ' + res + '\n'); @@ -109,7 +109,7 @@ Results.prototype._watch = function (t) { self.emit('fail'); } }); - + t.on('test', function (st) { self._watch(st) }); }; @@ -118,7 +118,7 @@ Results.prototype.close = function () { if (self.closed) self._stream.emit('error', new Error('ALREADY CLOSED')); self.closed = true; var write = function (s) { self._stream.queue(s) }; - + write('\n1..' + self.count + '\n'); write('# tests ' + self.count + '\n'); write('# pass ' + self.pass + '\n'); @@ -132,22 +132,22 @@ function encodeResult (res, count) { var output = ''; output += (res.ok ? 'ok ' : 'not ok ') + count; output += res.name ? ' ' + res.name.toString().replace(/\s+/g, ' ') : ''; - + if (res.skip) output += ' # SKIP'; else if (res.todo) output += ' # TODO'; - + output += '\n'; if (res.ok) return output; - + var outer = ' '; var inner = outer + ' '; output += outer + '---\n'; output += inner + 'operator: ' + res.operator + '\n'; - + if (has(res, 'expected') || has(res, 'actual')) { var ex = inspect(res.expected, {depth: res.objectPrintDepth}); var ac = inspect(res.actual, {depth: res.objectPrintDepth}); - + if (Math.max(ex.length, ac.length) > 65 || invalidYaml(ex) || invalidYaml(ac)) { output += inner + 'expected: |-\n' + inner + ' ' + ex + '\n'; output += inner + 'actual: |-\n' + inner + ' ' + ac + '\n'; @@ -170,7 +170,7 @@ function encodeResult (res, count) { output += inner + ' ' + lines[i] + '\n'; } } - + output += outer + '...\n'; return output; } @@ -179,7 +179,7 @@ function getNextTest (results) { if (!results._only) { return results.tests.shift(); } - + do { var t = results.tests.shift(); if (!t) continue; diff --git a/lib/test.js b/lib/test.js index ab380310..d31c2558 100644 --- a/lib/test.js +++ b/lib/test.js @@ -14,8 +14,7 @@ module.exports = Test; var nextTick = typeof setImmediate !== 'undefined' ? setImmediate - : process.nextTick -; + : process.nextTick; var safeSetTimeout = setTimeout; var safeClearTimeout = clearTimeout; @@ -106,13 +105,13 @@ Test.prototype.test = function (name, opts, cb) { t.on('prerun', function () { self.assertCount++; }) - + if (!self._pendingAsserts()) { nextTick(function () { self._end(); }); } - + nextTick(function() { if (!self._plan && self.pendingCount == self._progeny.length) { self._end(); @@ -144,12 +143,12 @@ Test.prototype.timeoutAfter = function(ms) { }); } -Test.prototype.end = function (err) { +Test.prototype.end = function (err) { var self = this; if (arguments.length >= 1 && !!err) { this.ifError(err); } - + if (this.calledEnd) { this.fail('.end() called twice'); } @@ -165,7 +164,7 @@ Test.prototype._end = function (err) { t.run(); return; } - + if (!this.ended) this.emit('end'); var pendingAsserts = this._pendingAsserts(); if (!this._planError && this._plan !== undefined && pendingAsserts) { @@ -204,7 +203,7 @@ Test.prototype._pendingAsserts = function () { Test.prototype._assert = function assert (ok, opts) { var self = this; var extra = opts.extra || {}; - + var res = { id : self.assertCount ++, ok : Boolean(ok), @@ -220,11 +219,11 @@ Test.prototype._assert = function assert (ok, opts) { res.expected = defined(extra.expected, opts.expected); } this._ok = Boolean(this._ok && ok); - + if (!ok) { res.error = defined(extra.error, opts.error, new Error(res.name)); } - + if (!ok) { var e = new Error('exception'); var err = (e.stack || '').split('\n'); @@ -235,7 +234,7 @@ Test.prototype._assert = function assert (ok, opts) { Stack trace lines may resemble one of the following. We need to should correctly extract a function name (if any) and path / line no. for each line. - + at myFunction (/path/to/file.js:123:45) at myFunction (/path/to/file.other-ext:123:45) at myFunction (/path to/file.js:123:45) @@ -249,7 +248,7 @@ Test.prototype._assert = function assert (ok, opts) { (plus anything preceding it). /^(?:[^\s]*\s*\bat\s+)/ - + Second captures function call description (optional). This is not necessarily a valid JS function name, but just what the stack trace is using to represent a function call. It may look @@ -261,21 +260,21 @@ Test.prototype._assert = function assert (ok, opts) { /(?:(.*)\s+\()?/ - Last part captures file path plus line no (and optional + Last part captures file path plus line no (and optional column no). /((?:\/|[A-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)/ */ var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[A-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)/ var m = re.exec(err[i]); - + if (!m) { continue; } var callDescription = m[1] || ''; var filePath = m[2]; - + if (filePath.slice(0, dir.length) === dir) { continue; } @@ -286,14 +285,14 @@ Test.prototype._assert = function assert (ok, opts) { res.file = filePath; res.line = Number(m[3]); if (m[4]) res.column = Number(m[4]); - + res.at = callDescription + ' (' + filePath + ')'; break; } } self.emit('result', res); - + var pendingAsserts = self._pendingAsserts(); if (!pendingAsserts) { if (extra.exiting) { @@ -304,7 +303,7 @@ Test.prototype._assert = function assert (ok, opts) { }); } } - + if (!self._planError && pendingAsserts < 0) { self._planError = true; self.fail('plan != count', { @@ -339,10 +338,7 @@ Test.prototype.skip = function (msg, extra) { }); }; -Test.prototype.ok -= Test.prototype['true'] -= Test.prototype.assert -= function (value, msg, extra) { +function assert(value, msg, extra) { this._assert(value, { message : defined(msg, 'should be truthy'), operator : 'ok', @@ -350,12 +346,13 @@ Test.prototype.ok actual : value, extra : extra }); -}; +} +Test.prototype.ok += Test.prototype['true'] += Test.prototype.assert += assert; -Test.prototype.notOk -= Test.prototype['false'] -= Test.prototype.notok -= function (value, msg, extra) { +function notOK(value, msg, extra) { this._assert(!value, { message : defined(msg, 'should be falsy'), operator : 'notOk', @@ -363,37 +360,52 @@ Test.prototype.notOk actual : value, extra : extra }); -}; +} +Test.prototype.notOk += Test.prototype['false'] += Test.prototype.notok += notOK; -Test.prototype.error -= Test.prototype.ifError -= Test.prototype.ifErr -= Test.prototype.iferror -= function (err, msg, extra) { +function error(err, msg, extra) { this._assert(!err, { message : defined(msg, String(err)), operator : 'error', actual : err, extra : extra }); -}; +} +Test.prototype.error += Test.prototype.ifError += Test.prototype.ifErr += Test.prototype.iferror += error; +function equal(a, b, msg, extra) { + this._assert(a === b, { + message : defined(msg, 'should be equal'), + operator : 'equal', + actual : a, + expected : b, + extra : extra + }); +} Test.prototype.equal = Test.prototype.equals = Test.prototype.isEqual = Test.prototype.is = Test.prototype.strictEqual = Test.prototype.strictEquals -= function (a, b, msg, extra) { - this._assert(a === b, { - message : defined(msg, 'should be equal'), - operator : 'equal', += equal; + +function notEqual(a, b, msg, extra) { + this._assert(a !== b, { + message : defined(msg, 'should not be equal'), + operator : 'notEqual', actual : a, - expected : b, + notExpected : b, extra : extra }); -}; - +} Test.prototype.notEqual = Test.prototype.notEquals = Test.prototype.notStrictEqual @@ -403,43 +415,46 @@ Test.prototype.notEqual = Test.prototype.not = Test.prototype.doesNotEqual = Test.prototype.isInequal -= function (a, b, msg, extra) { - this._assert(a !== b, { - message : defined(msg, 'should not be equal'), - operator : 'notEqual', += notEqual; + +function tapeDeepEqual(a, b, msg, extra) { + this._assert(deepEqual(a, b, { strict: true }), { + message : defined(msg, 'should be equivalent'), + operator : 'deepEqual', actual : a, - notExpected : b, + expected : b, extra : extra }); -}; - +} Test.prototype.deepEqual = Test.prototype.deepEquals = Test.prototype.isEquivalent = Test.prototype.same -= function (a, b, msg, extra) { - this._assert(deepEqual(a, b, { strict: true }), { += tapeDeepEqual; + +function deepLooseEqual(a, b, msg, extra) { + this._assert(deepEqual(a, b), { message : defined(msg, 'should be equivalent'), - operator : 'deepEqual', + operator : 'deepLooseEqual', actual : a, expected : b, extra : extra }); -}; - +} Test.prototype.deepLooseEqual = Test.prototype.looseEqual = Test.prototype.looseEquals -= function (a, b, msg, extra) { - this._assert(deepEqual(a, b), { - message : defined(msg, 'should be equivalent'), - operator : 'deepLooseEqual', += deepLooseEqual; + +function notDeepEqual(a, b, msg, extra) { + this._assert(!deepEqual(a, b, { strict: true }), { + message : defined(msg, 'should not be equivalent'), + operator : 'notDeepEqual', actual : a, - expected : b, + notExpected : b, extra : extra }); -}; - +} Test.prototype.notDeepEqual = Test.prototype.notEquivalent = Test.prototype.notDeeply @@ -448,20 +463,9 @@ Test.prototype.notDeepEqual = Test.prototype.isNotDeeply = Test.prototype.isNotEquivalent = Test.prototype.isInequivalent -= function (a, b, msg, extra) { - this._assert(!deepEqual(a, b, { strict: true }), { - message : defined(msg, 'should not be equivalent'), - operator : 'notDeepEqual', - actual : a, - notExpected : b, - extra : extra - }); -}; += notDeepEqual; -Test.prototype.notDeepLooseEqual -= Test.prototype.notLooseEqual -= Test.prototype.notLooseEquals -= function (a, b, msg, extra) { +function notDeepLooseEqual(a, b, msg, extra) { this._assert(!deepEqual(a, b), { message : defined(msg, 'should be equivalent'), operator : 'notDeepLooseEqual', @@ -469,7 +473,11 @@ Test.prototype.notDeepLooseEqual expected : b, extra : extra }); -}; +} +Test.prototype.notDeepLooseEqual += Test.prototype.notLooseEqual += Test.prototype.notLooseEquals += notDeepLooseEqual; Test.prototype['throws'] = function (fn, expected, msg, extra) { if (typeof expected === 'string') { @@ -541,4 +549,3 @@ Test.skip = function (name_, _opts, _cb) { }; // vim: set softtabstop=4 shiftwidth=4: - diff --git a/package.json b/package.json index f371363e..1247ec8f 100644 --- a/package.json +++ b/package.json @@ -1,66 +1,72 @@ { - "name": "tape", - "version": "4.9.0", - "description": "tap-producing test harness for node and browsers", - "main": "index.js", - "bin": "./bin/tape", - "directories": { - "example": "example", - "test": "test" - }, - "dependencies": { - "deep-equal": "~1.0.1", - "defined": "~1.0.0", - "for-each": "~0.3.2", - "function-bind": "~1.1.1", - "glob": "~7.1.2", - "has": "~1.0.1", - "inherits": "~2.0.3", - "minimist": "~1.2.0", - "object-inspect": "~1.5.0", - "resolve": "~1.5.0", - "resumer": "~0.0.0", - "string.prototype.trim": "~1.1.2", - "through": "~2.3.8" - }, - "devDependencies": { - "concat-stream": "^1.6.2", - "falafel": "^2.1.0", - "js-yaml": "^3.11.0", - "tap": "^8.0.1", - "tap-parser": "^3.0.5" - }, - "scripts": { - "test": "tap test/*.js" - }, - "testling": { - "files": "test/browser/*.js", - "browsers": [ - "ie/6..latest", - "chrome/20..latest", - "firefox/10..latest", - "safari/latest", - "opera/11.0..latest", - "iphone/6", - "ipad/6" - ] - }, - "repository": { - "type": "git", - "url": "git://github.com/substack/tape.git" - }, - "homepage": "https://github.com/substack/tape", - "keywords": [ - "tap", - "test", - "harness", - "assert", - "browser" - ], - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "license": "MIT" + "name": "tape", + "version": "4.9.0", + "description": "tap-producing test harness for node and browsers", + "main": "index.js", + "bin": "./bin/tape", + "directories": { + "example": "example", + "test": "test" + }, + "dependencies": { + "deep-equal": "~1.0.1", + "defined": "~1.0.0", + "for-each": "~0.3.2", + "function-bind": "~1.1.1", + "glob": "~7.1.2", + "has": "~1.0.1", + "inherits": "~2.0.3", + "minimist": "~1.2.0", + "object-inspect": "~1.5.0", + "resolve": "~1.5.0", + "resumer": "~0.0.0", + "string.prototype.trim": "~1.1.2", + "through": "~2.3.8" + }, + "devDependencies": { + "concat-stream": "^1.6.2", + "eclint": "^2.7.0", + "eslint": "^4.19.1", + "falafel": "^2.1.0", + "js-yaml": "^3.11.0", + "tap": "^8.0.1", + "tap-parser": "^3.0.5" + }, + "scripts": { + "prelint": "eclint check", + "lint": "eslint .", + "pretest": "npm run lint", + "test": "npm run tests-only", + "tests-only": "tap test/*.js" + }, + "testling": { + "files": "test/browser/*.js", + "browsers": [ + "ie/6..latest", + "chrome/20..latest", + "firefox/10..latest", + "safari/latest", + "opera/11.0..latest", + "iphone/6", + "ipad/6" + ] + }, + "repository": { + "type": "git", + "url": "git://github.com/substack/tape.git" + }, + "homepage": "https://github.com/substack/tape", + "keywords": [ + "tap", + "test", + "harness", + "assert", + "browser" + ], + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" + }, + "license": "MIT" } diff --git a/readme.markdown b/readme.markdown index 5446235c..7c53801a 100644 --- a/readme.markdown +++ b/readme.markdown @@ -95,26 +95,26 @@ The default TAP output is good for machines and humans that are robots. If you want a more colorful / pretty output there are lots of modules on npm that will output something pretty if you pipe TAP into them: - - https://github.com/scottcorgan/tap-spec - - https://github.com/scottcorgan/tap-dot - - https://github.com/substack/faucet - - https://github.com/juliangruber/tap-bail - - https://github.com/kirbysayshi/tap-browser-color - - https://github.com/gummesson/tap-json - - https://github.com/derhuerst/tap-min - - https://github.com/calvinmetcalf/tap-nyan - - https://www.npmjs.org/package/tap-pessimist - - https://github.com/toolness/tap-prettify - - https://github.com/shuhei/colortape - - https://github.com/aghassemi/tap-xunit - - https://github.com/namuol/tap-difflet - - https://github.com/gritzko/tape-dom - - https://github.com/axross/tap-diff - - https://github.com/axross/tap-notify - - https://github.com/zoubin/tap-summary - - https://github.com/Hypercubed/tap-markdown - - https://github.com/gabrielcsapo/tap-html - - https://github.com/mcnuttandrew/tap-react-browser + - https://github.com/scottcorgan/tap-spec + - https://github.com/scottcorgan/tap-dot + - https://github.com/substack/faucet + - https://github.com/juliangruber/tap-bail + - https://github.com/kirbysayshi/tap-browser-color + - https://github.com/gummesson/tap-json + - https://github.com/derhuerst/tap-min + - https://github.com/calvinmetcalf/tap-nyan + - https://www.npmjs.org/package/tap-pessimist + - https://github.com/toolness/tap-prettify + - https://github.com/shuhei/colortape + - https://github.com/aghassemi/tap-xunit + - https://github.com/namuol/tap-difflet + - https://github.com/gritzko/tape-dom + - https://github.com/axross/tap-diff + - https://github.com/axross/tap-notify + - https://github.com/zoubin/tap-summary + - https://github.com/Hypercubed/tap-markdown + - https://github.com/gabrielcsapo/tap-html + - https://github.com/mcnuttandrew/tap-react-browser To use them, try `node test/index.js | tap-spec` or pipe it into one of the modules of your choice! @@ -146,11 +146,8 @@ finished. Tests execute serially. Available `opts` options are: - opts.skip = true/false. See test.skip. -- opts.timeout = 500. Set a timeout for the test, after which it will fail. - See test.timeoutAfter. -- opts.objectPrintDepth = 5. Configure max depth of expected / actual object - printing. Environmental variable `NODE_TAPE_OBJECT_PRINT_DEPTH` can set the - desired default depth for all tests; locally-set values will take precedence. +- opts.timeout = 500. Set a timeout for the test, after which it will fail. See test.timeoutAfter. +- opts.objectPrintDepth = 5. Configure max depth of expected / actual object printing. Environmental variable `NODE_TAPE_OBJECT_PRINT_DEPTH` can set the desired default depth for all tests; locally-set values will take precedence. If you forget to `t.plan()` out how many assertions you are going to run and you don't call `t.end()` explicitly, your test will hang. diff --git a/test/add-subtest-async.js b/test/add-subtest-async.js index 74b4d8a0..ddc39f76 100644 --- a/test/add-subtest-async.js +++ b/test/add-subtest-async.js @@ -1,11 +1,11 @@ var test = require('../') test('parent', function (t) { - t.pass('parent'); - setTimeout(function () { - t.test('child', function (t) { - t.pass('child'); - t.end(); - }); - }, 100) + t.pass('parent'); + setTimeout(function () { + t.test('child', function (t) { + t.pass('child'); + t.end(); + }); + }, 100) }) diff --git a/test/anonymous-fn.js b/test/anonymous-fn.js index 2856ea82..e05b967c 100644 --- a/test/anonymous-fn.js +++ b/test/anonymous-fn.js @@ -7,7 +7,7 @@ var testWrapper = require('./anonymous-fn/test-wrapper'); tap.test('inside anonymous functions', function (tt) { tt.plan(1); - + var test = tape.createHarness(); var tc = function (rows) { var body = stripFullStack(rows.toString('utf8')); @@ -39,9 +39,9 @@ tap.test('inside anonymous functions', function (tt) { '# fail 1' ].join('\n') + '\n'); }; - + test.createStream().pipe(concat(tc)); - + test('wrapped test failure', testWrapper(function (t) { t.fail('fail'); t.end(); diff --git a/test/anonymous-fn/test-wrapper.js b/test/anonymous-fn/test-wrapper.js index acf66e30..9702c9f1 100644 --- a/test/anonymous-fn/test-wrapper.js +++ b/test/anonymous-fn/test-wrapper.js @@ -1,16 +1,16 @@ // Example of wrapper function that would invoke tape module.exports = function (testCase) { - return function(t) { - setUp(); - testCase(t); - tearDown(); - }; + return function(t) { + setUp(); + testCase(t); + tearDown(); + }; } function setUp() { - // ... example ... + // ... example ... } function tearDown() { - // ... example ... + // ... example ... } diff --git a/test/array.js b/test/array.js index d206be58..dc4a4a40 100644 --- a/test/array.js +++ b/test/array.js @@ -5,9 +5,9 @@ var concat = require('concat-stream'); tap.test('array test', function (tt) { tt.plan(1); - + var test = tape.createHarness(); - + test.createStream().pipe(concat(function (rows) { tt.same(rows.toString('utf8'), [ 'TAP version 13', @@ -25,29 +25,29 @@ tap.test('array test', function (tt) { '# ok' ].join('\n') + '\n'); })); - + test('array', function (t) { t.plan(5); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/test/bound.js b/test/bound.js index d3981954..58f26920 100644 --- a/test/bound.js +++ b/test/bound.js @@ -1,10 +1,10 @@ var test = require('../'); test('bind works', function (t) { - t.plan(2); - var equal = t.equal; - var deepEqual = t.deepEqual; - equal(3, 3); - deepEqual([4], [4]); - t.end(); + t.plan(2); + var equal = t.equal; + var deepEqual = t.deepEqual; + equal(3, 3); + deepEqual([4], [4]); + t.end(); }); diff --git a/test/comment.js b/test/comment.js index ab00690c..b3f9bcc3 100644 --- a/test/comment.js +++ b/test/comment.js @@ -9,15 +9,15 @@ tap.test('no comment', function (assert) { var verify = function (output) { assert.equal(output.toString('utf8'), [ - 'TAP version 13', - '# no comment', - '', - '1..0', - '# tests 0', - '# pass 0', - '', - '# ok', - '' + 'TAP version 13', + '# no comment', + '', + '1..0', + '# tests 0', + '# pass 0', + '', + '# ok', + '' ].join('\n')); }; @@ -69,19 +69,19 @@ tap.test('whitespace', function (assert) { var verify = function (output) { assert.equal(output.toString('utf8'), [ - 'TAP version 13', - '# whitespace', - '# ', - '# a', - '# a', - '# a', - '', - '1..0', - '# tests 0', - '# pass 0', - '', - '# ok', - '' + 'TAP version 13', + '# whitespace', + '# ', + '# a', + '# a', + '# a', + '', + '1..0', + '# tests 0', + '# pass 0', + '', + '# ok', + '' ].join('\n')); }; @@ -102,23 +102,23 @@ tap.test('non-string types', function (assert) { var verify = function (output) { assert.equal(output.toString('utf8'), [ - 'TAP version 13', - '# non-string types', - '# true', - '# false', - '# 42', - '# 6.66', - '# [object Object]', - '# [object Object]', - '# [object Object]', - '# function ConstructorFunction() {}', - '', - '1..0', - '# tests 0', - '# pass 0', - '', - '# ok', - '' + 'TAP version 13', + '# non-string types', + '# true', + '# false', + '# 42', + '# 6.66', + '# [object Object]', + '# [object Object]', + '# [object Object]', + '# function ConstructorFunction() {}', + '', + '1..0', + '# tests 0', + '# pass 0', + '', + '# ok', + '' ].join('\n')); }; @@ -143,19 +143,19 @@ tap.test('multiline string', function (assert) { var verify = function (output) { assert.equal(output.toString('utf8'), [ - 'TAP version 13', - '# multiline strings', - '# a', - '# b', - '# c', - '# d', - '', - '1..0', - '# tests 0', - '# pass 0', - '', - '# ok', - '' + 'TAP version 13', + '# multiline strings', + '# a', + '# b', + '# c', + '# d', + '', + '1..0', + '# tests 0', + '# pass 0', + '', + '# ok', + '' ].join('\n')); }; diff --git a/test/common.js b/test/common.js index 9e4a0391..f156693a 100644 --- a/test/common.js +++ b/test/common.js @@ -32,32 +32,32 @@ module.exports.getDiag = function (body) { // strip out all stack frames that aren't directly under our test directory, // and replace them with placeholders. module.exports.stripFullStack = function (output) { - var stripped = ' [... stack stripped ...]'; - var withDuplicates = output.split('\n').map(function (line) { - var m = line.match(/[ ]{8}at .*\((.*)\)/); + var stripped = ' [... stack stripped ...]'; + var withDuplicates = output.split('\n').map(function (line) { + var m = line.match(/[ ]{8}at .*\((.*)\)/); - var stripChangingData = function (line) { - var withoutTestDir = line.replace(__dirname, '$TEST'); - var withoutPackageDir = withoutTestDir.replace(path.dirname(__dirname), '$TAPE'); - var withoutPathSep = withoutPackageDir.replace(new RegExp('\\' + path.sep, 'g'), '/'); - var withoutLineNumbers = withoutPathSep.replace(/:\d+:\d+/g, ':$LINE:$COL'); - var withoutNestedLineNumbers = withoutLineNumbers.replace(/, \:\$LINE:\$COL\)$/, ')'); - return withoutNestedLineNumbers; - } + var stripChangingData = function (line) { + var withoutTestDir = line.replace(__dirname, '$TEST'); + var withoutPackageDir = withoutTestDir.replace(path.dirname(__dirname), '$TAPE'); + var withoutPathSep = withoutPackageDir.replace(new RegExp('\\' + path.sep, 'g'), '/'); + var withoutLineNumbers = withoutPathSep.replace(/:\d+:\d+/g, ':$LINE:$COL'); + var withoutNestedLineNumbers = withoutLineNumbers.replace(/, \:\$LINE:\$COL\)$/, ')'); + return withoutNestedLineNumbers; + } - if (m) { - if (m[1].slice(0, __dirname.length) === __dirname) { - return stripChangingData(line); - } - return stripped; - } - return stripChangingData(line); - }) + if (m) { + if (m[1].slice(0, __dirname.length) === __dirname) { + return stripChangingData(line); + } + return stripped; + } + return stripChangingData(line); + }) - var deduped = withDuplicates.filter(function (line, ix) { - var hasPrior = line === stripped && withDuplicates[ix - 1] === stripped; - return !hasPrior; - }); + var deduped = withDuplicates.filter(function (line, ix) { + var hasPrior = line === stripped && withDuplicates[ix - 1] === stripped; + return !hasPrior; + }); - return deduped.join('\n'); + return deduped.join('\n'); } diff --git a/test/deep-equal-failure.js b/test/deep-equal-failure.js index 4c0d4eed..48d0687c 100644 --- a/test/deep-equal-failure.js +++ b/test/deep-equal-failure.js @@ -41,9 +41,9 @@ tap.test('deep equal failure', function (assert) { ); assert.deepEqual(getDiag(body), { - operator: 'equal', - expected: '{ b: 2 }', - actual: '{ a: 1 }' + operator: 'equal', + expected: '{ b: 2 }', + actual: '{ a: 1 }' }); })); @@ -55,9 +55,9 @@ tap.test('deep equal failure', function (assert) { id: 1, name: 'should be equal', diag: { - operator: 'equal', - expected: '{ b: 2 }', - actual: '{ a: 1 }' + operator: 'equal', + expected: '{ b: 2 }', + actual: '{ a: 1 }' } }); }); @@ -102,9 +102,9 @@ tap.test('deep equal failure, depth 6, with option', function (assert) { ); assert.deepEqual(getDiag(body), { - operator: 'equal', - expected: '{ a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }', - actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }' + operator: 'equal', + expected: '{ a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }', + actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }' }); })); @@ -116,9 +116,9 @@ tap.test('deep equal failure, depth 6, with option', function (assert) { id: 1, name: 'should be equal', diag: { - operator: 'equal', - expected: '{ a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }', - actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }' + operator: 'equal', + expected: '{ a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }', + actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }' } }); }); @@ -163,9 +163,9 @@ tap.test('deep equal failure, depth 6, without option', function (assert) { ); assert.deepEqual(getDiag(body), { - operator: 'equal', - expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }', - actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }' + operator: 'equal', + expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }', + actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }' }); })); @@ -177,9 +177,9 @@ tap.test('deep equal failure, depth 6, without option', function (assert) { id: 1, name: 'should be equal', diag: { - operator: 'equal', - expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }', - actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }' + operator: 'equal', + expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }', + actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }' } }); }); diff --git a/test/default-messages.js b/test/default-messages.js index 46c055fd..dcfdbffc 100644 --- a/test/default-messages.js +++ b/test/default-messages.js @@ -7,7 +7,7 @@ tap.test('default messages', function (t) { t.plan(1); var ps = spawn(process.execPath, [path.join(__dirname, 'messages', 'defaults.js')]); - + ps.stdout.pipe(concat(function (rows) { t.same(rows.toString('utf8'), [ diff --git a/test/double_end.js b/test/double_end.js index 5457cb27..a24f4507 100644 --- a/test/double_end.js +++ b/test/double_end.js @@ -26,13 +26,13 @@ test(function (t) { var stackExpected; var atExpected; try { - to._onTimeout(); + to._onTimeout(); } catch (e) { - stackExpected = stripFullStack(e.stack).split('\n')[1]; - stackExpected = stackExpected.replace('double_end.js', 'double_end/double.js'); - stackExpected = stackExpected.trim(); - atExpected = stackExpected.replace(/^at\s+/, 'at: '); + stackExpected = stripFullStack(e.stack).split('\n')[1]; + stackExpected = stackExpected.replace('double_end.js', 'double_end/double.js'); + stackExpected = stackExpected.trim(); + atExpected = stackExpected.replace(/^at\s+/, 'at: '); } var stripped = stripFullStack(body.toString('utf8')); diff --git a/test/end-as-callback.js b/test/end-as-callback.js index 98609f5d..f8791c0a 100644 --- a/test/end-as-callback.js +++ b/test/end-as-callback.js @@ -5,23 +5,23 @@ var concat = require('concat-stream'); tap.test("tape assert.end as callback", function (tt) { var test = tape.createHarness({ exit: false }) - + test.createStream().pipe(concat(function (rows) { tt.equal(rows.toString('utf8'), [ - 'TAP version 13', - '# do a task and write', - 'ok 1 null', - 'ok 2 should be equal', - '# do a task and write fail', - 'ok 3 null', - 'ok 4 should be equal', - 'not ok 5 Error: fail', - getStackTrace(rows), // tap error stack - '', - '1..5', - '# tests 5', - '# pass 4', - '# fail 1' + 'TAP version 13', + '# do a task and write', + 'ok 1 null', + 'ok 2 should be equal', + '# do a task and write fail', + 'ok 3 null', + 'ok 4 should be equal', + 'not ok 5 Error: fail', + getStackTrace(rows), // tap error stack + '', + '1..5', + '# tests 5', + '# pass 4', + '# fail 1' ].join('\n') + '\n'); tt.end() })); diff --git a/test/exit/fail.js b/test/exit/fail.js index d7fd3ce7..07a65ca3 100644 --- a/test/exit/fail.js +++ b/test/exit/fail.js @@ -3,26 +3,26 @@ var falafel = require('falafel'); test('array', function (t) { t.plan(5); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/test/exit/ok.js b/test/exit/ok.js index f1068e57..6d405c7c 100644 --- a/test/exit/ok.js +++ b/test/exit/ok.js @@ -4,26 +4,26 @@ var test = require('../../'); test('array', function (t) { t.comment('hi'); t.plan(5); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/test/exit/too_few.js b/test/exit/too_few.js index 8e60ce5b..68ba71db 100644 --- a/test/exit/too_few.js +++ b/test/exit/too_few.js @@ -3,26 +3,26 @@ var test = require('../../'); test('array', function (t) { t.plan(6); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/test/exposed-harness.js b/test/exposed-harness.js index b790340c..e1795eb0 100644 --- a/test/exposed-harness.js +++ b/test/exposed-harness.js @@ -3,11 +3,10 @@ var tap = require('tap'); tap.test('main harness object is exposed', function (assert) { - assert.equal(typeof tape.getHarness, 'function', 'tape.getHarness is a function') + assert.equal(typeof tape.getHarness, 'function', 'tape.getHarness is a function') - assert.equal(tape.getHarness()._results.pass, 0) + assert.equal(tape.getHarness()._results.pass, 0) - assert.end() + assert.end() }) - diff --git a/test/fail.js b/test/fail.js index 2c975bb8..133359ca 100644 --- a/test/fail.js +++ b/test/fail.js @@ -7,7 +7,7 @@ var stripFullStack = require('./common').stripFullStack; tap.test('array test', function (tt) { tt.plan(1); - + var test = tape.createHarness({ exit : false }); var tc = function (rows) { tt.same(stripFullStack(rows.toString('utf8')), [ @@ -40,31 +40,31 @@ tap.test('array test', function (tt) { '' ].join('\n')); }; - + test.createStream().pipe(concat(tc)); - + test('array', function (t) { t.plan(5); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/test/has spaces.js b/test/has spaces.js index ae18e71d..19a2b9e3 100644 --- a/test/has spaces.js +++ b/test/has spaces.js @@ -6,7 +6,7 @@ var stripFullStack = require('./common').stripFullStack; tap.test('array test', function (tt) { tt.plan(1); - + var test = tape.createHarness({ exit : false }); var tc = function (rows) { tt.same(stripFullStack(rows.toString('utf8')), [ @@ -30,9 +30,9 @@ tap.test('array test', function (tt) { '' ].join('\n')); }; - + test.createStream().pipe(concat(tc)); - + test('fail', function (t) { t.fail('this should fail'); t.end(); diff --git a/test/messages/defaults.js b/test/messages/defaults.js index 8d842eb9..836a34aa 100644 --- a/test/messages/defaults.js +++ b/test/messages/defaults.js @@ -1,12 +1,12 @@ var test = require('../../'); test('default messages', function (t) { - t.plan(7); - t.ok(true); - t.notOk(false); - t.equal(true, true); - t.notEqual(true, false); - t.deepEqual(true, true); - t.deepLooseEqual(true, true); - t.notDeepLooseEqual(true, false); + t.plan(7); + t.ok(true); + t.notOk(false); + t.equal(true, true); + t.notEqual(true, false); + t.deepEqual(true, true); + t.deepLooseEqual(true, true); + t.notDeepLooseEqual(true, false); }); diff --git a/test/nested-async-plan-noend.js b/test/nested-async-plan-noend.js index 6f8cfdd0..69f43b9d 100644 --- a/test/nested-async-plan-noend.js +++ b/test/nested-async-plan-noend.js @@ -1,36 +1,36 @@ var test = require('../'); test('Harness async test support', function(t) { - t.plan(3); + t.plan(3); - t.ok(true, 'sync child A'); + t.ok(true, 'sync child A'); - t.test('sync child B', function(tt) { - tt.plan(2); + t.test('sync child B', function(tt) { + tt.plan(2); - setTimeout(function(){ - tt.test('async grandchild A', function(ttt) { - ttt.plan(1); - ttt.ok(true); - }); - }, 50); + setTimeout(function(){ + tt.test('async grandchild A', function(ttt) { + ttt.plan(1); + ttt.ok(true); + }); + }, 50); - setTimeout(function() { - tt.test('async grandchild B', function(ttt) { - ttt.plan(1); - ttt.ok(true); - }); - }, 100); - }); - - setTimeout(function() { - t.test('async child', function(tt) { - tt.plan(2); - tt.ok(true, 'sync grandchild in async child A'); - tt.test('sync grandchild in async child B', function(ttt) { - ttt.plan(1); - ttt.ok(true); - }); + setTimeout(function() { + tt.test('async grandchild B', function(ttt) { + ttt.plan(1); + ttt.ok(true); + }); + }, 100); }); - }, 200); + + setTimeout(function() { + t.test('async child', function(tt) { + tt.plan(2); + tt.ok(true, 'sync grandchild in async child A'); + tt.test('sync grandchild in async child B', function(ttt) { + ttt.plan(1); + ttt.ok(true); + }); + }); + }, 200); }); diff --git a/test/nested-sync-noplan-noend.js b/test/nested-sync-noplan-noend.js index 6039093d..42735a80 100644 --- a/test/nested-sync-noplan-noend.js +++ b/test/nested-sync-noplan-noend.js @@ -7,7 +7,7 @@ tap.test('nested sync test without plan or end', function (tt) { var test = tape.createHarness(); var tc = function (rows) { - tt.same(rows.toString('utf8'), [ + tt.same(rows.toString('utf8'), [ 'TAP version 13', '# nested without plan or end', '# first', @@ -27,15 +27,15 @@ tap.test('nested sync test without plan or end', function (tt) { test('nested without plan or end', function(t) { t.test('first', function(q) { - setTimeout(function first() { + setTimeout(function first() { q.ok(true); - q.end() + q.end() }, 10); }); t.test('second', function(q) { - setTimeout(function second() { + setTimeout(function second() { q.ok(true); - q.end() + q.end() }, 10); }); }); diff --git a/test/nested.js b/test/nested.js index f444f95f..46822594 100644 --- a/test/nested.js +++ b/test/nested.js @@ -5,7 +5,7 @@ var concat = require('concat-stream'); tap.test('array test', function (tt) { tt.plan(1); - + var test = tape.createHarness(); var tc = function (rows) { tt.same(rows.toString('utf8'), [ @@ -29,40 +29,40 @@ tap.test('array test', function (tt) { '# ok' ].join('\n') + '\n'); }; - + test.createStream().pipe(concat(tc)); - + test('nested array test', function (t) { t.plan(6); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + t.test('inside test', function (q) { q.plan(2); q.ok(true); - + setTimeout(function () { q.ok(true); }, 100); }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/test/only-twice.js b/test/only-twice.js index ce6048ef..488e49ba 100644 --- a/test/only-twice.js +++ b/test/only-twice.js @@ -2,20 +2,19 @@ var tape = require('../'); var tap = require('tap'); tap.test('only twice error', function (assert) { - var test = tape.createHarness({ exit : false }); + var test = tape.createHarness({ exit : false }); - test.only("first only", function (t) { - t.end() - }); + test.only("first only", function (t) { + t.end() + }); - assert.throws(function() { - test.only('second only', function(t) { - t.end(); + assert.throws(function() { + test.only('second only', function(t) { + t.end(); + }); + }, { + name: 'Error', + message: 'there can only be one only test' }); - }, { - name: 'Error', - message: 'there can only be one only test' - }); - assert.end(); + assert.end(); }); - diff --git a/test/require.js b/test/require.js index 6b05a000..5e39e170 100644 --- a/test/require.js +++ b/test/require.js @@ -4,7 +4,7 @@ var concat = require('concat-stream'); tap.test('requiring a single module', function (t) { t.plan(2); - + var tc = function (rows) { t.same(rows.toString('utf8'), [ 'TAP version 13', @@ -21,7 +21,7 @@ tap.test('requiring a single module', function (t) { '# ok' ].join('\n') + '\n\n'); }; - + var ps = tape('-r ./require/a require/test-a.js'); ps.stdout.pipe(concat(tc)); ps.on('exit', function (code) { @@ -31,7 +31,7 @@ tap.test('requiring a single module', function (t) { tap.test('requiring multiple modules', function (t) { t.plan(2); - + var tc = function (rows) { t.same(rows.toString('utf8'), [ 'TAP version 13', @@ -53,7 +53,7 @@ tap.test('requiring multiple modules', function (t) { '# ok' ].join('\n') + '\n\n'); }; - + var ps = tape('-r ./require/a -r ./require/b require/test-a.js require/test-b.js'); ps.stdout.pipe(concat(tc)); ps.on('exit', function (code) { @@ -62,8 +62,8 @@ tap.test('requiring multiple modules', function (t) { }); function tape(args) { - var proc = require('child_process') - var bin = __dirname + '/../bin/tape' + var proc = require('child_process') + var bin = __dirname + '/../bin/tape' - return proc.spawn('node', [bin].concat(args.split(' ')), { cwd: __dirname }) -} \ No newline at end of file + return proc.spawn('node', [bin].concat(args.split(' ')), { cwd: __dirname }) +} diff --git a/test/require/a.js b/test/require/a.js index b2dd811b..097eb883 100644 --- a/test/require/a.js +++ b/test/require/a.js @@ -1,8 +1,8 @@ var tape = require('../..'); tape.test('module-a', function(t) { - t.plan(1) - t.pass('loaded module a') + t.plan(1) + t.pass('loaded module a') }) -global.module_a = true \ No newline at end of file +global.module_a = true diff --git a/test/require/b.js b/test/require/b.js index 2206c17c..2f10a0ec 100644 --- a/test/require/b.js +++ b/test/require/b.js @@ -1,8 +1,8 @@ var tape = require('../..'); tape.test('module-b', function(t) { - t.plan(1) - t.pass('loaded module b') + t.plan(1) + t.pass('loaded module b') }) -global.module_b = true \ No newline at end of file +global.module_b = true diff --git a/test/require/test-a.js b/test/require/test-a.js index 822ef540..769e40cd 100644 --- a/test/require/test-a.js +++ b/test/require/test-a.js @@ -1,7 +1,7 @@ var tape = require('../..'); tape.test('test-a', function(t) { - t.ok(global.module_a, 'module-a loaded in same context') - t.pass('test ran after module-a was loaded') - t.end() -}) \ No newline at end of file + t.ok(global.module_a, 'module-a loaded in same context') + t.pass('test ran after module-a was loaded') + t.end() +}) diff --git a/test/require/test-b.js b/test/require/test-b.js index 8efcba1c..4eb3b681 100644 --- a/test/require/test-b.js +++ b/test/require/test-b.js @@ -1,7 +1,7 @@ var tape = require('../..'); tape.test('test-b', function(t) { - t.ok(global.module_b, 'module-b loaded in same context') - t.pass('test ran after module-b was loaded') - t.end() -}) \ No newline at end of file + t.ok(global.module_b, 'module-b loaded in same context') + t.pass('test ran after module-b was loaded') + t.end() +}) diff --git a/test/skip.js b/test/skip.js index 54c53f90..c3bf8d9e 100644 --- a/test/skip.js +++ b/test/skip.js @@ -30,7 +30,7 @@ tap.test('test SKIP comment', function (assert) { test('skip this', { skip: true }, function(t) { t.fail('this should not even run'); - ran++; + ran++; t.end(); }); diff --git a/test/stackTrace.js b/test/stackTrace.js index 1cab4ace..8da3b529 100644 --- a/test/stackTrace.js +++ b/test/stackTrace.js @@ -239,13 +239,13 @@ function getDiag (body) { var yamlEnd = body.indexOf(' ...\n'); var diag = body.slice(yamlStart, yamlEnd).split('\n').map(function (line) { return line.slice(2); - }).join('\n'); + }).join('\n'); - // Get rid of 'at' variable (which has a line number / path of its own that's - // difficult to check). - var withStack = yaml.safeLoad(diag); - delete withStack.at; - return withStack; + // Get rid of 'at' variable (which has a line number / path of its own that's + // difficult to check). + var withStack = yaml.safeLoad(diag); + delete withStack.at; + return withStack; } function stripAt (body) { diff --git a/test/subtest_and_async.js b/test/subtest_and_async.js index 719dbf5b..9e49965d 100644 --- a/test/subtest_and_async.js +++ b/test/subtest_and_async.js @@ -1,23 +1,23 @@ var test = require('../'); var asyncFunction = function (callback) { - setTimeout(callback, Math.random * 50); + setTimeout(callback, Math.random * 50); }; test('master test', function (t) { - t.test('subtest 1', function (t) { - t.pass('subtest 1 before async call'); - asyncFunction(function () { - t.pass('subtest 1 in async callback'); - t.end(); - }) - }); + t.test('subtest 1', function (t) { + t.pass('subtest 1 before async call'); + asyncFunction(function () { + t.pass('subtest 1 in async callback'); + t.end(); + }) + }); - t.test('subtest 2', function (t) { - t.pass('subtest 2 before async call'); - asyncFunction(function () { - t.pass('subtest 2 in async callback'); - t.end(); - }) - }); + t.test('subtest 2', function (t) { + t.pass('subtest 2 before async call'); + asyncFunction(function () { + t.pass('subtest 2 in async callback'); + t.end(); + }) + }); }); diff --git a/test/throws.js b/test/throws.js index 5b576eb1..9b2bba96 100644 --- a/test/throws.js +++ b/test/throws.js @@ -32,142 +32,142 @@ tap.test('failures', function (tt) { tt.equal( stripFullStack(body.toString('utf8')), 'TAP version 13\n' - + '# non functions\n' - + 'not ok 1 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage() + "] message: '" + getNonFunctionMessage() + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage(undefined) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 2 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage(null) + "] message: '" + getNonFunctionMessage(null) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage(null) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 3 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage(true) + "] message: '" + getNonFunctionMessage(true) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage(true) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 4 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage(false) + "] message: '" + getNonFunctionMessage(false) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage(false) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 5 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage('abc') + "] message: '" + getNonFunctionMessage('abc') + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage('abc') + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 6 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage(/a/g) + "] message: '" + getNonFunctionMessage(/a/g) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage(/a/g) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 7 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage([]) + "] message: '" + getNonFunctionMessage([]) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage([]) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 8 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage({}) + "] message: '" + getNonFunctionMessage({}) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage({}) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '# function\n' - + 'not ok 9 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: undefined\n' - + ' actual: undefined\n' - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should throw\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '# custom error messages\n' - + 'ok 10 "message" is enumerable\n' - + "ok 11 { custom: 'error', message: 'message' }\n" - + 'ok 12 getter is still the same\n' - + '# throws null\n' - + 'ok 13 throws null\n' - + '\n1..13\n' - + '# tests 13\n' - + '# pass 4\n' - + '# fail 9\n' + + '# non functions\n' + + 'not ok 1 should throw\n' + + ' ---\n' + + ' operator: throws\n' + + ' expected: |-\n' + + ' undefined\n' + + ' actual: |-\n' + + " { [TypeError: " + getNonFunctionMessage() + "] message: '" + getNonFunctionMessage() + "' }\n" + + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' TypeError: ' + getNonFunctionMessage(undefined) + '\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 2 should throw\n' + + ' ---\n' + + ' operator: throws\n' + + ' expected: |-\n' + + ' undefined\n' + + ' actual: |-\n' + + " { [TypeError: " + getNonFunctionMessage(null) + "] message: '" + getNonFunctionMessage(null) + "' }\n" + + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' TypeError: ' + getNonFunctionMessage(null) + '\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 3 should throw\n' + + ' ---\n' + + ' operator: throws\n' + + ' expected: |-\n' + + ' undefined\n' + + ' actual: |-\n' + + " { [TypeError: " + getNonFunctionMessage(true) + "] message: '" + getNonFunctionMessage(true) + "' }\n" + + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' TypeError: ' + getNonFunctionMessage(true) + '\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 4 should throw\n' + + ' ---\n' + + ' operator: throws\n' + + ' expected: |-\n' + + ' undefined\n' + + ' actual: |-\n' + + " { [TypeError: " + getNonFunctionMessage(false) + "] message: '" + getNonFunctionMessage(false) + "' }\n" + + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' TypeError: ' + getNonFunctionMessage(false) + '\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 5 should throw\n' + + ' ---\n' + + ' operator: throws\n' + + ' expected: |-\n' + + ' undefined\n' + + ' actual: |-\n' + + " { [TypeError: " + getNonFunctionMessage('abc') + "] message: '" + getNonFunctionMessage('abc') + "' }\n" + + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' TypeError: ' + getNonFunctionMessage('abc') + '\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 6 should throw\n' + + ' ---\n' + + ' operator: throws\n' + + ' expected: |-\n' + + ' undefined\n' + + ' actual: |-\n' + + " { [TypeError: " + getNonFunctionMessage(/a/g) + "] message: '" + getNonFunctionMessage(/a/g) + "' }\n" + + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' TypeError: ' + getNonFunctionMessage(/a/g) + '\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 7 should throw\n' + + ' ---\n' + + ' operator: throws\n' + + ' expected: |-\n' + + ' undefined\n' + + ' actual: |-\n' + + " { [TypeError: " + getNonFunctionMessage([]) + "] message: '" + getNonFunctionMessage([]) + "' }\n" + + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' TypeError: ' + getNonFunctionMessage([]) + '\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 8 should throw\n' + + ' ---\n' + + ' operator: throws\n' + + ' expected: |-\n' + + ' undefined\n' + + ' actual: |-\n' + + " { [TypeError: " + getNonFunctionMessage({}) + "] message: '" + getNonFunctionMessage({}) + "' }\n" + + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' TypeError: ' + getNonFunctionMessage({}) + '\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + '# function\n' + + 'not ok 9 should throw\n' + + ' ---\n' + + ' operator: throws\n' + + ' expected: undefined\n' + + ' actual: undefined\n' + + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: should throw\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + '# custom error messages\n' + + 'ok 10 "message" is enumerable\n' + + "ok 11 { custom: 'error', message: 'message' }\n" + + 'ok 12 getter is still the same\n' + + '# throws null\n' + + 'ok 13 throws null\n' + + '\n1..13\n' + + '# tests 13\n' + + '# pass 4\n' + + '# fail 9\n' ); })); @@ -196,8 +196,8 @@ tap.test('failures', function (tt) { }); test('throws null', function (t) { - t.plan(1); - t.throws(function () { throw null; }, 'throws null'); - t.end(); + t.plan(1); + t.throws(function () { throw null; }, 'throws null'); + t.end(); }); }); diff --git a/test/timeoutAfter.js b/test/timeoutAfter.js index 7b8bf647..80752d28 100644 --- a/test/timeoutAfter.js +++ b/test/timeoutAfter.js @@ -6,7 +6,7 @@ var stripFullStack = require('./common').stripFullStack; tap.test('timeoutAfter test', function (tt) { tt.plan(1); - + var test = tape.createHarness(); var tc = function (rows) { tt.same(stripFullStack(rows.toString('utf8')), [ @@ -26,9 +26,9 @@ tap.test('timeoutAfter test', function (tt) { '# fail 1' ].join('\n') + '\n'); }; - + test.createStream().pipe(concat(tc)); - + test('timeoutAfter', function (t) { t.plan(1); t.timeoutAfter(1); diff --git a/test/too_many.js b/test/too_many.js index 3bd0ca56..5c7e4b38 100644 --- a/test/too_many.js +++ b/test/too_many.js @@ -7,7 +7,7 @@ var stripFullStack = require('./common').stripFullStack; tap.test('array test', function (tt) { tt.plan(1); - + var test = tape.createHarness({ exit : false }); var tc = function (rows) { tt.same(stripFullStack(rows.toString('utf8')), [ @@ -40,31 +40,31 @@ tap.test('array test', function (tt) { '# fail 1' ].join('\n') + '\n'); }; - + test.createStream().pipe(concat(tc)); - + test('array', function (t) { t.plan(3); - + var src = '(' + function () { var xs = [ 1, 2, [ 3, 4 ] ]; var ys = [ 5, 6 ]; g([ xs, ys ]); } + ')()'; - + var output = falafel(src, function (node) { if (node.type === 'ArrayExpression') { node.update('fn(' + node.source() + ')'); } }); - + var arrays = [ [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], ]; - + Function(['fn','g'], output)( function (xs) { t.same(arrays.shift(), xs); diff --git a/test/undef.js b/test/undef.js index f809384b..52759ac7 100644 --- a/test/undef.js +++ b/test/undef.js @@ -6,7 +6,7 @@ var stripFullStack = require('./common').stripFullStack; tap.test('array test', function (tt) { tt.plan(1); - + var test = tape.createHarness(); test.createStream().pipe(concat(function (body) { tt.equal( @@ -34,7 +34,7 @@ tap.test('array test', function (tt) { + '# fail 1\n' ); })); - + test('undef', function (t) { t.plan(1); t.deepEqual({}, { beep: undefined });