diff --git a/.eslintrc b/.eslintrc index 5cc84b03..0f0ffc01 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,16 +1,124 @@ { "root": true, + "env": { + "browser": true, + "node": true, + }, + "extends": "@ljharb", + "globals": { + "Promise": false, + }, "rules": { + "array-bracket-spacing": "off", + "complexity": "off", + "eqeqeq": ["error", "always", { "null": "ignore" }], + "func-style": "warn", "indent": ["error", 4], - "key-spacing": "error", - "quotes": ["error", "single", { - "avoidEscape": true, - }], - "semi": ["error", "always"], - "space-before-function-paren": ["error", { - "anonymous": "always", - "named": "never", - }], - "no-useless-escape": "error", + "no-magic-numbers": "off", + "max-lines": "warn", + "max-lines-per-function": "warn", + "max-statements": "warn", + "max-statements-per-line": [2, { "max": 2 }], + "multiline-comment-style": "off", + "no-param-reassign": "warn", + "no-negated-condition": "off", + "no-use-before-define": "warn", + "no-underscore-dangle": "warn", + "operator-linebreak": ["error", "before"], + "sort-keys": "warn", }, + "ignorePatterns": [ "syntax-error.*" ], + "overrides": [ + { + "files": ["*.mjs", "test/import/package_type/*.js"], + "extends": "@ljharb/eslint-config/esm", + }, + { + "files": ["bin/**"], + "rules": { + "global-require": "off", + "no-process-exit": "off", + "quote-props": ["error", "as-needed", { + "keywords": false, + }], + }, + }, + { + "files": ["bin/import-or-require.js"], + "parserOptions": { + "ecmaVersion": 2020, + }, + }, + { + "files": ["index.js"], + "rules": { + "no-param-reassign": "warn", + }, + }, + { + "files": ["lib/results.js"], + "rules": { + "no-cond-assign": "warn", + "no-param-reassign": "warn", + "no-plusplus": "warn", + }, + }, + { + "files": ["lib/test.js"], + "rules": { + "eqeqeq": "warn", + "func-name-matching": "off", + "max-params": "off", + "no-continue": "off", + "no-invalid-this": "off", + "no-param-reassign": "warn", + "no-plusplus": "warn", + "no-multi-assign": "off", + "no-restricted-syntax": "off", + }, + }, + { + "files": ["test/async-await/*"], + "parserOptions": { + "ecmaVersion": 2017, + }, + }, + { + "files": ["example/**", "test/**"], + "globals": { + "g": false, + }, + "rules": { + "no-new-func": "off", + }, + }, + { + "files": ["example/**"], + "rules": { + "array-bracket-newline": "off", + "global-require": "off", + "no-console": "off", + }, + }, + { + "files": ["test/**"], + "rules": { + "dot-notation": [2, { + "allowKeywords": true, + "allowPattern": "throws" + }], + "id-length": "off", + "max-len": "off", + "max-lines-per-function": "off", + "no-plusplus": "off", + "no-throw-literal": "off", + }, + }, + { + "files": ["test/*/**"], + "rules": { + "camelcase": "off", + }, + }, + ], } diff --git a/bin/tape b/bin/tape index 3ea1cec5..a0c755a1 100755 --- a/bin/tape +++ b/bin/tape @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + var resolveModule = require('resolve').sync; var resolvePath = require('path').resolve; var readFileSync = require('fs').readFileSync; @@ -21,9 +23,7 @@ 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. - */ + // This check ensures we ignore `-r ""`, trailing `-r`, or other silly things the user might (inadvertently) be doing. require(resolveModule(module, { basedir: cwd })); } }); @@ -39,8 +39,7 @@ if (typeof opts.ignore === 'string') { } opts._.forEach(function (arg) { - // If glob does not match, `files` will be an empty array. - // Note: `glob.sync` may throw an error and crash the node process. + // If glob does not match, `files` will be an empty array. Note: `glob.sync` may throw an error and crash the node process. var files = glob.sync(arg); if (!Array.isArray(files)) { diff --git a/example/array.js b/example/array.js index bec161f4..40be4847 100644 --- a/example/array.js +++ b/example/array.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var test = require('../'); @@ -17,13 +19,13 @@ test('array', function (t) { }); var arrays = [ - [ 3, 4 ], - [ 1, 2, [ 3, 4 ] ], - [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [3, 4], + [1, 2, [3, 4]], + [5, 6], + [[ 1, 2, [3, 4]], [5, 6]] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; diff --git a/example/fail.js b/example/fail.js index a0db0b11..4373c76b 100644 --- a/example/fail.js +++ b/example/fail.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var test = require('../'); @@ -20,10 +22,10 @@ test('array', function (t) { [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; diff --git a/example/nested.js b/example/nested.js index 2a36f25e..299f6bb4 100644 --- a/example/nested.js +++ b/example/nested.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var test = require('../'); @@ -5,8 +7,8 @@ test('nested array test', function (t) { t.plan(5); var src = '(' + function () { - var xs = [ 1, 2, [ 3, 4 ] ]; - var ys = [ 5, 6 ]; + var xs = [1, 2, [3, 4]]; + var ys = [5, 6]; g([ xs, ys ]); } + ')()'; @@ -26,19 +28,19 @@ test('nested array test', function (t) { }); var arrays = [ - [ 3, 4 ], - [ 1, 2, [ 3, 4 ] ], - [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [3, 4], + [1, 2, [3, 4]], + [5, 6], + [[ 1, 2, [3, 4]], [5, 6]] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; }, function (xs) { - t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); + t.same(xs, [[1, 2, [3, 4]], [5, 6]]); } ); }); diff --git a/example/nested_fail.js b/example/nested_fail.js index ba168c7e..44ea3fd1 100644 --- a/example/nested_fail.js +++ b/example/nested_fail.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var test = require('../'); @@ -29,10 +31,10 @@ test('nested array test', function (t) { [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; diff --git a/example/not_enough.js b/example/not_enough.js index fffc714f..e50ccac3 100644 --- a/example/not_enough.js +++ b/example/not_enough.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var test = require('../'); @@ -20,10 +22,10 @@ test('array', function (t) { [ 3, 4 ], [ 1, 2, [ 3, 4 ] ], [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; diff --git a/example/static/server.js b/example/static/server.js index 80cea43d..6b1e3532 100644 --- a/example/static/server.js +++ b/example/static/server.js @@ -1,3 +1,5 @@ +'use strict'; + var http = require('http'); var ecstatic = require('ecstatic')(__dirname); var server = http.createServer(ecstatic); diff --git a/example/stream/object.js b/example/stream/object.js index 20f0819f..39c662ce 100644 --- a/example/stream/object.js +++ b/example/stream/object.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../../'); var path = require('path'); diff --git a/example/stream/tap.js b/example/stream/tap.js index 9ea9ff74..53d7e232 100644 --- a/example/stream/tap.js +++ b/example/stream/tap.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../../'); var path = require('path'); diff --git a/example/stream/test/x.js b/example/stream/test/x.js index 7dbb98ad..670baa56 100644 --- a/example/stream/test/x.js +++ b/example/stream/test/x.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../../../'); test(function (t) { t.plan(1); diff --git a/example/stream/test/y.js b/example/stream/test/y.js index 28606d51..0a0928f2 100644 --- a/example/stream/test/y.js +++ b/example/stream/test/y.js @@ -1,7 +1,9 @@ +'use strict'; + var test = require('../../../'); test(function (t) { t.plan(2); - t.equal(1+1, 2); + t.equal(1 + 1, 2); t.ok(true); }); diff --git a/example/timing.js b/example/timing.js index 614c1441..4754776f 100644 --- a/example/timing.js +++ b/example/timing.js @@ -1,12 +1,14 @@ +'use strict'; + var test = require('../'); test('timing test', function (t) { t.plan(2); t.equal(typeof Date.now, 'function'); - var start = new Date; + var start = new Date(); setTimeout(function () { - t.equal(new Date - start, 100); + t.equal(new Date() - start, 100); }, 100); }); diff --git a/example/too_many.js b/example/too_many.js index cdcb5ee9..2ae76502 100644 --- a/example/too_many.js +++ b/example/too_many.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var test = require('../'); @@ -5,8 +7,8 @@ test('array', function (t) { t.plan(3); var src = '(' + function () { - var xs = [ 1, 2, [ 3, 4 ] ]; - var ys = [ 5, 6 ]; + var xs = [1, 2, [3, 4]]; + var ys = [5, 6]; g([ xs, ys ]); } + ')()'; @@ -17,19 +19,19 @@ test('array', function (t) { }); var arrays = [ - [ 3, 4 ], - [ 1, 2, [ 3, 4 ] ], - [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [3, 4], + [1, 2, [3, 4]], + [5, 6], + [[1, 2, [3, 4]], [5, 6]] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; }, function (xs) { - t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); + t.same(xs, [[1, 2, [3, 4]], [5, 6]]); } ); }); diff --git a/example/two.js b/example/two.js index 78e49c37..de5b213a 100644 --- a/example/two.js +++ b/example/two.js @@ -1,16 +1,18 @@ +'use strict'; + var test = require('../'); test('one', function (t) { t.plan(2); t.ok(true); setTimeout(function () { - t.equal(1+3, 4); + t.equal(1 + 3, 4); }, 100); }); test('two', function (t) { t.plan(3); - t.equal(5, 2+3); + t.equal(5, 2 + 3); setTimeout(function () { t.equal('a'.charCodeAt(0), 97); t.ok(true); diff --git a/index.js b/index.js index 839cd20d..7e402af3 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,5 @@ +'use strict'; + var defined = require('defined'); var createDefaultStream = require('./lib/default_stream'); var Test = require('./lib/test'); @@ -5,16 +7,14 @@ var createResult = require('./lib/results'); var through = require('through'); var canEmitExit = typeof process !== 'undefined' && process - && typeof process.on === 'function' && process.browser !== true -; + && typeof process.on === 'function' && process.browser !== true; var canExit = typeof process !== 'undefined' && process - && typeof process.exit === 'function' -; + && typeof process.exit === 'function'; module.exports = (function () { - var wait = false; var harness; var lazyLoad = function () { + // eslint-disable-next-line no-invalid-this return getHarness().apply(this, arguments); }; @@ -45,12 +45,12 @@ module.exports = (function () { return lazyLoad; function getHarness(opts) { - if (!opts) opts = {}; + if (!opts) { opts = {}; } opts.autoclose = !canEmitExit; - if (!harness) harness = createExitHarness(opts); + if (!harness) { harness = createExitHarness(opts); } return harness; } -})(); +}()); function createExitHarness(conf) { var config = conf || {}; @@ -61,14 +61,15 @@ function createExitHarness(conf) { var stream = harness.createStream({ objectMode: conf.objectMode }); var es = stream.pipe(conf.stream || createDefaultStream()); if (canEmitExit) { + // eslint-disable-next-line no-unused-vars es.on('error', function (err) { harness._exitCode = 1; }); } var ended = false; stream.on('end', function () { ended = true; }); - if (config.exit === false) return harness; - if (!canEmitExit || !canExit) return harness; + if (config.exit === false) { return harness; } + if (!canEmitExit || !canExit) { return harness; } process.on('exit', function (code) { // let the process exit cleanly. @@ -80,12 +81,13 @@ function createExitHarness(conf) { var only = harness._results._only; for (var i = 0; i < harness._tests.length; i++) { var t = harness._tests[i]; - if (only && t !== only) continue; - t._exit(); + if (!only || t === only) { + t._exit(); + } } } harness.close(); - process.exit(code || harness._exitCode); + process.exit(code || harness._exitCode); // eslint-disable-line no-process-exit }); return harness; @@ -111,9 +113,9 @@ function createHarness(conf_) { inspectCode(st_); }); st.on('result', function (r) { - if (!r.todo && !r.ok && typeof r !== 'string') test._exitCode = 1; + if (!r.todo && !r.ok && typeof r !== 'string') { test._exitCode = 1; } }); - })(t); + }(t)); results.push(t); return t; @@ -136,7 +138,7 @@ function createHarness(conf_) { var only = false; test.only = function () { - if (only) throw new Error('there can only be one only test'); + if (only) { throw new Error('there can only be one only test'); } only = true; var t = test.apply(null, arguments); results.only(t); diff --git a/lib/default_stream.js b/lib/default_stream.js index 2744258a..9e6372ec 100644 --- a/lib/default_stream.js +++ b/lib/default_stream.js @@ -1,3 +1,5 @@ +'use strict'; + var through = require('through'); var fs = require('fs'); @@ -10,20 +12,28 @@ module.exports = function () { for (var i = 0; i < buf.length; i++) { var c = typeof buf === 'string' ? buf.charAt(i) - : String.fromCharCode(buf[i]) - ; - if (c === '\n') flush(); - else line += c; + : String.fromCharCode(buf[i]); + if (c === '\n') { + flush(); + } else { + line += c; + } } } function flush() { - if (fs.writeSync && /^win/.test(process.platform)) { - try { fs.writeSync(1, line + '\n'); } - catch (e) { stream.emit('error', e); } + if (fs.writeSync && (/^win/).test(process.platform)) { + try { + fs.writeSync(1, line + '\n'); + } catch (e) { + stream.emit('error', e); + } } else { - try { console.log(line); } - catch (e) { stream.emit('error', e); } + try { + console.log(line); // eslint-disable-line no-console + } catch (e) { + stream.emit('error', e); + } } line = ''; } diff --git a/lib/results.js b/lib/results.js index 3299fbc8..29d8e242 100644 --- a/lib/results.js +++ b/lib/results.js @@ -1,3 +1,5 @@ +'use strict'; + var defined = require('defined'); var EventEmitter = require('events').EventEmitter; var inherits = require('inherits'); @@ -8,11 +10,7 @@ var callBound = require('call-bind/callBound'); var has = require('has'); var regexpTest = callBound('RegExp.prototype.test'); var yamlIndicators = /:|-|\?/; -var nextTick = typeof setImmediate !== 'undefined' - ? setImmediate - : process.nextTick -; - +var nextTick = typeof setImmediate !== 'undefined' ? setImmediate : process.nextTick; module.exports = Results; inherits(Results, EventEmitter); @@ -21,7 +19,7 @@ function coalesceWhiteSpaces(str) { } function Results() { - if (!(this instanceof Results)) return new Results; + if (!(this instanceof Results)) { return new Results(); } this.count = 0; this.fail = 0; this.pass = 0; @@ -33,13 +31,14 @@ function Results() { } Results.prototype.createStream = function (opts) { - if (!opts) opts = {}; + if (!opts) { opts = {}; } var self = this; - var output, testId = 0; + var output; + var testId = 0; if (opts.objectMode) { output = through(); self.on('_push', function ontest(t, extra) { - if (!extra) extra = {}; + if (!extra) { extra = {}; } var id = testId++; t.once('prerun', function () { var row = { @@ -81,7 +80,10 @@ Results.prototype.createStream = function (opts) { var t; while (t = getNextTest(self)) { t.run(); - if (!t.ended) return t.once('end', function () { nextTick(next); }); + if (!t.ended) { + t.once('end', function () { nextTick(next); }); + return; + } } self.emit('done'); }); @@ -106,8 +108,11 @@ Results.prototype._watch = function (t) { var write = function (s) { self._stream.queue(s); }; t.once('prerun', function () { var premsg = ''; - if (t._skip) premsg = 'SKIP '; - else if (t._todo) premsg = 'TODO '; + if (t._skip) { + premsg = 'SKIP '; + } else if (t._todo) { + premsg = 'TODO '; + } write('# ' + premsg + coalesceWhiteSpaces(t.name) + '\n'); }); @@ -117,11 +122,12 @@ Results.prototype._watch = function (t) { return; } write(encodeResult(res, self.count + 1)); - self.count ++; + self.count++; - if (res.ok || res.todo) self.pass ++; - else { - self.fail ++; + if (res.ok || res.todo) { + self.pass++; + } else { + self.fail++; self.emit('fail'); } }); @@ -131,16 +137,20 @@ Results.prototype._watch = function (t) { Results.prototype.close = function () { var self = this; - if (self.closed) self._stream.emit('error', new Error('ALREADY CLOSED')); + 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 + self.todo) + '\n'); - if (self.todo) write('# todo ' + self.todo + '\n'); - if (self.fail) write('# fail ' + self.fail + '\n'); - else write('\n# ok\n'); + if (self.todo) { + write('# todo ' + self.todo + '\n'); + } if (self.fail) { + write('# fail ' + self.fail + '\n'); + } else { + write('\n# ok\n'); + } self._stream.queue(null); }; @@ -151,13 +161,13 @@ function encodeResult(res, count) { output += res.name ? ' ' + coalesceWhiteSpaces(res.name) : ''; if (res.skip) { - output += ' # SKIP' + ((typeof res.skip === 'string') ? ' ' + coalesceWhiteSpaces(res.skip) : ''); + output += ' # SKIP' + (typeof res.skip === 'string' ? ' ' + coalesceWhiteSpaces(res.skip) : ''); } else if (res.todo) { - output += ' # TODO' + ((typeof res.todo === 'string') ? ' ' + coalesceWhiteSpaces(res.todo) : ''); - }; + output += ' # TODO' + (typeof res.todo === 'string' ? ' ' + coalesceWhiteSpaces(res.todo) : ''); + } output += '\n'; - if (res.ok) return output; + if (res.ok) { return output; } var outer = ' '; var inner = outer + ' '; @@ -165,8 +175,8 @@ function encodeResult(res, count) { 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}); + 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'; @@ -202,11 +212,12 @@ function getNextTest(results) { do { var t = results.tests.shift(); - if (!t) continue; - if (results._only === t) { + if (t && results._only === t) { return t; } } while (results.tests.length !== 0); + + return void undefined; } function invalidYaml(str) { diff --git a/lib/test.js b/lib/test.js index b002a67f..94fb175c 100644 --- a/lib/test.js +++ b/lib/test.js @@ -25,6 +25,7 @@ var safeClearTimeout = clearTimeout; inherits(Test, EventEmitter); +// eslint-disable-next-line no-unused-vars var getTestArgs = function (name_, opts_, cb_) { var name = '(anonymous)'; var opts = {}; @@ -41,11 +42,15 @@ var getTestArgs = function (name_, opts_, cb_) { cb = arg; } } - return { name: name, opts: opts, cb: cb }; + return { + name: name, + opts: opts, + cb: cb + }; }; function Test(name_, opts_, cb_) { - if (! (this instanceof Test)) { + if (!(this instanceof Test)) { return new Test(name_, opts_, cb_); } @@ -84,14 +89,15 @@ function Test(name_, opts_, cb_) { }; } return val; - })(this, this[prop]); + }(this, this[prop])); } } -Test.prototype.run = function () { +Test.prototype.run = function run() { this.emit('prerun'); if (!this._cb || this._skip) { - return this._end(); + this._end(); + return; } if (this._timeout != null) { this.timeoutAfter(this._timeout); @@ -136,7 +142,7 @@ Test.prototype.plan = function (n) { }; Test.prototype.timeoutAfter = function (ms) { - if (!ms) throw new Error('timeoutAfter requires a timespan'); + if (!ms) { throw new Error('timeoutAfter requires a timespan'); } var self = this; var timeout = safeSetTimeout(function () { self.fail(self.name + ' timed out after ' + ms + 'ms'); @@ -176,7 +182,6 @@ Test.prototype._end = function (err) { return; } - function next(i) { if (i === self._teardown.length) { completeEnd(); @@ -207,7 +212,7 @@ Test.prototype._end = function (err) { } function completeEnd() { - if (!self.ended) self.emit('end'); + if (!self.ended) { self.emit('end'); } var pendingAsserts = self._pendingAsserts(); if (!self._planError && self._plan !== undefined && pendingAsserts) { self._planError = true; @@ -221,8 +226,7 @@ Test.prototype._end = function (err) { }; Test.prototype._exit = function () { - if (this._plan !== undefined && - !this._planError && this.assertCount !== this._plan) { + if (this._plan !== undefined && !this._planError && this.assertCount !== this._plan) { this._planError = true; this.fail('plan != count', { expected: this._plan, @@ -326,12 +330,11 @@ Test.prototype._assert = function assert(ok, opts) { continue; } - // Function call description may not (just) be a function name. - // Try to extract function name by looking at first "word" only. + // Function call description may not (just) be a function name. Try to extract function name by looking at first "word" only. res.functionName = callDescription.split(/\s+/)[0]; res.file = filePath; res.line = Number(m[3]); - if (m[4]) res.column = Number(m[4]); + if (m[4]) { res.column = Number(m[4]); } res.at = callDescription + ' (' + filePath + ')'; break; @@ -385,7 +388,7 @@ Test.prototype.skip = function (msg, extra) { }); }; -function assert(value, msg, extra) { +var tapeAssert = function assert(value, msg, extra) { this._assert(value, { message: defined(msg, 'should be truthy'), operator: 'ok', @@ -393,11 +396,11 @@ function assert(value, msg, extra) { actual: value, extra: extra }); -} +}; Test.prototype.ok = Test.prototype['true'] = Test.prototype.assert -= assert; += tapeAssert; function notOK(value, msg, extra) { this._assert(!value, { @@ -631,6 +634,7 @@ Test.prototype.doesNotMatch = function doesNotMatch(string, regexp, msg, extra) }); }; +// eslint-disable-next-line no-unused-vars Test.skip = function (name_, _opts, _cb) { var args = getTestArgs.apply(null, arguments); args.opts.skip = true; diff --git a/package.json b/package.json index 1b8c6ab0..f1aea39e 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "through": "~2.3.8" }, "devDependencies": { + "@ljharb/eslint-config": "^17.6.0", "array.prototype.flatmap": "^1.2.4", "aud": "^1.1.5", "concat-stream": "^1.6.2", diff --git a/test/add-subtest-async.js b/test/add-subtest-async.js index 12b2e2d3..9d13d44e 100644 --- a/test/add-subtest-async.js +++ b/test/add-subtest-async.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); test('parent', function (t) { diff --git a/test/anonymous-fn.js b/test/anonymous-fn.js index f28c4340..9a73ed8a 100644 --- a/test/anonymous-fn.js +++ b/test/anonymous-fn.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); var concat = require('concat-stream'); diff --git a/test/anonymous-fn/test-wrapper.js b/test/anonymous-fn/test-wrapper.js index 38e8ba1a..f79ef485 100644 --- a/test/anonymous-fn/test-wrapper.js +++ b/test/anonymous-fn/test-wrapper.js @@ -1,3 +1,5 @@ +'use strict'; + // Example of wrapper function that would invoke tape module.exports = function (testCase) { return function (t) { diff --git a/test/array.js b/test/array.js index dc4a4a40..982ddd87 100644 --- a/test/array.js +++ b/test/array.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var tape = require('../'); var tap = require('tap'); @@ -30,9 +32,9 @@ tap.test('array test', function (tt) { t.plan(5); var src = '(' + function () { - var xs = [ 1, 2, [ 3, 4 ] ]; - var ys = [ 5, 6 ]; - g([ xs, ys ]); + var xs = [1, 2, [3, 4]]; + var ys = [5, 6]; + g([xs, ys]); } + ')()'; var output = falafel(src, function (node) { @@ -42,19 +44,19 @@ tap.test('array test', function (tt) { }); var arrays = [ - [ 3, 4 ], - [ 1, 2, [ 3, 4 ] ], - [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [3, 4], + [1, 2, [3, 4]], + [5, 6], + [[1, 2, [3, 4]], [5, 6]] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; }, function (xs) { - t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); + t.same(xs, [[1, 2, [3, 4]], [5, 6]]); } ); }); diff --git a/test/bound.js b/test/bound.js index 58f26920..cff296b3 100644 --- a/test/bound.js +++ b/test/bound.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); test('bind works', function (t) { diff --git a/test/browser/asserts.js b/test/browser/asserts.js index a1b24f6d..fb981b7c 100644 --- a/test/browser/asserts.js +++ b/test/browser/asserts.js @@ -1,9 +1,11 @@ +'use strict'; + var test = require('../../'); test(function (t) { t.plan(4); t.ok(true); - t.equal(3, 1+2); - t.deepEqual([1,2,[3,4]], [1,2,[3,4]]); - t.notDeepEqual([1,2,[3,4,5]], [1,2,[3,4]]); + t.equal(3, 1 + 2); + t.deepEqual([1, 2, [3, 4]], [1, 2, [3, 4]]); + t.notDeepEqual([1, 2, [3, 4, 5]], [1, 2, [3, 4]]); }); diff --git a/test/child_ordering.js b/test/child_ordering.js index 08d3c760..6c75f587 100644 --- a/test/child_ordering.js +++ b/test/child_ordering.js @@ -1,12 +1,14 @@ +'use strict'; + var test = require('../'); var childRan = false; test('parent', function (t) { - t.test('child', function (t) { + t.test('child', function (st) { childRan = true; - t.pass('child ran'); - t.end(); + st.pass('child ran'); + st.end(); }); t.end(); }); @@ -22,22 +24,22 @@ var grandChildRan = false; test('grandparent', function (t) { t.ok(!grandParentRan, 'grand parent ran twice'); grandParentRan = true; - t.test('parent', function (t) { - t.ok(!parentRan, 'parent ran twice'); + t.test('parent', function (st) { + st.ok(!parentRan, 'parent ran twice'); parentRan = true; - t.test('grandchild', function (t) { - t.ok(!grandChildRan, 'grand child ran twice'); + st.test('grandchild', function (s2t) { + s2t.ok(!grandChildRan, 'grand child ran twice'); grandChildRan = true; - t.pass('grand child ran'); - t.end(); + s2t.pass('grand child ran'); + s2t.end(); }); - t.pass('parent ran'); - t.end(); + st.pass('parent ran'); + st.end(); }); - t.test('other parent', function (t) { - t.ok(parentRan, 'first parent runs before second parent'); - t.ok(grandChildRan, 'grandchild runs before second parent'); - t.end(); + t.test('other parent', function (st) { + st.ok(parentRan, 'first parent runs before second parent'); + st.ok(grandChildRan, 'grandchild runs before second parent'); + st.end(); }); t.pass('grandparent ran'); t.end(); diff --git a/test/circular-things.js b/test/circular-things.js index 46562e1a..140727ea 100644 --- a/test/circular-things.js +++ b/test/circular-things.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); var concat = require('concat-stream'); diff --git a/test/comment.js b/test/comment.js index ff055e00..b9933b53 100644 --- a/test/comment.js +++ b/test/comment.js @@ -1,3 +1,5 @@ +'use strict'; + var concat = require('concat-stream'); var tap = require('tap'); var tape = require('../'); @@ -62,7 +64,6 @@ tap.test('null argument', function (assert) { }); }); - // Exploratory test, how is whitespace treated? tap.test('whitespace', function (assert) { assert.plan(1); @@ -130,7 +131,7 @@ tap.test('non-string types', function (assert) { t.comment(42); t.comment(6.66); t.comment({}); - t.comment({'answer': 42}); + t.comment({ answer: 42 }); function ConstructorFunction() {} t.comment(new ConstructorFunction()); t.comment(ConstructorFunction); @@ -164,11 +165,11 @@ tap.test('multiline string', function (assert) { test('multiline strings', function (t) { t.comment([ 'a', - 'b', + 'b' ].join('\n')); t.comment([ 'c', - 'd', + 'd' ].join('\r\n')); t.end(); }); diff --git a/test/common.js b/test/common.js index 8188fe65..eedc70ca 100644 --- a/test/common.js +++ b/test/common.js @@ -1,3 +1,5 @@ +'use strict'; + var path = require('path'); var yaml = require('js-yaml'); diff --git a/test/create_multiple_streams.js b/test/create_multiple_streams.js index 8ecac498..9307e881 100644 --- a/test/create_multiple_streams.js +++ b/test/create_multiple_streams.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); tape.test('createMultipleStreams', function (tt) { @@ -11,7 +13,7 @@ tape.test('createMultipleStreams', function (tt) { th('test one', function (tht) { tht.plan(1); - setTimeout( function () { + setTimeout(function () { tht.pass(); testOneComplete = true; }, 100); @@ -24,8 +26,7 @@ tape.test('createMultipleStreams', function (tt) { th.onFinish(function () { tt.equal(th._results.count, 2, 'harness test ran'); - tt.equal(th._results.fail, 0, "harness test didn't fail"); + tt.equal(th._results.fail, 0, "harness test didn't fail"); }); }); - diff --git a/test/deep-equal-failure.js b/test/deep-equal-failure.js index b086d2c3..c227ff4b 100644 --- a/test/deep-equal-failure.js +++ b/test/deep-equal-failure.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); var concat = require('concat-stream'); @@ -64,7 +66,7 @@ tap.test('deep equal failure', function (assert) { test('deep equal', function (t) { t.plan(1); - t.equal({a: 1}, {b: 2}); + t.equal({ a: 1 }, { b: 2 }); }); }); @@ -123,7 +125,7 @@ tap.test('deep equal failure, depth 6, with option', function (assert) { }); }); - test('deep equal', {objectPrintDepth: 6}, function (t) { + test('deep equal', { objectPrintDepth: 6 }, function (t) { t.plan(1); t.equal({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }); }); diff --git a/test/deep.js b/test/deep.js index 909ebe10..c5820043 100644 --- a/test/deep.js +++ b/test/deep.js @@ -1,17 +1,19 @@ +'use strict'; + var test = require('../'); test('deep strict equal', function (t) { t.notDeepEqual( - [ { a: '3' } ], - [ { a: 3 } ] + [{ a: '3' }], + [{ a: 3 }] ); t.end(); }); test('deep loose equal', function (t) { t.deepLooseEqual( - [ { a: '3' } ], - [ { a: 3 } ] + [{ a: '3' }], + [{ a: 3 }] ); t.end(); }); diff --git a/test/double_end.js b/test/double_end.js index f254ed35..64edb526 100644 --- a/test/double_end.js +++ b/test/double_end.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('tap').test; var path = require('path'); var concat = require('concat-stream'); @@ -18,7 +20,7 @@ test(function (t) { // This code is unfortunately by necessity highly coupled to node // versions, and may require tweaking with future versions of the timers // library. - function doEnd() { throw new Error(); }; + function doEnd() { throw new Error(); } var to = setTimeout(doEnd, 5000); clearTimeout(to); to._onTimeout = doEnd; @@ -27,8 +29,7 @@ test(function (t) { var atExpected; try { to._onTimeout(); - } - catch (e) { + } catch (e) { stackExpected = stripFullStack(e.stack)[1]; stackExpected = stackExpected.replace('double_end.js', 'double_end/double.js'); stackExpected = stackExpected.trim(); diff --git a/test/double_end/double.js b/test/double_end/double.js index 43929e51..2c0ae405 100644 --- a/test/double_end/double.js +++ b/test/double_end/double.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../../'); test('double end', function (t) { diff --git a/test/end-as-callback.js b/test/end-as-callback.js index a8c70940..301cad50 100644 --- a/test/end-as-callback.js +++ b/test/end-as-callback.js @@ -1,3 +1,5 @@ +'use strict'; + var tap = require('tap'); var forEach = require('for-each'); var tape = require('../'); @@ -73,14 +75,11 @@ function getStackTrace(rows) { if (row.indexOf('---') > -1) { // start of stack trace extract = true; } + } else if (row.indexOf('...') > -1) { // end of stack trace + extract = false; + stacktrace += ' ...'; } else { - if (row.indexOf('...') > -1) { // end of stack trace - extract = false; - stacktrace += ' ...'; - } else { - stacktrace += row + '\n'; - } - + stacktrace += row + '\n'; } }); // console.log(stacktrace); diff --git a/test/error.js b/test/error.js index 83e80100..18dcb0bd 100644 --- a/test/error.js +++ b/test/error.js @@ -32,7 +32,7 @@ tap.test('failures', function (tt) { '# tests 1', '# pass 0', '# fail 1', - '', + '' ]); })); diff --git a/test/exit.js b/test/exit.js index 80ef8ad5..7c528666 100644 --- a/test/exit.js +++ b/test/exit.js @@ -1,3 +1,5 @@ +'use strict'; + var tap = require('tap'); var path = require('path'); var spawn = require('child_process').spawn; @@ -25,7 +27,7 @@ tap.test('exit ok', function (t) { '', '# ok', '', // yes, these double-blank-lines at the end are required. - '' // if you can figure out how to remove them, please do! + '' // if you can figure out how to remove them, please do! ].join('\n')); }; diff --git a/test/exit/fail.js b/test/exit/fail.js index 07a65ca3..930f51df 100644 --- a/test/exit/fail.js +++ b/test/exit/fail.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../../'); var falafel = require('falafel'); @@ -5,9 +7,9 @@ test('array', function (t) { t.plan(5); var src = '(' + function () { - var xs = [ 1, 2, [ 3, 4 ] ]; - var ys = [ 5, 6 ]; - g([ xs, ys ]); + var xs = [1, 2, [3, 4]]; + var ys = [5, 6]; + g([xs, ys]); } + ')()'; var output = falafel(src, function (node) { @@ -17,19 +19,19 @@ test('array', function (t) { }); var arrays = [ - [ 3, 4 ], - [ 1, 2, [ 3, 4 ] ], - [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [3, 4], + [1, 2, [3, 4]], + [5, 6], + [[1, 2, [3, 4]], [5, 6]] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; }, function (xs) { - t.same(xs, [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]); + t.same(xs, [[1, 2, [3, 4444]], [5, 6]]); } ); }); diff --git a/test/exit/ok.js b/test/exit/ok.js index 6d405c7c..7649d940 100644 --- a/test/exit/ok.js +++ b/test/exit/ok.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var test = require('../../'); @@ -6,9 +8,9 @@ test('array', function (t) { t.plan(5); var src = '(' + function () { - var xs = [ 1, 2, [ 3, 4 ] ]; - var ys = [ 5, 6 ]; - g([ xs, ys ]); + var xs = [1, 2, [3, 4]]; + var ys = [5, 6]; + g([xs, ys]); } + ')()'; var output = falafel(src, function (node) { @@ -18,19 +20,19 @@ test('array', function (t) { }); var arrays = [ - [ 3, 4 ], - [ 1, 2, [ 3, 4 ] ], - [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [3, 4], + [1, 2, [3, 4]], + [5, 6], + [[1, 2, [3, 4]], [5, 6]] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; }, function (xs) { - t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); + t.same(xs, [[1, 2, [3, 4]], [5, 6]]); } ); }); diff --git a/test/exit/second.js b/test/exit/second.js index 8a206bb3..79e632e2 100644 --- a/test/exit/second.js +++ b/test/exit/second.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../../'); test('first', function (t) { diff --git a/test/exit/todo.js b/test/exit/todo.js index acbf960a..bf0de1a8 100644 --- a/test/exit/todo.js +++ b/test/exit/todo.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../../'); test('todo pass', { todo: true }, function (t) { diff --git a/test/exit/todo_fail.js b/test/exit/todo_fail.js index f8ffa67c..06ec32f1 100644 --- a/test/exit/todo_fail.js +++ b/test/exit/todo_fail.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../../'); test('todo fail', { todo: true }, function (t) { diff --git a/test/exit/too_few.js b/test/exit/too_few.js index 68ba71db..33bc0855 100644 --- a/test/exit/too_few.js +++ b/test/exit/too_few.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var test = require('../../'); @@ -5,9 +7,9 @@ test('array', function (t) { t.plan(6); var src = '(' + function () { - var xs = [ 1, 2, [ 3, 4 ] ]; - var ys = [ 5, 6 ]; - g([ xs, ys ]); + var xs = [1, 2, [3, 4]]; + var ys = [5, 6]; + g([xs, ys]); } + ')()'; var output = falafel(src, function (node) { @@ -17,19 +19,19 @@ test('array', function (t) { }); var arrays = [ - [ 3, 4 ], - [ 1, 2, [ 3, 4 ] ], - [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [3, 4], + [1, 2, [3, 4]], + [5, 6], + [[1, 2, [3, 4]], [5, 6]] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; }, function (xs) { - t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); + t.same(xs, [[1, 2, [3, 4]], [5, 6]]); } ); }); diff --git a/test/exposed-harness.js b/test/exposed-harness.js index 1056ddbc..d153eda7 100644 --- a/test/exposed-harness.js +++ b/test/exposed-harness.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); diff --git a/test/fail.js b/test/fail.js index 45df8d66..7a1f7285 100644 --- a/test/fail.js +++ b/test/fail.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var tape = require('../'); var tap = require('tap'); @@ -47,9 +49,9 @@ tap.test('array test', function (tt) { t.plan(5); var src = '(' + function () { - var xs = [ 1, 2, [ 3, 4 ] ]; - var ys = [ 5, 6 ]; - g([ xs, ys ]); + var xs = [1, 2, [3, 4]]; + var ys = [5, 6]; + g([xs, ys]); } + ')()'; var output = falafel(src, function (node) { @@ -59,19 +61,19 @@ tap.test('array test', function (tt) { }); var arrays = [ - [ 3, 4 ], - [ 1, 2, [ 3, 4 ] ], - [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [3, 4], + [1, 2, [3, 4]], + [5, 6], + [[1, 2, [3, 4]], [5, 6]] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; }, function (xs) { - t.same(xs, [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]); + t.same(xs, [[1, 2, [3, 4444]], [5, 6]]); } ); }); diff --git a/test/has spaces.js b/test/has spaces.js index 3e8c80db..990c9d88 100644 --- a/test/has spaces.js +++ b/test/has spaces.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); var concat = require('concat-stream'); diff --git a/test/ignore_from_gitignore.js b/test/ignore_from_gitignore.js index d95260b8..8260c2ec 100644 --- a/test/ignore_from_gitignore.js +++ b/test/ignore_from_gitignore.js @@ -38,7 +38,7 @@ tap.test('Should pass with ignoring', { skip: process.platform === 'win32' }, fu ]); }; - var ps = spawn(tapeBin, ['**/*.js', '-i', '.ignore'], {cwd: path.join(__dirname, 'ignore')}); + var ps = spawn(tapeBin, ['**/*.js', '-i', '.ignore'], { cwd: path.join(__dirname, 'ignore') }); ps.stdout.pipe(concat(tc)); ps.on('exit', function (code) { tt.equal(code, 0); // code 0 @@ -95,7 +95,7 @@ tap.test('Should pass', { skip: process.platform === 'win32' }, function (tt) { ]); }; - var ps = spawn(tapeBin, ['**/*.js'], {cwd: path.join(__dirname, 'ignore')}); + var ps = spawn(tapeBin, ['**/*.js'], { cwd: path.join(__dirname, 'ignore') }); ps.stdout.pipe(concat(tc)); ps.on('exit', function (code) { tt.equal(code, 1); @@ -110,10 +110,10 @@ tap.test('Should fail when ignore file does not exist', { skip: process.platform }; var testStderr = function (rows) { - tt.ok(/^ENOENT[:,] no such file or directory,? (?:open )?'\$TEST\/ignore\/.gitignore'\n$/m.test(stripFullStack(rows.toString('utf8')).join('\n'))); + tt.ok((/^ENOENT[:,] no such file or directory,? (?:open )?'\$TEST\/ignore\/.gitignore'\n$/m).test(stripFullStack(rows.toString('utf8')).join('\n'))); }; - var ps = spawn(tapeBin, ['**/*.js', '-i'], {cwd: path.join(__dirname, 'ignore')}); + var ps = spawn(tapeBin, ['**/*.js', '-i'], { cwd: path.join(__dirname, 'ignore') }); ps.stdout.pipe(concat(testStdout)); ps.stderr.pipe(concat(testStderr)); ps.on('exit', function (code) { diff --git a/test/many.js b/test/many.js index d6e85158..6e5368a3 100644 --- a/test/many.js +++ b/test/many.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); test('many tests', function (t) { diff --git a/test/match.js b/test/match.js index b598b9db..407d6b5d 100644 --- a/test/match.js +++ b/test/match.js @@ -56,13 +56,13 @@ tap.test('match', function (tt) { test('match', function (t) { t.plan(6); - t.throws( + t['throws']( function () { t.match(/abc/, 'string'); }, TypeError, 'regex arg must be a regex' ); - t.throws( + t['throws']( function () { t.match({ abc: 123 }, /abc/); }, TypeError, 'string arg must be a string' @@ -150,13 +150,13 @@ tap.test('doesNotMatch', function (tt) { test('doesNotMatch', function (t) { t.plan(6); - t.throws( + t['throws']( function () { t.doesNotMatch(/abc/, 'string'); }, TypeError, 'regex arg must be a regex' ); - t.throws( + t['throws']( function () { t.doesNotMatch({ abc: 123 }, /abc/); }, TypeError, 'string arg must be a string' diff --git a/test/max_listeners.js b/test/max_listeners.js index 23ebea8c..286a2b15 100644 --- a/test/max_listeners.js +++ b/test/max_listeners.js @@ -1,3 +1,5 @@ +'use strict'; + var spawn = require('child_process').spawn; var path = require('path'); diff --git a/test/max_listeners/source.js b/test/max_listeners/source.js index 2179f97d..137f8a1c 100644 --- a/test/max_listeners/source.js +++ b/test/max_listeners/source.js @@ -1,5 +1,10 @@ +'use strict'; + var test = require('../../'); -for (var i = 0; i < 11; i ++) { - test(function (t) { t.ok(true, 'true is truthy'); t.end(); }); +for (var i = 0; i < 11; i++) { + test(function (t) { + t.ok(true, 'true is truthy'); + t.end(); + }); } diff --git a/test/nested-async-plan-noend.js b/test/nested-async-plan-noend.js index 1acc1416..a086d8ed 100644 --- a/test/nested-async-plan-noend.js +++ b/test/nested-async-plan-noend.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); test('Harness async test support', function (t) { diff --git a/test/nested-sync-noplan-noend.js b/test/nested-sync-noplan-noend.js index c0e5d4ac..80a7da04 100644 --- a/test/nested-sync-noplan-noend.js +++ b/test/nested-sync-noplan-noend.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); var concat = require('concat-stream'); diff --git a/test/nested.js b/test/nested.js index 46822594..a2b5a390 100644 --- a/test/nested.js +++ b/test/nested.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var tape = require('../'); var tap = require('tap'); @@ -36,9 +38,9 @@ tap.test('array test', function (tt) { t.plan(6); var src = '(' + function () { - var xs = [ 1, 2, [ 3, 4 ] ]; - var ys = [ 5, 6 ]; - g([ xs, ys ]); + var xs = [1, 2, [3, 4]]; + var ys = [5, 6]; + g([xs, ys]); } + ')()'; var output = falafel(src, function (node) { @@ -57,19 +59,19 @@ tap.test('array test', function (tt) { }); var arrays = [ - [ 3, 4 ], - [ 1, 2, [ 3, 4 ] ], - [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [3, 4], + [1, 2, [3, 4]], + [5, 6], + [[1, 2, [3, 4]], [5, 6]] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; }, function (xs) { - t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); + t.same(xs, [[1, 2, [3, 4]], [5, 6]]); } ); }); diff --git a/test/nested2.js b/test/nested2.js index 1612b9b6..f167df61 100644 --- a/test/nested2.js +++ b/test/nested2.js @@ -1,18 +1,19 @@ +'use strict'; + var test = require('../'); test(function (t) { var i = 0; - t.test('setup', function (t) { + t.test('setup', function (st) { process.nextTick(function () { - t.equal(i, 0, 'called once'); + st.equal(i, 0, 'called once'); i++; - t.end(); + st.end(); }); }); - - t.test('teardown', function (t) { - t.end(); + t.test('teardown', function (st) { + st.end(); }); t.end(); diff --git a/test/no_callback.js b/test/no_callback.js index 760ff26c..99f268b5 100644 --- a/test/no_callback.js +++ b/test/no_callback.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); test('No callback.'); diff --git a/test/not-deep-equal-failure.js b/test/not-deep-equal-failure.js index 5ac49cc9..40fcb9d9 100644 --- a/test/not-deep-equal-failure.js +++ b/test/not-deep-equal-failure.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); var concat = require('concat-stream'); @@ -64,7 +66,7 @@ tap.test('deep equal failure', function (assert) { test('not deep equal', function (t) { t.plan(1); - t.notDeepEqual({b: 2}, {b: 2}); + t.notDeepEqual({ b: 2 }, { b: 2 }); }); }); @@ -123,7 +125,7 @@ tap.test('not deep equal failure, depth 6, with option', function (assert) { }); }); - test('not deep equal', {objectPrintDepth: 6}, function (t) { + test('not deep equal', { objectPrintDepth: 6 }, function (t) { t.plan(1); t.notDeepEqual({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }); }); diff --git a/test/not-equal-failure.js b/test/not-equal-failure.js index bb7f9167..6db2861a 100644 --- a/test/not-equal-failure.js +++ b/test/not-equal-failure.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); var concat = require('concat-stream'); diff --git a/test/objectMode.js b/test/objectMode.js index 33df4661..fd71d8cc 100644 --- a/test/objectMode.js +++ b/test/objectMode.js @@ -1,3 +1,5 @@ +'use strict'; + var tap = require('tap'); var tape = require('../'); var forEach = require('for-each'); @@ -12,7 +14,7 @@ tap.test('object results', function (assert) { }; printer.end = function (obj) { - if (obj) objects.push(obj); + if (obj) { objects.push(obj); } var todos = 0; var skips = 0; @@ -22,21 +24,21 @@ tap.test('object results', function (assert) { assert.equal(objects.length, 13); - forEach(objects, function (obj) { - if (obj.type === 'assert') { + forEach(objects, function (object) { + if (object.type === 'assert') { asserts++; - } else if (obj.type === 'test') { - testIds.push(obj.id); + } else if (object.type === 'test') { + testIds.push(object.id); - if (obj.skip) { + if (object.skip) { skips++; - } else if (obj.todo) { + } else if (object.todo) { todos++; } - } else if (obj.type === 'end') { - endIds.push(obj.text); + } else if (object.type === 'end') { + endIds.push(object.text); // test object should exist - assert.notEqual(testIds.indexOf(obj.test), -1); + assert.notEqual(testIds.indexOf(object.test), -1); } }); @@ -51,17 +53,17 @@ tap.test('object results', function (assert) { tape('parent', function (t1) { t1.equal(true, true); - t1.test('child1', {skip: true}, function (t2) { + t1.test('child1', { skip: true }, function (t2) { t2.equal(true, true); t2.equal(true, false); t2.end(); }); - t1.test('child2', {todo: true}, function (t3) { + t1.test('child2', { todo: true }, function (t3) { t3.equal(true, false); t3.equal(true, true); t3.end(); }); - t1.test('child3', {todo: true}); + t1.test('child3', { todo: true }); t1.equal(true, true); t1.equal(true, true); t1.end(); diff --git a/test/onFailure.js b/test/onFailure.js index 666227d7..0d7c1cc0 100644 --- a/test/onFailure.js +++ b/test/onFailure.js @@ -1,10 +1,12 @@ +'use strict'; + var tap = require('tap'); var tape = require('../').createHarness(); -//Because this test passing depends on a failure, -//we must direct the failing output of the inner test +// Because this test passing depends on a failure, +// we must direct the failing output of the inner test var noop = function () {}; -var mockSink = {on: noop, removeListener: noop, emit: noop, end: noop}; +var mockSink = { on: noop, removeListener: noop, emit: noop, end: noop }; tape.createStream().pipe(mockSink); tap.test('on failure', { timeout: 1000 }, function (tt) { diff --git a/test/onFinish.js b/test/onFinish.js index 7881273e..db3b7609 100644 --- a/test/onFinish.js +++ b/test/onFinish.js @@ -1,7 +1,9 @@ +'use strict'; + var tap = require('tap'); var tape = require('../'); -tap.test('on finish', {timeout: 1000}, function (tt) { +tap.test('on finish', { timeout: 1000 }, function (tt) { tt.plan(1); tape.onFinish(function () { tt.pass('tape ended'); diff --git a/test/only-twice.js b/test/only-twice.js index cca7c758..98008c90 100644 --- a/test/only-twice.js +++ b/test/only-twice.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); @@ -8,7 +10,7 @@ tap.test('only twice error', function (assert) { t.end(); }); - assert.throws(function () { + assert['throws'](function () { test.only('second only', function (t) { t.end(); }); diff --git a/test/only.js b/test/only.js index 41f2f839..27253efa 100644 --- a/test/only.js +++ b/test/only.js @@ -1,3 +1,5 @@ +'use strict'; + var tap = require('tap'); var tape = require('../'); var concat = require('concat-stream'); @@ -18,7 +20,7 @@ tap.test('tape only test', function (tt) { '', '# ok' ].join('\n') + '\n'); - tt.deepEqual(ran, [ 3 ]); + tt.deepEqual(ran, [3]); tt.end(); }; diff --git a/test/only2.js b/test/only2.js index fcf4f439..bf629978 100644 --- a/test/only2.js +++ b/test/only2.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); test('only2 test 1', function (t) { diff --git a/test/only3.js b/test/only3.js index b192a4e0..6c73ef83 100644 --- a/test/only3.js +++ b/test/only3.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); test('only3 test 1', function (t) { diff --git a/test/only4.js b/test/only4.js index d570b5bc..b4362124 100644 --- a/test/only4.js +++ b/test/only4.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); test('only4 duplicate test name', function (t) { diff --git a/test/only5.js b/test/only5.js index 0e158872..abbfbe20 100644 --- a/test/only5.js +++ b/test/only5.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); test.only('only5 duplicate test name', function (t) { diff --git a/test/order.js b/test/order.js index 02aaa055..5c0ea715 100644 --- a/test/order.js +++ b/test/order.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); var current = 0; diff --git a/test/plan_optional.js b/test/plan_optional.js index 680dbcbb..6731f269 100644 --- a/test/plan_optional.js +++ b/test/plan_optional.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); test('plan should be optional', function (t) { diff --git a/test/require.js b/test/require.js index 7420bb7e..14014cdd 100644 --- a/test/require.js +++ b/test/require.js @@ -1,3 +1,5 @@ +'use strict'; + var tap = require('tap'); var spawn = require('child_process').spawn; var concat = require('concat-stream'); @@ -62,8 +64,7 @@ tap.test('requiring multiple modules', function (t) { }); function tape(args) { - var proc = require('child_process'); var bin = __dirname + '/../bin/tape'; - return proc.spawn('node', [bin].concat(args.split(' ')), { cwd: __dirname }); + return spawn('node', [bin].concat(args.split(' ')), { cwd: __dirname }); } diff --git a/test/require/a.js b/test/require/a.js index 86e0296b..f4d87453 100644 --- a/test/require/a.js +++ b/test/require/a.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../..'); tape.test('module-a', function (t) { diff --git a/test/require/b.js b/test/require/b.js index 808fc9e5..f7fe3b1c 100644 --- a/test/require/b.js +++ b/test/require/b.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../..'); tape.test('module-b', function (t) { diff --git a/test/require/test-a.js b/test/require/test-a.js index 03d5a84a..bcf15ca9 100644 --- a/test/require/test-a.js +++ b/test/require/test-a.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../..'); tape.test('test-a', function (t) { diff --git a/test/require/test-b.js b/test/require/test-b.js index 5069b55b..6cd57bfd 100644 --- a/test/require/test-b.js +++ b/test/require/test-b.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../..'); tape.test('test-b', function (t) { diff --git a/test/skip.js b/test/skip.js index 234c75a9..d0843599 100644 --- a/test/skip.js +++ b/test/skip.js @@ -1,5 +1,6 @@ +'use strict'; + var test = require('../'); -var ran = 0; var concat = require('concat-stream'); var tap = require('tap'); @@ -30,21 +31,18 @@ tap.test('test SKIP comment', function (assert) { test('skip this', { skip: true }, function (t) { t.fail('this should not even run'); - ran++; t.end(); }); test.skip('skip this too', function (t) { t.fail('this should not even run'); - ran++; t.end(); }); test('skip subtest', function (t) { - ran++; - t.test('skip this', { skip: true }, function (t) { - t.fail('this should not even run'); - t.end(); + t.test('skip this', { skip: true }, function (st) { + st.fail('this should not even run'); + st.end(); }); t.end(); }); diff --git a/test/skip_explanation.js b/test/skip_explanation.js index 1752dcfd..544d3056 100644 --- a/test/skip_explanation.js +++ b/test/skip_explanation.js @@ -1,3 +1,5 @@ +'use strict'; + var tap = require('tap'); var test = require('../'); var concat = require('concat-stream'); @@ -72,7 +74,8 @@ tap.test('test skip explanations', function (assert) { // var platform = process.platform; something like this needed var platform = 'win32'; - t.fail('run openssl', + t.fail( + 'run openssl', { skip: platform === 'win32' && 'Installer cannot work on windows\nand fails to add to PATH\n\n Err: (2401) denied' } ); t.end(); diff --git a/test/stackTrace.js b/test/stackTrace.js index f2e4b4e2..8ae0ee6b 100644 --- a/test/stackTrace.js +++ b/test/stackTrace.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); var concat = require('concat-stream'); @@ -28,10 +30,9 @@ tap.test('preserves stack trace with newlines', function (tt) { }); stream.pipe(concat(function (body) { - var body = body.toString('utf8'); - body = stripAt(body); + var strippedBody = stripAt(body.toString('utf8')); tt.equal( - body, + strippedBody, 'TAP version 13\n' + '# multiline stack trace\n' + 'not ok 1 Error: Preserve stack\n' @@ -52,7 +53,7 @@ tap.test('preserves stack trace with newlines', function (tt) { + '# fail 1\n' ); - tt.deepEqual(getDiag(body), { + tt.deepEqual(getDiag(strippedBody), { stack: stackTrace, operator: 'error', expected: 'undefined', @@ -175,9 +176,9 @@ tap.test('preserves stack trace for failed assertions', function (tt) { parser.once('assert', function (data) { tt.equal(typeof data.diag.at, 'string'); tt.equal(typeof data.diag.stack, 'string'); - at = data.diag.at || ''; + var at = data.diag.at || ''; stack = data.diag.stack || ''; - tt.ok(/^Error: true should be false(\n at .+)+/.exec(stack), 'stack should be a stack'); + tt.ok((/^Error: true should be false(\n {4}at .+)+/).exec(stack), 'stack should be a stack'); tt.deepEqual(data, { ok: false, id: 1, @@ -193,10 +194,9 @@ tap.test('preserves stack trace for failed assertions', function (tt) { }); stream.pipe(concat(function (body) { - var body = body.toString('utf8'); - body = stripAt(body); + var strippedBody = stripAt(body.toString('utf8')); tt.equal( - body, + strippedBody, 'TAP version 13\n' + '# t.equal stack trace\n' + 'not ok 1 true should be false\n' @@ -206,7 +206,8 @@ tap.test('preserves stack trace for failed assertions', function (tt) { + ' actual: true\n' + ' stack: |-\n' + ' ' - + stack.replace(/\n/g, '\n ') + '\n' + + stack.replace(/\n/g, '\n ') + + '\n' + ' ...\n' + '\n' + '1..1\n' @@ -215,7 +216,7 @@ tap.test('preserves stack trace for failed assertions', function (tt) { + '# fail 1\n' ); - tt.deepEqual(getDiag(body), { + tt.deepEqual(getDiag(strippedBody), { stack: stack, operator: 'equal', expected: false, @@ -240,9 +241,9 @@ tap.test('preserves stack trace for failed assertions where actual===falsy', fun parser.once('assert', function (data) { tt.equal(typeof data.diag.at, 'string'); tt.equal(typeof data.diag.stack, 'string'); - at = data.diag.at || ''; + var at = data.diag.at || ''; stack = data.diag.stack || ''; - tt.ok(/^Error: false should be true(\n at .+)+/.exec(stack), 'stack should be a stack'); + tt.ok((/^Error: false should be true(\n {4}at .+)+/).exec(stack), 'stack should be a stack'); tt.deepEqual(data, { ok: false, id: 1, @@ -258,10 +259,9 @@ tap.test('preserves stack trace for failed assertions where actual===falsy', fun }); stream.pipe(concat(function (body) { - var body = body.toString('utf8'); - body = stripAt(body); + var strippedBody = stripAt(body.toString('utf8')); tt.equal( - body, + strippedBody, 'TAP version 13\n' + '# t.equal stack trace\n' + 'not ok 1 false should be true\n' @@ -271,7 +271,8 @@ tap.test('preserves stack trace for failed assertions where actual===falsy', fun + ' actual: false\n' + ' stack: |-\n' + ' ' - + stack.replace(/\n/g, '\n ') + '\n' + + stack.replace(/\n/g, '\n ') + + '\n' + ' ...\n' + '\n' + '1..1\n' @@ -280,7 +281,7 @@ tap.test('preserves stack trace for failed assertions where actual===falsy', fun + '# fail 1\n' ); - tt.deepEqual(getDiag(body), { + tt.deepEqual(getDiag(strippedBody), { stack: stack, operator: 'equal', expected: true, diff --git a/test/subcount.js b/test/subcount.js index 8985e6d8..62b94746 100644 --- a/test/subcount.js +++ b/test/subcount.js @@ -1,14 +1,16 @@ +'use strict'; + var test = require('../'); test('parent test', function (t) { t.plan(2); - t.test('first child', function (t) { - t.plan(1); - t.pass('pass first child'); + t.test('first child', function (st) { + st.plan(1); + st.pass('pass first child'); }); - t.test(function (t) { - t.plan(1); - t.pass('pass second child'); + t.test(function (st) { + st.plan(1); + st.pass('pass second child'); }); }); diff --git a/test/subtest_and_async.js b/test/subtest_and_async.js index 5d922850..a5843e53 100644 --- a/test/subtest_and_async.js +++ b/test/subtest_and_async.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); var asyncFunction = function (callback) { diff --git a/test/subtest_plan.js b/test/subtest_plan.js index e0f906e5..b3063b96 100644 --- a/test/subtest_plan.js +++ b/test/subtest_plan.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); test('parent', function (t) { @@ -7,15 +9,15 @@ test('parent', function (t) { t.pass('assertion in parent'); - t.test('first child', function (t) { - t.plan(1); - t.pass('pass first child'); + t.test('first child', function (st) { + st.plan(1); + st.pass('pass first child'); firstChildRan = true; }); - t.test('second child', function (t) { - t.plan(2); - t.ok(firstChildRan, 'first child ran first'); - t.pass('pass second child'); + t.test('second child', function (st) { + st.plan(2); + st.ok(firstChildRan, 'first child ran first'); + st.pass('pass second child'); }); }); diff --git a/test/teardown.js b/test/teardown.js index 51f16498..f804f8c6 100644 --- a/test/teardown.js +++ b/test/teardown.js @@ -95,7 +95,7 @@ tap.test('teardowns', function (tt) { ' [... stack stripped ...]', ' ...', i > 0 ? [] : [ - 'not ok '+ (offset + 1) +' plan != count', + 'not ok ' + (offset + 1) + ' plan != count', ' ---', ' operator: fail', ' expected: 1', @@ -120,14 +120,16 @@ tap.test('teardowns', function (tt) { '# success (promise) teardown: 3' ] : [ '# SKIP success (promise)' - ], [ + ], + [ '', '1..' + ((typeof Promise === 'function' ? 1 : 0) + 10 + v.nonFunctions.length), '# tests ' + ((typeof Promise === 'function' ? 1 : 0) + 10 + v.nonFunctions.length), '# pass ' + ((typeof Promise === 'function' ? 1 : 0) + 5), '# fail ' + (5 + v.nonFunctions.length), '' - ])); + ] + )); })); test('success', function (t) { diff --git a/test/throws.js b/test/throws.js index 5cad0334..a683bfcf 100644 --- a/test/throws.js +++ b/test/throws.js @@ -1,19 +1,18 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); var concat = require('concat-stream'); var stripFullStack = require('./common').stripFullStack; -function fn() { - throw new TypeError('RegExp'); -} - function getNonFunctionMessage(fn) { try { fn(); } catch (e) { return e.message; } + return ''; } var getter = function () { return 'message'; }; @@ -41,7 +40,7 @@ tap.test('failures', function (tt) { ' { [TypeError: ' + getNonFunctionMessage() + "] message: '" + getNonFunctionMessage() + "' }", ' at: Test. ($TEST/throws.js:$LINE:$COL)', ' stack: |-', - ' TypeError: ' + getNonFunctionMessage(undefined) + '', + String(' TypeError: ' + getNonFunctionMessage(undefined)), ' [... stack stripped ...]', ' at Test. ($TEST/throws.js:$LINE:$COL)', ' [... stack stripped ...]', @@ -55,7 +54,7 @@ tap.test('failures', function (tt) { ' { [TypeError: ' + getNonFunctionMessage(null) + "] message: '" + getNonFunctionMessage(null) + "' }", ' at: Test. ($TEST/throws.js:$LINE:$COL)', ' stack: |-', - ' TypeError: ' + getNonFunctionMessage(null) + '', + String(' TypeError: ' + getNonFunctionMessage(null)), ' [... stack stripped ...]', ' at Test. ($TEST/throws.js:$LINE:$COL)', ' [... stack stripped ...]', @@ -69,7 +68,7 @@ tap.test('failures', function (tt) { ' { [TypeError: ' + getNonFunctionMessage(true) + "] message: '" + getNonFunctionMessage(true) + "' }", ' at: Test. ($TEST/throws.js:$LINE:$COL)', ' stack: |-', - ' TypeError: ' + getNonFunctionMessage(true) + '', + String(' TypeError: ' + getNonFunctionMessage(true)), ' [... stack stripped ...]', ' at Test. ($TEST/throws.js:$LINE:$COL)', ' [... stack stripped ...]', @@ -83,7 +82,7 @@ tap.test('failures', function (tt) { ' { [TypeError: ' + getNonFunctionMessage(false) + "] message: '" + getNonFunctionMessage(false) + "' }", ' at: Test. ($TEST/throws.js:$LINE:$COL)', ' stack: |-', - ' TypeError: ' + getNonFunctionMessage(false) + '', + String(' TypeError: ' + getNonFunctionMessage(false)), ' [... stack stripped ...]', ' at Test. ($TEST/throws.js:$LINE:$COL)', ' [... stack stripped ...]', @@ -97,7 +96,7 @@ tap.test('failures', function (tt) { ' { [TypeError: ' + getNonFunctionMessage('abc') + "] message: '" + getNonFunctionMessage('abc') + "' }", ' at: Test. ($TEST/throws.js:$LINE:$COL)', ' stack: |-', - ' TypeError: ' + getNonFunctionMessage('abc') + '', + String(' TypeError: ' + getNonFunctionMessage('abc')), ' [... stack stripped ...]', ' at Test. ($TEST/throws.js:$LINE:$COL)', ' [... stack stripped ...]', @@ -111,7 +110,7 @@ tap.test('failures', function (tt) { ' { [TypeError: ' + getNonFunctionMessage(/a/g) + "] message: '" + getNonFunctionMessage(/a/g) + "' }", ' at: Test. ($TEST/throws.js:$LINE:$COL)', ' stack: |-', - ' TypeError: ' + getNonFunctionMessage(/a/g) + '', + String(' TypeError: ' + getNonFunctionMessage(/a/g)), ' [... stack stripped ...]', ' at Test. ($TEST/throws.js:$LINE:$COL)', ' [... stack stripped ...]', @@ -125,7 +124,7 @@ tap.test('failures', function (tt) { ' { [TypeError: ' + getNonFunctionMessage([]) + "] message: '" + getNonFunctionMessage([]) + "' }", ' at: Test. ($TEST/throws.js:$LINE:$COL)', ' stack: |-', - ' TypeError: ' + getNonFunctionMessage([]) + '', + String(' TypeError: ' + getNonFunctionMessage([])), ' [... stack stripped ...]', ' at Test. ($TEST/throws.js:$LINE:$COL)', ' [... stack stripped ...]', @@ -139,7 +138,7 @@ tap.test('failures', function (tt) { ' { [TypeError: ' + getNonFunctionMessage({}) + "] message: '" + getNonFunctionMessage({}) + "' }", ' at: Test. ($TEST/throws.js:$LINE:$COL)', ' stack: |-', - ' TypeError: ' + getNonFunctionMessage({}) + '', + String(' TypeError: ' + getNonFunctionMessage({})), ' [... stack stripped ...]', ' at Test. ($TEST/throws.js:$LINE:$COL)', ' [... stack stripped ...]', @@ -188,38 +187,38 @@ tap.test('failures', function (tt) { test('non functions', function (t) { t.plan(8); - t.throws(); - t.throws(null); - t.throws(true); - t.throws(false); - t.throws('abc'); - t.throws(/a/g); - t.throws([]); - t.throws({}); + t['throws'](); + t['throws'](null); + t['throws'](true); + t['throws'](false); + t['throws']('abc'); + t['throws'](/a/g); + t['throws']([]); + t['throws']({}); }); test('function', function (t) { t.plan(1); - t.throws(function () {}); + t['throws'](function () {}); }); test('custom error messages', function (t) { t.plan(3); t.equal(Object.prototype.propertyIsEnumerable.call(messageGetterError, 'message'), true, '"message" is enumerable'); - t.throws(thrower, "{ custom: 'error', message: 'message' }"); + t['throws'](thrower, "{ custom: 'error', message: 'message' }"); t.equal(Object.getOwnPropertyDescriptor(messageGetterError, 'message').get, getter, 'getter is still the same'); }); test('throws null', function (t) { t.plan(1); - t.throws(function () { throw null; }, 'throws null'); + t['throws'](function () { throw null; }, 'throws null'); t.end(); }); test('wrong type of error', function (t) { t.plan(1); var actual = new RangeError('actual!'); - t.throws(function () { throw actual; }, TypeError, 'throws actual'); + t['throws'](function () { throw actual; }, TypeError, 'throws actual'); t.end(); }); }); diff --git a/test/timeout.js b/test/timeout.js index b74b11a1..bf11242d 100644 --- a/test/timeout.js +++ b/test/timeout.js @@ -1,3 +1,5 @@ +'use strict'; + var test = require('../'); var ran = 0; diff --git a/test/timeoutAfter.js b/test/timeoutAfter.js index 366b5d6f..10a0fe4d 100644 --- a/test/timeoutAfter.js +++ b/test/timeoutAfter.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); var concat = require('concat-stream'); diff --git a/test/todo.js b/test/todo.js index 5b9351ee..fe25481a 100644 --- a/test/todo.js +++ b/test/todo.js @@ -1,3 +1,5 @@ +'use strict'; + var tap = require('tap'); var tape = require('../'); var concat = require('concat-stream'); diff --git a/test/todo_explanation.js b/test/todo_explanation.js index 225d584f..72c559ed 100644 --- a/test/todo_explanation.js +++ b/test/todo_explanation.js @@ -1,3 +1,5 @@ +'use strict'; + var tap = require('tap'); var tape = require('../'); var concat = require('concat-stream'); @@ -5,7 +7,7 @@ var concat = require('concat-stream'); var common = require('./common'); var stripFullStack = common.stripFullStack; -tap.test('tape todo test', { todo: process.versions.node.match(/0\.8\.\d+/) ? 'Fails on node 0.8': false }, function (assert) { +tap.test('tape todo test', { todo: process.versions.node.match(/0\.8\.\d+/) ? 'Fails on node 0.8' : false }, function (assert) { var test = tape.createHarness({ exit: false }); assert.plan(1); diff --git a/test/todo_single.js b/test/todo_single.js index 0359bcfa..d9da7eaa 100644 --- a/test/todo_single.js +++ b/test/todo_single.js @@ -1,3 +1,5 @@ +'use strict'; + var tap = require('tap'); var tape = require('../'); var concat = require('concat-stream'); diff --git a/test/too_many.js b/test/too_many.js index 6ac3e164..86131d85 100644 --- a/test/too_many.js +++ b/test/too_many.js @@ -1,3 +1,5 @@ +'use strict'; + var falafel = require('falafel'); var tape = require('../'); var tap = require('tap'); @@ -48,9 +50,9 @@ tap.test('array test', function (tt) { t.plan(3); var src = '(' + function () { - var xs = [ 1, 2, [ 3, 4 ] ]; - var ys = [ 5, 6 ]; - g([ xs, ys ]); + var xs = [1, 2, [3, 4]]; + var ys = [5, 6]; + g([xs, ys]); } + ')()'; var output = falafel(src, function (node) { @@ -60,19 +62,19 @@ tap.test('array test', function (tt) { }); var arrays = [ - [ 3, 4 ], - [ 1, 2, [ 3, 4 ] ], - [ 5, 6 ], - [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], + [3, 4], + [1, 2, [3, 4]], + [5, 6], + [[1, 2, [3, 4]], [5, 6]] ]; - Function(['fn','g'], output)( + Function(['fn', 'g'], output)( function (xs) { t.same(arrays.shift(), xs); return xs; }, function (xs) { - t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); + t.same(xs, [[1, 2, [3, 4]], [5, 6]]); } ); }); diff --git a/test/undef.js b/test/undef.js index 5b219d99..42846a29 100644 --- a/test/undef.js +++ b/test/undef.js @@ -1,3 +1,5 @@ +'use strict'; + var tape = require('../'); var tap = require('tap'); var concat = require('concat-stream');