Added some tests

This commit is contained in:
2021-06-23 22:30:45 +02:00
parent 24f897e907
commit 3d3d7fae48
3796 changed files with 218744 additions and 3 deletions

40
tests/node_modules/tape/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,40 @@
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 = 180
block_comment_start = /*
block_comment = *
block_comment_end = */
[.nycrc]
indent_style = tab
[*.md]
indent_style = space
indent_size = 4
[*.yml]
indent_style = space
indent_size = 2
[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 = 1

1
tests/node_modules/tape/.eslintignore generated vendored Normal file
View File

@@ -0,0 +1 @@
coverage/

45
tests/node_modules/tape/.eslintrc generated vendored Normal file
View File

@@ -0,0 +1,45 @@
{
"root": true,
"env": {
"browser": true,
"node": true,
},
"globals": {
"Promise": false,
},
"rules": {
"comma-dangle": ["error", "never"],
"indent": ["error", 4],
"key-spacing": "error",
"quotes": ["error", "single", {
"avoidEscape": true,
}],
"semi": ["error", "always"],
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
}],
"no-undef": "error",
"no-useless-escape": "error",
"operator-linebreak": ["error", "before"],
"space-unary-ops": ["error", {
"words": false,
"nonwords": false,
}],
"strict": "error",
},
"overrides": [
{
"files": ["test/async-await/*"],
"parserOptions": {
"ecmaVersion": 2017,
},
},
{
"files": ["example/**", "test/**"],
"globals": {
"g": false,
},
},
],
}

13
tests/node_modules/tape/.nycrc generated vendored Normal file
View File

@@ -0,0 +1,13 @@
{
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"lines": 86,
"statements": 85.93,
"functions": 82.43,
"branches": 76.06,
"exclude": [
"coverage",
"test"
]
}

21
tests/node_modules/tape/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2012 James Halliday
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

58
tests/node_modules/tape/bin/tape generated vendored Executable file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/env node
'use strict';
var resolveModule = require('resolve').sync;
var resolvePath = require('path').resolve;
var readFileSync = require('fs').readFileSync;
var parseOpts = require('minimist');
var glob = require('glob');
var ignore = require('dotignore');
var opts = parseOpts(process.argv.slice(2), {
alias: { r: 'require', i: 'ignore' },
string: ['require', 'ignore'],
default: { r: [], i: null }
});
var cwd = process.cwd();
if (typeof opts.require === 'string') {
opts.require = [opts.require];
}
opts.require.forEach(function (module) {
var options = { basedir: cwd, extensions: Object.keys(require.extensions) };
if (module) {
/* This check ensures we ignore `-r ""`, trailing `-r`, or
* other silly things the user might (inadvertently) be doing.
*/
require(resolveModule(module, options));
}
});
if (typeof opts.ignore === 'string') {
try {
var ignoreStr = readFileSync(resolvePath(cwd, opts.ignore || '.gitignore'), 'utf-8');
} catch (e) {
console.error(e.message);
process.exit(2);
}
var matcher = ignore.createMatcher(ignoreStr);
}
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.
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.');
}
files.filter(function (file) { return !matcher || !matcher.shouldIgnore(file); }).forEach(function (file) {
require(resolvePath(cwd, file));
});
});
// vim: ft=javascript

37
tests/node_modules/tape/example/array.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
var falafel = require('falafel');
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);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
}
);
});

37
tests/node_modules/tape/example/fail.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
var falafel = require('falafel');
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);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]);
}
);
});

53
tests/node_modules/tape/example/nested.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
'use strict';
var falafel = require('falafel');
var test = require('../');
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, '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);
return xs;
},
function (xs) {
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
}
);
});
test('another', function (t) {
t.plan(1);
setTimeout(function () {
t.ok(true);
}, 100);
});

53
tests/node_modules/tape/example/nested_fail.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
'use strict';
var falafel = require('falafel');
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);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
}
);
});
test('another', function (t) {
t.plan(1);
setTimeout(function () {
t.ok(true);
}, 100);
});

5
tests/node_modules/tape/example/no_callback.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
'use strict';
var test = require('../');
test('No cb test');

37
tests/node_modules/tape/example/not_enough_fail.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
var falafel = require('falafel');
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);
return xs;
},
function (xs) {
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
}
);
});

2
tests/node_modules/tape/example/static/build.sh generated vendored Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
browserify ../timing.js -o bundle.js

21
tests/node_modules/tape/example/static/index.html generated vendored Normal file
View File

@@ -0,0 +1,21 @@
<!doctype html>
<html>
<head>
<style>
body {
font-family: monospace;
white-space: pre;
}
</style>
</head>
<body>
<script>
if (typeof console === 'undefined') console = {};
console.log = function (msg) {
var txt = document.createTextNode(msg);
document.body.appendChild(txt);
};
</script>
<script src="bundle.js"></script>
</body>
</html>

6
tests/node_modules/tape/example/static/server.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
'use strict';
var http = require('http');
var ecstatic = require('ecstatic')(__dirname);
var server = http.createServer(ecstatic);
server.listen(8000);

12
tests/node_modules/tape/example/stream/object.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
var test = require('../../');
var path = require('path');
test.createStream({ objectMode: true }).on('data', function (row) {
console.log(JSON.stringify(row));
});
process.argv.slice(2).forEach(function (file) {
require(path.resolve(file));
});

10
tests/node_modules/tape/example/stream/tap.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
'use strict';
var test = require('../../');
var path = require('path');
test.createStream().pipe(process.stdout);
process.argv.slice(2).forEach(function (file) {
require(path.resolve(file));
});

View File

@@ -0,0 +1,7 @@
'use strict';
var test = require('../../../');
test(function (t) {
t.plan(1);
t.equal('beep', 'boop');
});

13
tests/node_modules/tape/example/stream/test/y.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
'use strict';
var test = require('../../../');
test(function (t) {
t.plan(2);
t.equal(1 + 1, 2);
t.ok(true);
});
test('wheee', function (t) {
t.ok(true);
t.end();
});

11
tests/node_modules/tape/example/throw.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
'use strict';
var test = require('../');
test('throw', function (t) {
t.plan(2);
setTimeout(function () {
throw new Error('doom');
}, 100);
});

14
tests/node_modules/tape/example/timing.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
'use strict';
var test = require('../');
test('timing test', function (t) {
t.plan(2);
t.equal(typeof Date.now, 'function');
var start = Date.now();
setTimeout(function () {
t.ok(Date.now() - start > 100);
}, 100);
});

37
tests/node_modules/tape/example/too_many_fail.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
var falafel = require('falafel');
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);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
}
);
});

20
tests/node_modules/tape/example/two.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
'use strict';
var test = require('../');
test('one', function (t) {
t.plan(2);
t.ok(true);
setTimeout(function () {
t.equal(1+3, 4);
}, 100);
});
test('two', function (t) {
t.plan(3);
t.equal(5, 2+3);
setTimeout(function () {
t.equal('a'.charCodeAt(0), 97);
t.ok(true);
}, 50);
});

154
tests/node_modules/tape/index.js generated vendored Normal file
View File

@@ -0,0 +1,154 @@
'use strict';
var defined = require('defined');
var createDefaultStream = require('./lib/default_stream');
var Test = require('./lib/test');
var createResult = require('./lib/results');
var through = require('through');
var canEmitExit = typeof process !== 'undefined' && process
&& typeof process.on === 'function' && process.browser !== true
;
var canExit = typeof process !== 'undefined' && process
&& typeof process.exit === 'function'
;
exports = module.exports = (function () {
var harness;
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) {
var output = through();
getHarness({ stream: output, objectMode: opts.objectMode });
return output;
}
return harness.createStream(opts);
};
lazyLoad.onFinish = function () {
return getHarness().onFinish.apply(this, arguments);
};
lazyLoad.onFailure = function () {
return getHarness().onFailure.apply(this, arguments);
};
lazyLoad.getHarness = getHarness;
return lazyLoad;
function getHarness(opts) {
if (!opts) opts = {};
opts.autoclose = !canEmitExit;
if (!harness) harness = createExitHarness(opts);
return harness;
}
})();
function createExitHarness(conf) {
if (!conf) 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;
process.on('exit', function (code) {
// let the process exit cleanly.
if (typeof code === 'number' && code !== 0) {
return;
}
if (!ended) {
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();
}
}
harness.close();
process.removeAllListeners('exit'); // necessary for node v0.6
process.exit(code || harness._exitCode);
});
return harness;
}
exports.createHarness = createHarness;
exports.Test = Test;
exports.test = exports; // tap compat
exports.test.skip = Test.skip;
function createHarness(conf_) {
if (!conf_) conf_ = {};
var results = createResult();
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_);
});
st.on('result', function (r) {
if (!r.todo && !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);
};
test.onFinish = function (cb) {
results.on('done', cb);
};
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');
only = true;
var t = test.apply(null, arguments);
results.only(t);
return t;
};
test._exitCode = 0;
test.close = function () { results.close(); };
return test;
}

32
tests/node_modules/tape/lib/default_stream.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
'use strict';
var through = require('through');
var fs = require('fs');
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'
? buf.charAt(i)
: 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); }
} else {
try { console.log(line); }
catch (e) { stream.emit('error', e); }
}
line = '';
}
};

220
tests/node_modules/tape/lib/results.js generated vendored Normal file
View File

@@ -0,0 +1,220 @@
'use strict';
var defined = require('defined');
var EventEmitter = require('events').EventEmitter;
var inherits = require('inherits');
var through = require('through');
var resumer = require('resumer');
var inspect = require('object-inspect');
var callBound = require('call-bind/callBound');
var has = require('has');
var regexpTest = callBound('RegExp.prototype.test');
var $split = callBound('String.prototype.split');
var $replace = callBound('String.prototype.replace');
var $shift = callBound('Array.prototype.shift');
var $push = callBound('Array.prototype.push');
var yamlIndicators = /:|-|\?/;
var nextTick = typeof setImmediate !== 'undefined'
? setImmediate
: process.nextTick
;
module.exports = Results;
inherits(Results, EventEmitter);
function coalesceWhiteSpaces(str) {
return $replace(String(str), /\s+/g, ' ');
}
function Results() {
if (!(this instanceof Results)) return new Results;
this.count = 0;
this.fail = 0;
this.pass = 0;
this.todo = 0;
this._stream = through();
this.tests = [];
this._only = null;
this._isRunning = false;
}
Results.prototype.createStream = function (opts) {
if (!opts) opts = {};
var self = this;
var output, testId = 0;
if (opts.objectMode) {
output = through();
self.on('_push', function ontest(t, extra) {
if (!extra) extra = {};
var id = testId++;
t.once('prerun', function () {
var row = {
type: 'test',
name: t.name,
id: id,
skip: t._skip,
todo: t._todo
};
if (has(extra, 'parent')) {
row.parent = extra.parent;
}
output.queue(row);
});
t.on('test', function (st) {
ontest(st, { parent: id });
});
t.on('result', function (res) {
if (res && typeof res === 'object') {
res.test = id;
res.type = 'assert';
}
output.queue(res);
});
t.on('end', function () {
output.queue({ type: 'end', test: id });
});
});
self.on('done', function () { output.queue(null); });
} else {
output = resumer();
output.queue('TAP version 13\n');
self._stream.pipe(output);
}
if (!this._isRunning) {
this._isRunning = true;
nextTick(function next() {
var t;
while (t = getNextTest(self)) {
t.run();
if (!t.ended) return t.once('end', function () { nextTick(next); });
}
self.emit('done');
});
}
return output;
};
Results.prototype.push = function (t) {
var self = this;
$push(self.tests, t);
self._watch(t);
self.emit('_push', t);
};
Results.prototype.only = function (t) {
this._only = t;
};
Results.prototype._watch = function (t) {
var self = this;
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 ';
write('# ' + premsg + coalesceWhiteSpaces(t.name) + '\n');
});
t.on('result', function (res) {
if (typeof res === 'string') {
write('# ' + res + '\n');
return;
}
write(encodeResult(res, self.count + 1));
self.count++;
if (res.ok || res.todo) self.pass++;
else {
self.fail++;
self.emit('fail');
}
});
t.on('test', function (st) { self._watch(st); });
};
Results.prototype.close = function () {
var self = this;
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');
self._stream.queue(null);
};
function encodeResult(res, count) {
var output = '';
output += (res.ok ? 'ok ' : 'not ok ') + count;
output += res.name ? ' ' + coalesceWhiteSpaces(res.name) : '';
if (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 += '\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';
} else {
output += inner + 'expected: ' + ex + '\n';
output += inner + 'actual: ' + ac + '\n';
}
}
if (res.at) {
output += inner + 'at: ' + res.at + '\n';
}
var actualStack = res.actual && (typeof res.actual === 'object' || typeof res.actual === 'function') ? res.actual.stack : undefined;
var errorStack = res.error && res.error.stack;
var stack = defined(actualStack, errorStack);
if (stack) {
var lines = $split(String(stack), '\n');
output += inner + 'stack: |-\n';
for (var i = 0; i < lines.length; i++) {
output += inner + ' ' + lines[i] + '\n';
}
}
output += outer + '...\n';
return output;
}
function getNextTest(results) {
if (!results._only) {
return $shift(results.tests);
}
do {
var t = $shift(results.tests);
if (!t) continue;
if (results._only === t) {
return t;
}
} while (results.tests.length !== 0);
}
function invalidYaml(str) {
return regexpTest(yamlIndicators, str);
}

750
tests/node_modules/tape/lib/test.js generated vendored Normal file
View File

@@ -0,0 +1,750 @@
'use strict';
var deepEqual = require('deep-equal');
var defined = require('defined');
var path = require('path');
var inherits = require('inherits');
var EventEmitter = require('events').EventEmitter;
var has = require('has');
var isRegExp = require('is-regex');
var trim = require('string.prototype.trim');
var callBound = require('call-bind/callBound');
var forEach = require('for-each');
var inspect = require('object-inspect');
var is = require('object-is');
var isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
var toLowerCase = callBound('String.prototype.toLowerCase');
var isProto = callBound('Object.prototype.isPrototypeOf');
var $test = callBound('RegExp.prototype.test');
var objectToString = callBound('Object.prototype.toString');
var $split = callBound('String.prototype.split');
var $replace = callBound('String.prototype.replace');
var $strSlice = callBound('String.prototype.slice');
var $push = callBound('Array.prototype.push');
var $shift = callBound('Array.prototype.shift');
module.exports = Test;
var nextTick = typeof setImmediate !== 'undefined'
? setImmediate
: process.nextTick;
var safeSetTimeout = setTimeout;
var safeClearTimeout = clearTimeout;
inherits(Test, EventEmitter);
var getTestArgs = function (name_, opts_, cb_) {
var name = '(anonymous)';
var opts = {};
var cb;
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
var t = typeof arg;
if (t === 'string') {
name = arg;
} else if (t === 'object') {
opts = arg || opts;
} else if (t === 'function') {
cb = arg;
}
}
return { name: name, opts: opts, cb: cb };
};
function Test(name_, opts_, cb_) {
if (!(this instanceof Test)) {
return new Test(name_, opts_, cb_);
}
var args = getTestArgs(name_, opts_, cb_);
this.readable = true;
this.name = args.name || '(anonymous)';
this.assertCount = 0;
this.pendingCount = 0;
this._skip = args.opts.skip || false;
this._todo = args.opts.todo || false;
this._timeout = args.opts.timeout;
this._plan = undefined;
this._cb = args.cb;
this._progeny = [];
this._teardown = [];
this._ok = true;
var depthEnvVar = process.env.NODE_TAPE_OBJECT_PRINT_DEPTH;
if (args.opts.objectPrintDepth) {
this._objectPrintDepth = args.opts.objectPrintDepth;
} else if (depthEnvVar) {
if (toLowerCase(depthEnvVar) === 'infinity') {
this._objectPrintDepth = Infinity;
} else {
this._objectPrintDepth = depthEnvVar;
}
} else {
this._objectPrintDepth = 5;
}
for (var prop in this) {
this[prop] = (function bind(self, val) {
if (typeof val === 'function') {
return function bound() {
return val.apply(self, arguments);
};
}
return val;
})(this, this[prop]);
}
}
Test.prototype.run = function () {
this.emit('prerun');
if (!this._cb || this._skip) {
return this._end();
}
if (this._timeout != null) {
this.timeoutAfter(this._timeout);
}
var callbackReturn = this._cb(this);
if (
typeof Promise === 'function'
&& callbackReturn
&& typeof callbackReturn.then === 'function'
) {
var self = this;
Promise.resolve(callbackReturn).then(function onResolve() {
if (!self.calledEnd) {
self.end();
}
})['catch'](function onError(err) {
if (err instanceof Error || objectToString(err) === '[object Error]') {
self.ifError(err);
} else {
self.fail(err);
}
self.end();
});
return;
}
this.emit('run');
};
Test.prototype.test = function (name, opts, cb) {
var self = this;
var t = new Test(name, opts, cb);
$push(this._progeny, t);
this.pendingCount++;
this.emit('test', t);
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();
}
});
};
Test.prototype.comment = function (msg) {
var that = this;
forEach($split(trim(msg), '\n'), function (aMsg) {
that.emit('result', $replace(trim(aMsg), /^#\s*/, ''));
});
};
Test.prototype.plan = function (n) {
this._plan = n;
this.emit('plan', n);
};
Test.prototype.timeoutAfter = function (ms) {
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');
self.end();
}, ms);
this.once('end', function () {
safeClearTimeout(timeout);
});
};
Test.prototype.end = function (err) {
var self = this;
if (arguments.length >= 1 && !!err) {
this.ifError(err);
}
if (this.calledEnd) {
this.fail('.end() already called');
}
this.calledEnd = true;
this._end();
};
Test.prototype.teardown = function (fn) {
if (typeof fn !== 'function') {
this.fail('teardown: ' + inspect(fn) + ' is not a function');
} else {
this._teardown.push(fn);
}
};
Test.prototype._end = function (err) {
var self = this;
if (!this._cb && !this._todo && !this._skip) this.fail('# TODO ' + this.name);
if (this._progeny.length) {
var t = $shift(this._progeny);
t.on('end', function () { self._end(); });
t.run();
return;
}
function next() {
if (self._teardown.length === 0) {
completeEnd();
return;
}
var fn = self._teardown.shift();
var res;
try {
res = fn();
} catch (e) {
self.fail(e);
}
if (res && typeof res.then === 'function') {
res.then(next, function (_err) {
err = err || _err;
});
} else {
next();
}
}
next();
function completeEnd() {
if (!self.ended) self.emit('end');
var pendingAsserts = self._pendingAsserts();
if (!self._planError && self._plan !== undefined && pendingAsserts) {
self._planError = true;
self.fail('plan != count', {
expected: self._plan,
actual: self.assertCount
});
}
self.ended = true;
}
};
Test.prototype._exit = function () {
if (this._plan !== undefined && !this._planError && this.assertCount !== this._plan) {
this._planError = true;
this.fail('plan != count', {
expected: this._plan,
actual: this.assertCount,
exiting: true
});
} else if (!this.ended) {
this.fail('test exited without ending: ' + this.name, {
exiting: true
});
}
};
Test.prototype._pendingAsserts = function () {
if (this._plan === undefined) {
return 1;
}
return this._plan - (this._progeny.length + this.assertCount);
};
Test.prototype._assert = function assert(ok, opts) {
var self = this;
var extra = opts.extra || {};
ok = !!ok || !!extra.skip;
var name = defined(extra.message, opts.message, '(unnamed assert)');
if (this.calledEnd && opts.operator !== 'fail') {
this.fail('.end() already called: ' + name);
return;
}
var res = {
id: self.assertCount++,
ok: ok,
skip: defined(extra.skip, opts.skip),
todo: defined(extra.todo, opts.todo, self._todo),
name: name,
operator: defined(extra.operator, opts.operator),
objectPrintDepth: self._objectPrintDepth
};
if (has(opts, 'actual') || has(extra, 'actual')) {
res.actual = defined(extra.actual, opts.actual);
}
if (has(opts, 'expected') || has(extra, 'expected')) {
res.expected = defined(extra.expected, opts.expected);
}
this._ok = !!(this._ok && ok);
if (!ok && !res.todo) {
res.error = defined(extra.error, opts.error, new Error(res.name));
}
if (!ok) {
var e = new Error('exception');
var err = $split(e.stack || '', '\n');
var dir = __dirname + path.sep;
for (var i = 0; i < err.length; i++) {
/*
Stack trace lines may resemble one of the following. We need
to correctly extract a function name (if any) and path / line
number 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)
at myFunction (C:\path\to\file.js:123:45)
at myFunction (/path/to/file.js:123)
at Test.<anonymous> (/path/to/file.js:123:45)
at Test.bound [as run] (/path/to/file.js:123:45)
at /path/to/file.js:123:45
Regex has three parts. First is non-capturing group for 'at '
(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
like `<anonymous>` or 'Test.bound [as run]'.
For our purposes, we assume that, if there is a function
name, it's everything leading up to the first open
parentheses (trimmed) before our pathname.
/(?:(.*)\s+\()?/
Last part captures file path plus line no (and optional
column no).
/((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)?/
*/
var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:)]+:(\d+)(?::(\d+))?)\)?$/;
var lineWithTokens = $replace($replace(err[i], process.cwd(), '/$CWD'), __dirname, '/$TEST');
var m = re.exec(lineWithTokens);
if (!m) {
continue;
}
var callDescription = m[1] || '<anonymous>';
var filePath = $replace($replace(m[2], '/$CWD', process.cwd()), '/$TEST', __dirname);
if ($strSlice(filePath, 0, dir.length) === dir) {
continue;
}
// Function call description may not (just) be a function name.
// Try to extract function name by looking at first "word" only.
res.functionName = $split(callDescription, /\s+/)[0];
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) {
self._end();
} else {
nextTick(function () {
self._end();
});
}
}
if (!self._planError && pendingAsserts < 0) {
self._planError = true;
self.fail('plan != count', {
expected: self._plan,
actual: self._plan - pendingAsserts
});
}
};
Test.prototype.fail = function (msg, extra) {
this._assert(false, {
message: msg,
operator: 'fail',
extra: extra
});
};
Test.prototype.pass = function (msg, extra) {
this._assert(true, {
message: msg,
operator: 'pass',
extra: extra
});
};
Test.prototype.skip = function (msg, extra) {
this._assert(true, {
message: msg,
operator: 'skip',
skip: true,
extra: extra
});
};
function assert(value, msg, extra) {
this._assert(value, {
message: defined(msg, 'should be truthy'),
operator: 'ok',
expected: true,
actual: value,
extra: extra
});
}
Test.prototype.ok
= Test.prototype['true']
= Test.prototype.assert
= assert;
function notOK(value, msg, extra) {
this._assert(!value, {
message: defined(msg, 'should be falsy'),
operator: 'notOk',
expected: false,
actual: value,
extra: extra
});
}
Test.prototype.notOk
= Test.prototype['false']
= Test.prototype.notok
= notOK;
function error(err, msg, extra) {
this._assert(!err, {
message: defined(msg, String(err)),
operator: 'error',
error: err,
extra: extra
});
}
Test.prototype.error
= Test.prototype.ifError
= Test.prototype.ifErr
= Test.prototype.iferror
= error;
function strictEqual(a, b, msg, extra) {
if (arguments.length < 2) {
throw new TypeError('two arguments must be provided to compare');
}
this._assert(is(a, b), {
message: defined(msg, 'should be strictly equal'),
operator: 'equal',
actual: a,
expected: b,
extra: extra
});
}
Test.prototype.equal
= Test.prototype.equals
= Test.prototype.isEqual
= Test.prototype.strictEqual
= Test.prototype.strictEquals
= Test.prototype.is
= strictEqual;
function notStrictEqual(a, b, msg, extra) {
if (arguments.length < 2) {
throw new TypeError('two arguments must be provided to compare');
}
this._assert(!is(a, b), {
message: defined(msg, 'should not be strictly equal'),
operator: 'notEqual',
actual: a,
expected: b,
extra: extra
});
}
Test.prototype.notEqual
= Test.prototype.notEquals
= Test.prototype.isNotEqual
= Test.prototype.doesNotEqual
= Test.prototype.isInequal
= Test.prototype.notStrictEqual
= Test.prototype.notStrictEquals
= Test.prototype.isNot
= Test.prototype.not
= notStrictEqual;
function looseEqual(a, b, msg, extra) {
if (arguments.length < 2) {
throw new TypeError('two arguments must be provided to compare');
}
this._assert(a == b, {
message: defined(msg, 'should be loosely equal'),
operator: 'looseEqual',
actual: a,
expected: b,
extra: extra
});
}
Test.prototype.looseEqual
= Test.prototype.looseEquals
= looseEqual;
function notLooseEqual(a, b, msg, extra) {
if (arguments.length < 2) {
throw new TypeError('two arguments must be provided to compare');
}
this._assert(a != b, {
message: defined(msg, 'should not be loosely equal'),
operator: 'notLooseEqual',
actual: a,
expected: b,
extra: extra
});
}
Test.prototype.notLooseEqual
= Test.prototype.notLooseEquals
= notLooseEqual;
function tapeDeepEqual(a, b, msg, extra) {
if (arguments.length < 2) {
throw new TypeError('two arguments must be provided to compare');
}
this._assert(deepEqual(a, b, { strict: true }), {
message: defined(msg, 'should be deeply equivalent'),
operator: 'deepEqual',
actual: a,
expected: b,
extra: extra
});
}
Test.prototype.deepEqual
= Test.prototype.deepEquals
= Test.prototype.isEquivalent
= Test.prototype.same
= tapeDeepEqual;
function notDeepEqual(a, b, msg, extra) {
if (arguments.length < 2) {
throw new TypeError('two arguments must be provided to compare');
}
this._assert(!deepEqual(a, b, { strict: true }), {
message: defined(msg, 'should not be deeply equivalent'),
operator: 'notDeepEqual',
actual: a,
expected: b,
extra: extra
});
}
Test.prototype.notDeepEqual
= Test.prototype.notDeepEquals
= Test.prototype.notEquivalent
= Test.prototype.notDeeply
= Test.prototype.notSame
= Test.prototype.isNotDeepEqual
= Test.prototype.isNotDeeply
= Test.prototype.isNotEquivalent
= Test.prototype.isInequivalent
= notDeepEqual;
function deepLooseEqual(a, b, msg, extra) {
if (arguments.length < 2) {
throw new TypeError('two arguments must be provided to compare');
}
this._assert(deepEqual(a, b), {
message: defined(msg, 'should be loosely deeply equivalent'),
operator: 'deepLooseEqual',
actual: a,
expected: b,
extra: extra
});
}
Test.prototype.deepLooseEqual
= deepLooseEqual;
function notDeepLooseEqual(a, b, msg, extra) {
if (arguments.length < 2) {
throw new TypeError('two arguments must be provided to compare');
}
this._assert(!deepEqual(a, b), {
message: defined(msg, 'should not be loosely deeply equivalent'),
operator: 'notDeepLooseEqual',
actual: a,
expected: b,
extra: extra
});
}
Test.prototype.notDeepLooseEqual
= notDeepLooseEqual;
Test.prototype['throws'] = function (fn, expected, msg, extra) {
if (typeof expected === 'string') {
msg = expected;
expected = undefined;
}
var caught = undefined;
try {
fn();
} catch (err) {
caught = { error: err };
if (Object(err) === err && (!isEnumerable(err, 'message') || !has(err, 'message'))) {
var message = err.message;
delete err.message;
err.message = message;
}
}
var passed = caught;
if (caught) {
if (typeof expected === 'string' && caught.error && caught.error.message === expected) {
throw new TypeError('The "error/message" argument is ambiguous. The error message ' + inspect(expected) + ' is identical to the message.');
}
if (typeof expected === 'function') {
if (typeof expected.prototype !== 'undefined' && caught.error instanceof expected) {
passed = true;
} else if (isProto(Error, expected)) {
passed = false;
} else {
passed = expected.call({}, caught.error) === true;
}
} else if (isRegExp(expected)) {
passed = expected.test(caught.error);
expected = inspect(expected);
} else if (expected && typeof expected === 'object') { // Handle validation objects.
var keys = Object.keys(expected);
// Special handle errors to make sure the name and the message are compared as well.
if (expected instanceof Error) {
$push(keys, 'name', 'message');
} else if (keys.length === 0) {
throw new TypeError('`throws` validation object must not be empty');
}
passed = keys.every(function (key) {
if (typeof caught.error[key] === 'string' && isRegExp(expected[key]) && $test(expected[key], caught.error[key])) {
return true;
}
if (key in caught.error && deepEqual(caught.error[key], expected[key], { strict: true })) {
return true;
}
return false;
});
}
}
this._assert(!!passed, {
message: defined(msg, 'should throw'),
operator: 'throws',
actual: caught && caught.error,
expected: expected,
error: !passed && caught && caught.error,
extra: extra
});
};
Test.prototype.doesNotThrow = function (fn, expected, msg, extra) {
if (typeof expected === 'string') {
msg = expected;
expected = undefined;
}
var caught = undefined;
try {
fn();
}
catch (err) {
caught = { error: err };
}
this._assert(!caught, {
message: defined(msg, 'should not throw'),
operator: 'throws',
actual: caught && caught.error,
expected: expected,
error: caught && caught.error,
extra: extra
});
};
Test.prototype.match = function match(string, regexp, msg, extra) {
if (!isRegExp(regexp)) {
throw new TypeError('The "regexp" argument must be an instance of RegExp. Received type ' + typeof regexp + ' (' + inspect(regexp) + ')');
}
if (typeof string !== 'string') {
throw new TypeError('The "string" argument must be of type string. Received type ' + typeof string + ' (' + inspect(string) + ')');
}
var matches = $test(regexp, string);
var message = defined(
msg,
'The input ' + (matches ? 'matched' : 'did not match') + ' the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string)
);
this._assert(matches, {
message: message,
operator: 'match',
actual: string,
expected: regexp,
extra: extra
});
};
Test.prototype.doesNotMatch = function doesNotMatch(string, regexp, msg, extra) {
if (!isRegExp(regexp)) {
throw new TypeError('The "regexp" argument must be an instance of RegExp. Received type ' + typeof regexp + ' (' + inspect(regexp) + ')');
}
if (typeof string !== 'string') {
throw new TypeError('The "string" argument must be of type string. Received type ' + typeof string + ' (' + inspect(string) + ')');
}
var matches = $test(regexp, string);
var message = defined(
msg,
'The input ' + (matches ? 'was expected to not match' : 'did not match') + ' the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string)
);
this._assert(!matches, {
message: message,
operator: 'doesNotMatch',
actual: string,
expected: regexp,
extra: extra
});
};
Test.skip = function (name_, _opts, _cb) {
var args = getTestArgs.apply(null, arguments);
args.opts.skip = true;
return Test(args.name, args.opts, args.cb);
};
// vim: set softtabstop=4 shiftwidth=4:

126
tests/node_modules/tape/package.json generated vendored Normal file
View File

@@ -0,0 +1,126 @@
{
"_from": "tape",
"_id": "tape@5.2.2",
"_inBundle": false,
"_integrity": "sha512-grXrzPC1ly2kyTMKdqxh5GiLpb0BpNctCuecTB0psHX4Gu0nc+uxWR4xKjTh/4CfQlH4zhvTM2/EXmHXp6v/uA==",
"_location": "/tape",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "tape",
"name": "tape",
"escapedName": "tape",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/tape/-/tape-5.2.2.tgz",
"_shasum": "a98475ecf30aa0ed2a89c36439bb9438d24d2184",
"_spec": "tape",
"_where": "/home/lilleman/go/src/gitlab.larvit.se/power-plan/auth/tests",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"bin": {
"tape": "bin/tape"
},
"bugs": {
"url": "https://github.com/substack/tape/issues"
},
"bundleDependencies": false,
"dependencies": {
"call-bind": "^1.0.2",
"deep-equal": "^2.0.5",
"defined": "^1.0.0",
"dotignore": "^0.1.2",
"for-each": "^0.3.3",
"glob": "^7.1.6",
"has": "^1.0.3",
"inherits": "^2.0.4",
"is-regex": "^1.1.2",
"minimist": "^1.2.5",
"object-inspect": "^1.9.0",
"object-is": "^1.1.5",
"object.assign": "^4.1.2",
"resolve": "^2.0.0-next.3",
"resumer": "^0.0.0",
"string.prototype.trim": "^1.2.4",
"through": "^2.3.8"
},
"deprecated": false,
"description": "tap-producing test harness for node and browsers",
"devDependencies": {
"array.prototype.flatmap": "^1.2.4",
"aud": "^1.1.4",
"concat-stream": "^1.6.2",
"eclint": "^2.8.1",
"ecstatic": "^4.1.4",
"es-value-fixtures": "^1.2.1",
"eslint": "^7.20.0",
"falafel": "^2.2.4",
"js-yaml": "^3.14.0",
"tap": "^8.0.1",
"tap-parser": "^3.0.5"
},
"directories": {
"example": "example",
"test": "test"
},
"exports": {
".": [
{
"default": "./index.js"
},
"./index.js"
],
"./lib/default_stream": "./lib/default_stream.js",
"./lib/results": "./lib/results.js",
"./lib/test": "./lib/test.js",
"./package": "./package.json",
"./package.json": "./package.json"
},
"homepage": "https://github.com/substack/tape",
"keywords": [
"tap",
"test",
"harness",
"assert",
"browser"
],
"license": "MIT",
"main": "index.js",
"name": "tape",
"repository": {
"type": "git",
"url": "git://github.com/substack/tape.git"
},
"scripts": {
"lint": "eslint . bin/*",
"posttest": "aud --production",
"prelint": "eclint check",
"pretest": "npm run lint",
"test": "npm run tests-only",
"test:example": "find example -name '*.js' | grep -v fail | grep -v static | xargs tap",
"tests-only": "nyc 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"
]
},
"version": "5.2.2"
}

527
tests/node_modules/tape/readme.markdown generated vendored Normal file
View File

@@ -0,0 +1,527 @@
# tape
tap-producing test harness for node and browsers
[![build status](https://secure.travis-ci.org/substack/tape.svg?branch=master)](http://travis-ci.org/substack/tape)
![tape](https://web.archive.org/web/20170612184731if_/http://substack.net/images/tape_drive.png)
# example
``` js
var test = require('tape');
test('timing test', function (t) {
t.plan(2);
t.equal(typeof Date.now, 'function');
var start = Date.now();
setTimeout(function () {
t.equal(Date.now() - start, 100);
}, 100);
});
test('test using promises', async function (t) {
const result = await someAsyncThing();
t.ok(result);
});
```
```
$ node example/timing.js
TAP version 13
# timing test
ok 1 should be strictly equal
not ok 2 should be strictly equal
---
operator: equal
expected: 100
actual: 107
...
1..2
# tests 2
# pass 1
# fail 1
```
# usage
You always need to `require('tape')` in test files. You can run the tests by
usual node means (`require('test-file.js')` or `node test-file.js`). You can
also run tests using the `tape` binary to utilize globbing, on Windows for
example:
```sh
$ tape tests/**/*.js
```
`tape`'s arguments are passed to the
[`glob`](https://www.npmjs.com/package/glob) module. If you want `glob` to
perform the expansion on a system where the shell performs such expansion, quote
the arguments as necessary:
```sh
$ tape 'tests/**/*.js'
$ tape "tests/**/*.js"
```
## Preloading modules
Additionally, it is possible to make `tape` load one or more modules before running any tests, by using the `-r` or `--require` flag. Here's an example that loads [babel-register](http://babeljs.io/docs/usage/require/) before running any tests, to allow for JIT compilation:
```sh
$ tape -r babel-register tests/**/*.js
```
Depending on the module you're loading, you may be able to parameterize it using environment variables or auxiliary files. Babel, for instance, will load options from [`.babelrc`](http://babeljs.io/docs/usage/babelrc/) at runtime.
The `-r` flag behaves exactly like node's `require`, and uses the same module resolution algorithm. This means that if you need to load local modules, you have to prepend their path with `./` or `../` accordingly.
For example:
```sh
$ tape -r ./my/local/module tests/**/*.js
```
Please note that all modules loaded using the `-r` flag will run *before* any tests, regardless of when they are specified. For example, `tape -r a b -r c` will actually load `a` and `c` *before* loading `b`, since they are flagged as required modules.
# things that go well with tape
`tape` maintains a fairly minimal core. Additional features are usually added by using another module alongside `tape`.
## pretty reporters
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:
- [tap-spec](https://github.com/scottcorgan/tap-spec)
- [tap-dot](https://github.com/scottcorgan/tap-dot)
- [faucet](https://github.com/substack/faucet)
- [tap-bail](https://github.com/juliangruber/tap-bail)
- [tap-browser-color](https://github.com/kirbysayshi/tap-browser-color)
- [tap-json](https://github.com/gummesson/tap-json)
- [tap-min](https://github.com/derhuerst/tap-min)
- [tap-nyan](https://github.com/calvinmetcalf/tap-nyan)
- [tap-pessimist](https://www.npmjs.org/package/tap-pessimist)
- [tap-prettify](https://github.com/toolness/tap-prettify)
- [colortape](https://github.com/shuhei/colortape)
- [tap-xunit](https://github.com/aghassemi/tap-xunit)
- [tap-difflet](https://github.com/namuol/tap-difflet)
- [tape-dom](https://github.com/gritzko/tape-dom)
- [tap-diff](https://github.com/axross/tap-diff)
- [tap-notify](https://github.com/axross/tap-notify)
- [tap-summary](https://github.com/zoubin/tap-summary)
- [tap-markdown](https://github.com/Hypercubed/tap-markdown)
- [tap-html](https://github.com/gabrielcsapo/tap-html)
- [tap-react-browser](https://github.com/mcnuttandrew/tap-react-browser)
- [tap-junit](https://github.com/dhershman1/tap-junit)
- [tap-nyc](https://github.com/MegaArman/tap-nyc)
- [tap-spec (emoji patch)](https://github.com/Sceat/tap-spec-emoji)
- [tape-repeater](https://github.com/rgruesbeck/tape-repeater)
- [tabe](https://github.com/Josenzo/tabe)
To use them, try `node test/index.js | tap-spec` or pipe it into one
of the modules of your choice!
## uncaught exceptions
By default, uncaught exceptions in your tests will not be intercepted, and will cause `tape` to crash. If you find this behavior undesirable, use [`tape-catch`](https://github.com/michaelrhodes/tape-catch) to report any exceptions as TAP errors.
## other
- CoffeeScript support with https://www.npmjs.com/package/coffeetape
- ES6 support with https://www.npmjs.com/package/babel-tape-runner or https://www.npmjs.com/package/buble-tape-runner
- Different test syntax with https://github.com/pguth/flip-tape (warning: mutates String.prototype)
- Electron test runner with https://github.com/tundrax/electron-tap
- Concurrency support with https://github.com/imsnif/mixed-tape
- In-process reporting with https://github.com/DavidAnson/tape-player
- Describe blocks with https://github.com/mattriley/tape-describe
# methods
The assertion methods in `tape` are heavily influenced or copied from the methods
in [node-tap](https://github.com/isaacs/node-tap).
```js
var test = require('tape')
```
## test([name], [opts], cb)
Create a new test with an optional `name` string and optional `opts` object.
`cb(t)` fires with the new test object `t` once all preceding tests have
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.todo = true/false. Test will be allowed to fail.
If you forget to `t.plan()` out how many assertions you are going to run and you don't call `t.end()` explicitly, or return a Promise that eventually settles, your test will hang.
If `cb` returns a Promise, it will be implicitly awaited. If that promise rejects, the test will be failed; if it fulfills, the test will end. Explicitly calling `t.end()` while also returning a Promise that fulfills is an error.
## test.skip([name], [opts], cb)
Generate a new test that will be skipped over.
## test.teardown(cb)
Register a callback to run after the individual test has completed. Multiple registered teardown callbacks will run in order. Useful for undoing side effects, closing network connections, etc.
## test.onFinish(fn)
The onFinish hook will get invoked when ALL `tape` tests have finished right before `tape` is about to print the test summary.
`fn` is called with no arguments, and its return value is ignored.
## test.onFailure(fn)
The onFailure hook will get invoked whenever any `tape` tests has failed.
`fn` is called with no arguments, and its return value is ignored.
## t.plan(n)
Declare that `n` assertions should be run. `t.end()` will be called
automatically after the `n`th assertion. If there are any more assertions after
the `n`th, or after `t.end()` is called, they will generate errors.
## t.end(err)
Declare the end of a test explicitly. If `err` is passed in `t.end` will assert that it is falsy.
Do not call `t.end()` if your test callback returns a Promise.
## t.fail(msg)
Generate a failing assertion with a message `msg`.
## t.pass(msg)
Generate a passing assertion with a message `msg`.
## t.timeoutAfter(ms)
Automatically timeout the test after X ms.
## t.skip(msg)
Generate an assertion that will be skipped over.
## t.ok(value, msg)
Assert that `value` is truthy with an optional description of the assertion `msg`.
Aliases: `t.true()`, `t.assert()`
## t.notOk(value, msg)
Assert that `value` is falsy with an optional description of the assertion `msg`.
Aliases: `t.false()`, `t.notok()`
## t.error(err, msg)
Assert that `err` is falsy. If `err` is non-falsy, use its `err.message` as the description message.
Aliases: `t.ifError()`, `t.ifErr()`, `t.iferror()`
## t.equal(actual, expected, msg)
Assert that `Object.is(actual, expected)` with an optional description of the assertion `msg`.
Aliases: `t.equals()`, `t.isEqual()`, `t.strictEqual()`, `t.strictEquals()`, `t.is()`
## t.notEqual(actual, expected, msg)
Assert that `!Object.is(actual, expected)` with an optional description of the assertion `msg`.
Aliases: `t.notEquals()`, `t.isNotEqual()`, `t.doesNotEqual()`, `t.isInequal()`, `t.notStrictEqual()`, `t.notStrictEquals()`, `t.isNot()`, `t.not()`
## t.looseEqual(actual, expected, msg)
Assert that `actual == expected` with an optional description of the assertion `msg`.
Aliases: `t.looseEquals()`
## t.notLooseEqual(actual, expected, msg)
Assert that `actual != expected` with an optional description of the assertion `msg`.
Aliases: `t.notLooseEquals()`
## t.deepEqual(actual, expected, msg)
Assert that `actual` and `expected` have the same structure and nested values using
[node's deepEqual() algorithm](https://github.com/substack/node-deep-equal)
with strict comparisons (`===`) on leaf nodes and an optional description of the assertion `msg`.
Aliases: `t.deepEquals()`, `t.isEquivalent()`, `t.same()`
## t.notDeepEqual(actual, expected, msg)
Assert that `actual` and `expected` do not have the same structure and nested values using
[node's deepEqual() algorithm](https://github.com/substack/node-deep-equal)
with strict comparisons (`===`) on leaf nodes and an optional description of the assertion `msg`.
Aliases: `t.notDeepEquals`, `t.notEquivalent()`, `t.notDeeply()`, `t.notSame()`,
`t.isNotDeepEqual()`, `t.isNotDeeply()`, `t.isNotEquivalent()`,
`t.isInequivalent()`
## t.deepLooseEqual(actual, expected, msg)
Assert that `actual` and `expected` have the same structure and nested values using
[node's deepEqual() algorithm](https://github.com/substack/node-deep-equal)
with loose comparisons (`==`) on leaf nodes and an optional description of the assertion `msg`.
## t.notDeepLooseEqual(actual, expected, msg)
Assert that `actual` and `expected` do not have the same structure and nested values using
[node's deepEqual() algorithm](https://github.com/substack/node-deep-equal)
with loose comparisons (`==`) on leaf nodes and an optional description of the assertion `msg`.
Aliases: `t.notLooseEqual()`, `t.notLooseEquals()`
## t.throws(fn, expected, msg)
Assert that the function call `fn()` throws an exception. `expected`, if present, must be a `RegExp`, `Function`, or `Object`. The `RegExp` matches the string representation of the exception, as generated by `err.toString()`. For example, if you set `expected` to `/user/`, the test will pass only if the string representation of the exception contains the word `user`. Any other exception will result in a failed test. The `Function` is the exception thrown (e.g. `Error`). `Object` in this case corresponds to a so-called validation object, in which each property is tested for strict deep equality. As an example, see the following two tests--each passes a validation object to `t.throws()` as the second parameter. The first test will pass, because all property values in the actual error object are deeply strictly equal to the property values in the validation object.
```
const err = new TypeError("Wrong value");
err.code = 404;
err.check = true;
// Passing test.
t.throws(
() => {
throw err;
},
{
code: 404,
check: true
},
"Test message."
);
```
This next test will fail, because all property values in the actual error object are _not_ deeply strictly equal to the property values in the validation object.
```
const err = new TypeError("Wrong value");
err.code = 404;
err.check = "true";
// Failing test.
t.throws(
() => {
throw err;
},
{
code: 404,
check: true // This is not deeply strictly equal to err.check.
},
"Test message."
);
```
This is very similar to how Node's `assert.throws()` method tests validation objects (please see the [Node _assert.throws()_ documentation](https://nodejs.org/api/assert.html#assert_assert_throws_fn_error_message) for more information).
If `expected` is not of type `RegExp`, `Function`, or `Object`, or omitted entirely, any exception will result in a passed test. `msg` is an optional description of the assertion.
Please note that the second parameter, `expected`, cannot be of type `string`. If a value of type `string` is provided for `expected`, then `t.throws(fn, expected, msg)` will execute, but the value of `expected` will be set to `undefined`, and the specified string will be set as the value for the `msg` parameter (regardless of what _actually_ passed as the third parameter). This can cause unexpected results, so please be mindful.
## t.doesNotThrow(fn, expected, msg)
Assert that the function call `fn()` does not throw an exception. `expected`, if present, limits what should not be thrown, and must be a `RegExp` or `Function`. The `RegExp` matches the string representation of the exception, as generated by `err.toString()`. For example, if you set `expected` to `/user/`, the test will fail only if the string representation of the exception contains the word `user`. Any other exception will result in a passed test. The `Function` is the exception thrown (e.g. `Error`). If `expected` is not of type `RegExp` or `Function`, or omitted entirely, any exception will result in a failed test. `msg` is an optional description of the assertion.
Please note that the second parameter, `expected`, cannot be of type `string`. If a value of type `string` is provided for `expected`, then `t.doesNotThrows(fn, expected, msg)` will execute, but the value of `expected` will be set to `undefined`, and the specified string will be set as the value for the `msg` parameter (regardless of what _actually_ passed as the third parameter). This can cause unexpected results, so please be mindful.
## t.test(name, [opts], cb)
Create a subtest with a new test handle `st` from `cb(st)` inside the current test `t`. `cb(st)` will only fire when `t` finishes. Additional tests queued up after `t` will not be run until all subtests finish.
You may pass the same options that [`test()`](#testname-opts-cb) accepts.
## t.comment(message)
Print a message without breaking the tap output. (Useful when using e.g. `tap-colorize` where output is buffered & `console.log` will print in incorrect order vis-a-vis tap output.)
Multiline output will be split by `\n` characters, and each one printed as a comment.
## t.match(string, regexp, message)
Assert that `string` matches the RegExp `regexp`. Will throw (not just fail) when the first two arguments are the wrong type.
## t.doesNotMatch(string, regexp, message)
Assert that `string` does not match the RegExp `regexp`. Will throw (not just fail) when the first two arguments are the wrong type.
## var htest = test.createHarness()
Create a new test harness instance, which is a function like `test()`, but with a new pending stack and test state.
By default the TAP output goes to `console.log()`. You can pipe the output to someplace else if you `htest.createStream().pipe()` to a destination stream on the first tick.
## test.only([name], [opts], cb)
Like `test([name], [opts], cb)` except if you use `.only` this is the only test case that will run for the entire process, all other test cases using `tape` will be ignored.
## var stream = test.createStream(opts)
Create a stream of output, bypassing the default output stream that writes messages to `console.log()`. By default `stream` will be a text stream of TAP output, but you can get an object stream instead by setting `opts.objectMode` to `true`.
### tap stream reporter
You can create your own custom test reporter using this `createStream()` api:
``` js
var test = require('tape');
var path = require('path');
test.createStream().pipe(process.stdout);
process.argv.slice(2).forEach(function (file) {
require(path.resolve(file));
});
```
You could substitute `process.stdout` for whatever other output stream you want, like a network connection or a file.
Pass in test files to run as arguments:
```sh
$ node tap.js test/x.js test/y.js
TAP version 13
# (anonymous)
not ok 1 should be strictly equal
---
operator: equal
expected: "boop"
actual: "beep"
...
# (anonymous)
ok 2 should be strictly equal
ok 3 (unnamed assert)
# wheee
ok 4 (unnamed assert)
1..4
# tests 4
# pass 3
# fail 1
```
### object stream reporter
Here's how you can render an object stream instead of TAP:
``` js
var test = require('tape');
var path = require('path');
test.createStream({ objectMode: true }).on('data', function (row) {
console.log(JSON.stringify(row))
});
process.argv.slice(2).forEach(function (file) {
require(path.resolve(file));
});
```
The output for this runner is:
```sh
$ node object.js test/x.js test/y.js
{"type":"test","name":"(anonymous)","id":0}
{"id":0,"ok":false,"name":"should be strictly equal","operator":"equal","actual":"beep","expected":"boop","error":{},"test":0,"type":"assert"}
{"type":"end","test":0}
{"type":"test","name":"(anonymous)","id":1}
{"id":0,"ok":true,"name":"should be strictly equal","operator":"equal","actual":2,"expected":2,"test":1,"type":"assert"}
{"id":1,"ok":true,"name":"(unnamed assert)","operator":"ok","actual":true,"expected":true,"test":1,"type":"assert"}
{"type":"end","test":1}
{"type":"test","name":"wheee","id":2}
{"id":0,"ok":true,"name":"(unnamed assert)","operator":"ok","actual":true,"expected":true,"test":2,"type":"assert"}
{"type":"end","test":2}
```
# install
With [npm](https://npmjs.org) do:
```sh
npm install tape --save-dev
```
# troubleshooting
Sometimes `t.end()` doesnt preserve the expected output ordering.
For instance the following:
```js
var test = require('tape');
test('first', function (t) {
setTimeout(function () {
t.ok(1, 'first test');
t.end();
}, 200);
t.test('second', function (t) {
t.ok(1, 'second test');
t.end();
});
});
test('third', function (t) {
setTimeout(function () {
t.ok(1, 'third test');
t.end();
}, 100);
});
```
will output:
```
ok 1 second test
ok 2 third test
ok 3 first test
```
because `second` and `third` assume `first` has ended before it actually does.
Use `t.plan()` instead to let other tests know they should wait:
```diff
var test = require('tape');
test('first', function (t) {
+ t.plan(2);
setTimeout(function () {
t.ok(1, 'first test');
- t.end();
}, 200);
t.test('second', function (t) {
t.ok(1, 'second test');
t.end();
});
});
test('third', function (t) {
setTimeout(function () {
t.ok(1, 'third test');
t.end();
}, 100);
});
```
# license
MIT

13
tests/node_modules/tape/test/add-subtest-async.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
'use strict';
var test = require('../');
test('parent', function (t) {
t.pass('parent');
setTimeout(function () {
t.test('child', function (st) {
st.pass('child');
st.end();
});
}, 100);
});

46
tests/node_modules/tape/test/anonymous-fn.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var stripFullStack = require('./common').stripFullStack;
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'));
tt.same(body, [
'TAP version 13',
'# wrapped test failure',
'not ok 1 fail',
' ---',
' operator: fail',
' at: <anonymous> ($TEST/anonymous-fn.js:$LINE:$COL)',
' stack: |-',
' Error: fail',
' [... stack stripped ...]',
' at $TEST/anonymous-fn.js:$LINE:$COL',
' at Test.<anonymous> ($TEST/anonymous-fn/test-wrapper.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
};
test.createStream().pipe(concat(tc));
test('wrapped test failure', testWrapper(function (t) {
t.fail('fail');
t.end();
}));
});

View File

@@ -0,0 +1,18 @@
'use strict';
// Example of wrapper function that would invoke tape
module.exports = function (testCase) {
return function (t) {
setUp();
testCase(t);
tearDown();
};
};
function setUp() {
// ... example ...
}
function tearDown() {
// ... example ...
}

63
tests/node_modules/tape/test/array.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
'use strict';
var falafel = require('falafel');
var tape = require('../');
var tap = require('tap');
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',
'# array',
'ok 1 should be deeply equivalent',
'ok 2 should be deeply equivalent',
'ok 3 should be deeply equivalent',
'ok 4 should be deeply equivalent',
'ok 5 should be deeply equivalent',
'',
'1..5',
'# tests 5',
'# pass 5',
'',
'# 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);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
}
);
});
});

291
tests/node_modules/tape/test/async-await.js generated vendored Normal file
View File

@@ -0,0 +1,291 @@
'use strict';
var tap = require('tap');
var stripFullStack = require('./common').stripFullStack;
var runProgram = require('./common').runProgram;
var nodeVersion = process.versions.node;
var majorVersion = nodeVersion.split('.')[0];
if (Number(majorVersion) < 8) {
process.exit(0);
}
tap.test('async1', function (t) {
runProgram('async-await', 'async1.js', function (r) {
t.same(r.stdout.toString('utf8'), [
'TAP version 13',
'# async1',
'ok 1 before await',
'ok 2 after await',
'',
'1..2',
'# tests 2',
'# pass 2',
'',
'# ok'
].join('\n') + '\n\n');
t.same(r.exitCode, 0);
t.same(r.stderr.toString('utf8'), '');
t.end();
});
});
tap.test('async2', function (t) {
runProgram('async-await', 'async2.js', function (r) {
var stdout = r.stdout.toString('utf8');
var lines = stdout.split('\n').filter(function (line) {
return !/^(\s+)at(\s+)<anonymous>$/.test(line);
});
t.same(stripFullStack(lines.join('\n')), [
'TAP version 13',
'# async2',
'ok 1 before await',
'not ok 2 after await',
' ---',
' operator: ok',
' expected: true',
' actual: false',
' at: Test.myTest ($TEST/async-await/async2.js:$LINE:$COL)',
' stack: |-',
' Error: after await',
' [... stack stripped ...]',
' at Test.myTest ($TEST/async-await/async2.js:$LINE:$COL)',
' ...',
'',
'1..2',
'# tests 2',
'# pass 1',
'# fail 1',
'',
''
]);
t.same(r.exitCode, 1);
t.same(r.stderr.toString('utf8'), '');
t.end();
});
});
tap.test('async3', function (t) {
runProgram('async-await', 'async3.js', function (r) {
t.same(r.stdout.toString('utf8'), [
'TAP version 13',
'# async3',
'ok 1 before await',
'ok 2 after await',
'',
'1..2',
'# tests 2',
'# pass 2',
'',
'# ok'
].join('\n') + '\n\n');
t.same(r.exitCode, 0);
t.same(r.stderr.toString('utf8'), '');
t.end();
});
});
tap.test('async4', function (t) {
runProgram('async-await', 'async4.js', function (r) {
t.same(stripFullStack(r.stdout.toString('utf8')), [
'TAP version 13',
'# async4',
'ok 1 before await',
'not ok 2 Error: oops',
' ---',
' operator: error',
' at: Test.myTest ($TEST/async-await/async4.js:$LINE:$COL)',
' stack: |-',
' Error: oops',
' at Timeout.myTimeout [as _onTimeout] ($TEST/async-await/async4.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..2',
'# tests 2',
'# pass 1',
'# fail 1',
'',
''
]);
t.same(r.exitCode, 1);
t.same(r.stderr.toString('utf8'), '');
t.end();
});
});
tap.test('async5', function (t) {
runProgram('async-await', 'async5.js', function (r) {
t.same(stripFullStack(r.stdout.toString('utf8')), [
'TAP version 13',
'# async5',
'ok 1 before server',
'ok 2 after server',
'ok 3 before request',
'ok 4 after request',
'ok 5 res.statusCode is 200',
'not ok 6 .end() already called: mockDb.state is new',
' ---',
' operator: fail',
' at: Timeout._onTimeout ($TEST/async-await/async5.js:$LINE:$COL)',
' stack: |-',
' Error: .end() already called: mockDb.state is new',
' [... stack stripped ...]',
' at Timeout._onTimeout ($TEST/async-await/async5.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 7 .end() already called: error on close',
' ---',
' operator: fail',
' at: Server.<anonymous> ($TEST/async-await/async5.js:$LINE:$COL)',
' stack: |-',
' Error: .end() already called: error on close',
' [... stack stripped ...]',
' at Server.<anonymous> ($TEST/async-await/async5.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 8 .end() already called',
' ---',
' operator: fail',
' at: Server.<anonymous> ($TEST/async-await/async5.js:$LINE:$COL)',
' stack: |-',
' Error: .end() already called',
' [... stack stripped ...]',
' at Server.<anonymous> ($TEST/async-await/async5.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..8',
'# tests 8',
'# pass 5',
'# fail 3',
'',
''
]);
t.same(r.exitCode, 1);
t.same(r.stderr.toString('utf8'), '');
t.end();
});
});
tap.test('sync-error', function (t) {
runProgram('async-await', 'sync-error.js', function (r) {
t.same(stripFullStack(r.stdout.toString('utf8')), [
'TAP version 13',
'# sync-error',
'ok 1 before throw',
''
]);
t.same(r.exitCode, 1);
var stderr = r.stderr.toString('utf8');
var lines = stderr.split('\n');
lines = lines.filter(function (line) {
return !/\(timers.js:/.test(line)
&& !/\(internal\/timers.js:/.test(line)
&& !/Immediate\.next/.test(line);
});
stderr = lines.join('\n');
t.same(stripFullStack(stderr), [
'$TEST/async-await/sync-error.js:7',
' throw new Error(\'oopsie\');',
' ^',
'',
'Error: oopsie',
' at Test.myTest ($TEST/async-await/sync-error.js:$LINE:$COL)',
' at Test.bound [as _cb] ($TAPE/lib/test.js:$LINE:$COL)',
' at Test.run ($TAPE/lib/test.js:$LINE:$COL)',
' at Test.bound [as run] ($TAPE/lib/test.js:$LINE:$COL)',
''
]);
t.end();
});
});
tap.test('async-error', function (t) {
runProgram('async-await', 'async-error.js', function (r) {
var stdout = r.stdout.toString('utf8');
var lines = stdout.split('\n');
lines = lines.filter(function (line) {
return !/^(\s+)at(\s+)<anonymous>$/.test(line);
});
stdout = lines.join('\n');
t.same(stripFullStack(stdout), [
'TAP version 13',
'# async-error',
'ok 1 before throw',
'not ok 2 Error: oopsie',
' ---',
' operator: error',
' stack: |-',
' Error: oopsie',
' at Test.myTest ($TEST/async-await/async-error.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..2',
'# tests 2',
'# pass 1',
'# fail 1',
'',
''
]);
t.same(r.exitCode, 1);
var stderr = r.stderr.toString('utf8');
var lines = stderr.split('\n');
lines = lines.filter(function (line) {
return !/\(timers.js:/.test(line)
&& !/\(internal\/timers.js:/.test(line)
&& !/Immediate\.next/.test(line);
});
stderr = lines.join('\n');
t.same(stderr, '');
t.end();
});
});
tap.test('async-bug', function (t) {
runProgram('async-await', 'async-bug.js', function (r) {
var stdout = r.stdout.toString('utf8');
var lines = stdout.split('\n');
lines = lines.filter(function (line) {
return !/^(\s+)at(\s+)<anonymous>$/.test(line);
});
stdout = lines.join('\n');
t.same(stripFullStack(stdout), [
'TAP version 13',
'# async-error',
'ok 1 before throw',
'ok 2 should be strictly equal',
'not ok 3 TypeError: Cannot read property \'length\' of null',
' ---',
' operator: error',
' stack: |-',
' TypeError: Cannot read property \'length\' of null',
' at myCode ($TEST/async-await/async-bug.js:$LINE:$COL)',
' at Test.myTest ($TEST/async-await/async-bug.js:$LINE:$COL)',
' ...',
'',
'1..3',
'# tests 3',
'# pass 2',
'# fail 1',
'',
''
]);
t.same(r.exitCode, 1);
var stderr = r.stderr.toString('utf8');
t.same(stderr, '');
t.end();
});
});

32
tests/node_modules/tape/test/async-await/async-bug.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
'use strict';
var test = require('../../');
function myCode(arr) {
let sum = 0;
// oops forgot to handle null
for (let i = 0; i < arr.length; i++) {
sum += arr[i];
}
return sum;
}
test('async-error', async function myTest(t) {
await sleep(100);
t.ok(true, 'before throw');
const sum = myCode([1, 2, 3]);
t.equal(sum, 6);
const sum2 = myCode(null);
t.equal(sum2, 0);
t.end();
});
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}

View File

@@ -0,0 +1,9 @@
'use strict';
var test = require('../../');
test('async-error', async function myTest(t) {
t.ok(true, 'before throw');
throw new Error('oopsie');
t.ok(true, 'after throw');
});

16
tests/node_modules/tape/test/async-await/async1.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
'use strict';
var test = require('../../');
test('async1', async function myTest(t) {
try {
t.ok(true, 'before await');
await new Promise((resolve) => {
setTimeout(resolve, 10);
});
t.ok(true, 'after await');
t.end();
} catch (err) {
t.ifError(err);
}
});

15
tests/node_modules/tape/test/async-await/async2.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
'use strict';
var test = require('../../');
test('async2', async function myTest(t) {
try {
t.ok(true, 'before await');
await new Promise((resolve) => {
setTimeout(resolve, 10);
});
t.ok(false, 'after await');
} catch (err) {
t.ifError(err);
}
});

11
tests/node_modules/tape/test/async-await/async3.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
'use strict';
var test = require('../../');
test('async3', async function myTest(t) {
t.ok(true, 'before await');
await new Promise((resolve) => {
setTimeout(resolve, 10);
});
t.ok(true, 'after await');
});

17
tests/node_modules/tape/test/async-await/async4.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
'use strict';
var test = require('../../');
test('async4', async function myTest(t) {
try {
t.ok(true, 'before await');
await new Promise((resolve, reject) => {
setTimeout(function myTimeout() {
reject(new Error('oops'));
}, 10);
});
t.ok(true, 'after await');
} catch (err) {
t.ifError(err);
}
});

59
tests/node_modules/tape/test/async-await/async5.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
'use strict';
var util = require('util');
var http = require('http');
var test = require('../../');
test('async5', async function myTest(t) {
try {
t.ok(true, 'before server');
var mockDb = { state: 'old' };
var server = http.createServer(function (req, res) {
res.end('OK');
// Pretend we write to the DB and it takes time.
setTimeout(function () {
mockDb.state = 'new';
}, 10);
});
await util.promisify(function (cb) {
server.listen(0, cb);
})();
t.ok(true, 'after server');
t.ok(true, 'before request');
var res = await util.promisify(function (cb) {
var req = http.request({
hostname: 'localhost',
port: server.address().port,
path: '/',
method: 'GET'
}, function (res) {
cb(null, res);
});
req.end();
})();
t.ok(true, 'after request');
res.resume();
t.equal(res.statusCode, 200, 'res.statusCode is 200');
setTimeout(function () {
t.equal(mockDb.state, 'new', 'mockDb.state is new');
server.close(function (err) {
t.ifError(err, 'error on close');
t.end();
});
}, 50);
} catch (err) {
t.ifError(err, 'error in catch');
t.end();
}
});

10
tests/node_modules/tape/test/async-await/sync-error.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
'use strict';
var test = require('../../');
test('sync-error', function myTest(t) {
t.ok(true, 'before throw');
throw new Error('oopsie');
t.ok(true, 'after throw');
t.end();
});

12
tests/node_modules/tape/test/bound.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
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();
});

11
tests/node_modules/tape/test/browser/asserts.js generated vendored Normal file
View File

@@ -0,0 +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]]);
});

56
tests/node_modules/tape/test/child_ordering.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
'use strict';
var test = require('../');
var childRan = false;
test('parent', function (t) {
t.test('child', function (t) {
childRan = true;
t.pass('child ran');
t.end();
});
t.end();
});
test('uncle', function (t) {
t.ok(childRan, 'Child should run before next top-level test');
t.end();
});
var grandParentRan = false;
var parentRan = false;
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');
parentRan = true;
t.test('grandchild', function (t) {
t.ok(!grandChildRan, 'grand child ran twice');
grandChildRan = true;
t.pass('grand child ran');
t.end();
});
t.pass('parent ran');
t.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.pass('grandparent ran');
t.end();
});
test('second grandparent', function (t) {
t.ok(grandParentRan, 'grandparent ran');
t.ok(parentRan, 'parent ran');
t.ok(grandChildRan, 'grandchild ran');
t.pass('other grandparent ran');
t.end();
});
// vim: set softtabstop=4 shiftwidth=4:

46
tests/node_modules/tape/test/circular-things.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var stripFullStack = require('./common').stripFullStack;
tap.test('circular test', function (assert) {
var test = tape.createHarness({ exit: false });
assert.plan(1);
test.createStream().pipe(concat(function (body) {
assert.deepEqual(stripFullStack(body.toString('utf8')), [
'TAP version 13',
'# circular',
'not ok 1 should be strictly equal',
' ---',
' operator: equal',
' expected: |-',
' {}',
' actual: |-',
' { circular: [Circular] }',
' at: Test.<anonymous> ($TEST/circular-things.js:$LINE:$COL)',
' stack: |-',
' Error: should be strictly equal',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/circular-things.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
}));
test('circular', function (t) {
t.plan(1);
var circular = {};
circular.circular = circular;
t.equal(circular, {});
});
});

192
tests/node_modules/tape/test/comment.js generated vendored Normal file
View File

@@ -0,0 +1,192 @@
'use strict';
var concat = require('concat-stream');
var tap = require('tap');
var tape = require('../');
// Exploratory test to ascertain proper output when no t.comment() call
// is made.
tap.test('no comment', function (assert) {
assert.plan(1);
var verify = function (output) {
assert.equal(output.toString('utf8'), [
'TAP version 13',
'# no comment',
'',
'1..0',
'# tests 0',
'# pass 0',
'',
'# ok',
''
].join('\n'));
};
var test = tape.createHarness();
test.createStream().pipe(concat(verify));
test('no comment', function (t) {
t.end();
});
});
// Exploratory test, can we call t.comment() passing nothing?
tap.test('missing argument', function (assert) {
assert.plan(1);
var test = tape.createHarness();
test.createStream();
test('missing argument', function (t) {
try {
t.comment();
t.end();
} catch (err) {
assert.equal(err.constructor, TypeError);
} finally {
assert.end();
}
});
});
// Exploratory test, can we call t.comment() passing nothing?
tap.test('null argument', function (assert) {
assert.plan(1);
var test = tape.createHarness();
test.createStream();
test('null argument', function (t) {
try {
t.comment(null);
t.end();
} catch (err) {
assert.equal(err.constructor, TypeError);
} finally {
assert.end();
}
});
});
// Exploratory test, how is whitespace treated?
tap.test('whitespace', function (assert) {
assert.plan(1);
var verify = function (output) {
assert.equal(output.toString('utf8'), [
'TAP version 13',
'# whitespace',
'# ',
'# a',
'# a',
'# a',
'',
'1..0',
'# tests 0',
'# pass 0',
'',
'# ok',
''
].join('\n'));
};
var test = tape.createHarness();
test.createStream().pipe(concat(verify));
test('whitespace', function (t) {
t.comment(' ');
t.comment(' a');
t.comment('a ');
t.comment(' a ');
t.end();
});
});
// Exploratory test, how about passing types other than strings?
tap.test('non-string types', function (assert) {
assert.plan(1);
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',
''
].join('\n'));
};
var test = tape.createHarness();
test.createStream().pipe(concat(verify));
test('non-string types', function (t) {
t.comment(true);
t.comment(false);
t.comment(42);
t.comment(6.66);
t.comment({});
t.comment({'answer': 42});
function ConstructorFunction() {}
t.comment(new ConstructorFunction());
t.comment(ConstructorFunction);
t.end();
});
});
tap.test('multiline string', function (assert) {
assert.plan(1);
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',
''
].join('\n'));
};
var test = tape.createHarness();
test.createStream().pipe(concat(verify));
test('multiline strings', function (t) {
t.comment([
'a',
'b'
].join('\n'));
t.comment([
'c',
'd'
].join('\r\n'));
t.end();
});
});
tap.test('comment with createStream/objectMode', function (assert) {
assert.plan(1);
var test = tape.createHarness();
test.createStream({ objectMode: true }).on('data', function (row) {
if (typeof row === 'string') {
assert.equal(row, 'comment message');
}
});
test('t.comment', function (t) {
t.comment('comment message');
t.end();
});
});

104
tests/node_modules/tape/test/common.js generated vendored Normal file
View File

@@ -0,0 +1,104 @@
'use strict';
var path = require('path');
var spawn = require('child_process').spawn;
var concat = require('concat-stream');
var yaml = require('js-yaml');
module.exports.getDiag = function (body) {
var yamlStart = body.indexOf(' ---');
var yamlEnd = body.indexOf(' ...\n');
var diag = body.slice(yamlStart, yamlEnd).split('\n').map(function (line) {
return line.slice(2);
}).join('\n');
// The stack trace and at variable will vary depending on where the code
// is run, so just strip it out.
var withStack = yaml.safeLoad(diag);
delete withStack.stack;
delete withStack.at;
return withStack;
};
// There are three challenges associated with checking the stack traces included
// in errors:
// 1) The base checkout directory of tape might change. Because stack traces
// include absolute paths, the stack traces will change depending on the
// checkout path. We handle this by replacing the base test directory with a
// placeholder $TEST variable and the package root with a placeholder
// $TAPE variable.
// 2) Line positions within the file might change. We handle this by replacing
// line and column markers with placeholder $LINE and $COL "variables"
// a) node 0.8 does not provide nested eval line numbers, so we remove them
// 3) Stacks themselves change frequently with refactoring. We've even run into
// issues with node library refactorings "breaking" stack traces. Most of
// these changes are irrelevant to the tests themselves. To counter this, we
// strip out all stack frames that aren't directly under our test directory,
// and replace them with placeholders.
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(/, <anonymous>:\$LINE:\$COL\)$/, ')');
return withoutNestedLineNumbers;
};
module.exports.stripFullStack = function (output) {
var stripped = ' [... stack stripped ...]';
var withDuplicates = output.split('\n').map(stripChangingData).map(function (line) {
var m = line.match(/[ ]{8}at .*\((.*)\)/);
if (m && m[1].slice(0, 5) !== '$TEST') {
return stripped;
}
return line;
});
var withoutInternals = withDuplicates.filter(function (line) {
return !line.match(/ \(node:[^)]+\)$/);
});
var deduped = withoutInternals.filter(function (line, ix) {
var hasPrior = line === stripped && withDuplicates[ix - 1] === stripped;
return !hasPrior;
});
return deduped.join('\n').replace(
// Handle stack trace variation in Node v0.8
/at(:?) Test\.(?:module\.exports|tap\.test\.err\.code)/g,
'at$1 Test.<anonymous>'
).replace(
// Handle stack trace variation in Node v0.8
/at(:?) (Test\.)?tap\.test\.test\.skip/g,
'at$1 $2<anonymous>'
).replace(
// Handle stack trace variation in Node v0.8
/(\[\.\.\. stack stripped \.\.\.\]\n *at) <anonymous> \(([^)]+)\)/g,
'$1 $2'
).split('\n');
};
module.exports.runProgram = function (folderName, fileName, cb) {
var result = {
stdout: null,
stderr: null,
exitCode: 0
};
var ps = spawn(process.execPath, [
path.join(__dirname, folderName, fileName)
]);
ps.stdout.pipe(concat(function (stdoutRows) {
result.stdout = stdoutRows;
}));
ps.stderr.pipe(concat(function (stderrRows) {
result.stderr = stderrRows;
}));
ps.on('exit', function (code) {
result.exitCode = code;
cb(result);
});
};

View File

@@ -0,0 +1,33 @@
'use strict';
var tape = require('../');
tape.test('createMultipleStreams', function (tt) {
tt.plan(2);
var th = tape.createHarness();
th.createStream();
th.createStream();
var testOneComplete = false;
th('test one', function (tht) {
tht.plan(1);
setTimeout( function () {
tht.pass();
testOneComplete = true;
}, 100);
});
th('test two', function (tht) {
tht.ok(testOneComplete, 'test 1 completed before test 2');
tht.end();
});
th.onFinish(function () {
tt.equal(th._results.count, 2, 'harness test ran');
tt.equal(th._results.fail, 0, "harness test didn't fail");
});
});

193
tests/node_modules/tape/test/deep-equal-failure.js generated vendored Normal file
View File

@@ -0,0 +1,193 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var tapParser = require('tap-parser');
var common = require('./common');
var getDiag = common.getDiag;
var stripFullStack = common.stripFullStack;
tap.test('deep equal failure', function (assert) {
var test = tape.createHarness({ exit: false });
var stream = test.createStream();
var parser = tapParser();
assert.plan(3);
stream.pipe(parser);
stream.pipe(concat(function (body) {
assert.deepEqual(stripFullStack(body.toString('utf8')), [
'TAP version 13',
'# deep equal',
'not ok 1 should be strictly equal',
' ---',
' operator: equal',
' expected: |-',
' { b: 2 }',
' actual: |-',
' { a: 1 }',
' at: Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)',
' stack: |-',
' Error: should be strictly equal',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
assert.deepEqual(getDiag(body), {
operator: 'equal',
expected: '{ b: 2 }',
actual: '{ a: 1 }'
});
}));
parser.once('assert', function (data) {
delete data.diag.stack;
delete data.diag.at;
assert.deepEqual(data, {
ok: false,
id: 1,
name: 'should be strictly equal',
diag: {
operator: 'equal',
expected: '{ b: 2 }',
actual: '{ a: 1 }'
}
});
});
test('deep equal', function (t) {
t.plan(1);
t.equal({a: 1}, {b: 2});
});
});
tap.test('deep equal failure, depth 6, with option', function (assert) {
var test = tape.createHarness({ exit: false });
var stream = test.createStream();
var parser = tapParser();
assert.plan(3);
stream.pipe(parser);
stream.pipe(concat(function (body) {
assert.deepEqual(stripFullStack(body.toString('utf8')), [
'TAP version 13',
'# deep equal',
'not ok 1 should be strictly equal',
' ---',
' operator: equal',
' expected: |-',
' { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }',
' actual: |-',
' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }',
' at: Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)',
' stack: |-',
' Error: should be strictly equal',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
assert.deepEqual(getDiag(body), {
operator: 'equal',
expected: '{ a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }'
});
}));
parser.once('assert', function (data) {
delete data.diag.stack;
delete data.diag.at;
assert.deepEqual(data, {
ok: false,
id: 1,
name: 'should be strictly equal',
diag: {
operator: 'equal',
expected: '{ a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }'
}
});
});
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 } } } } } });
});
});
tap.test('deep equal failure, depth 6, without option', function (assert) {
var test = tape.createHarness({ exit: false });
var stream = test.createStream();
var parser = tapParser();
assert.plan(3);
stream.pipe(parser);
stream.pipe(concat(function (body) {
assert.deepEqual(stripFullStack(body.toString('utf8')), [
'TAP version 13',
'# deep equal',
'not ok 1 should be strictly equal',
' ---',
' operator: equal',
' expected: |-',
' { a: { a1: { a2: { a3: { a4: [Object] } } } } }',
' actual: |-',
' { a: { a1: { a2: { a3: { a4: [Object] } } } } }',
' at: Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)',
' stack: |-',
' Error: should be strictly equal',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
assert.deepEqual(getDiag(body), {
operator: 'equal',
expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }'
});
}));
parser.once('assert', function (data) {
delete data.diag.stack;
delete data.diag.at;
assert.deepEqual(data, {
ok: false,
id: 1,
name: 'should be strictly equal',
diag: {
operator: 'equal',
expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }'
}
});
});
test('deep equal', function (t) {
t.plan(1);
t.equal({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } });
});
});

37
tests/node_modules/tape/test/deep.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
var test = require('../');
test('deep strict equal', function (t) {
t.notDeepEqual(
[ { a: '3' } ],
[ { a: 3 } ]
);
t.end();
});
test('deep loose equal', function (t) {
t.deepLooseEqual(
[ { a: '3' } ],
[ { a: 3 } ]
);
t.end();
});
test('requires 2 arguments', function (t) {
var err = /^TypeError: two arguments must be provided/;
t.throws(function () { t.deepEqual(); }, err, 'deepEqual: no args');
t.throws(function () { t.deepEqual(undefined); }, err, 'deepEqual: one arg');
t.throws(function () { t.deepLooseEqual(); }, err, 'deepLooseEqual: no args');
t.throws(function () { t.deepLooseEqual(undefined); }, err, 'deepLooseEqual: one arg');
t.throws(function () { t.notDeepEqual(); }, err, 'notDeepEqual: no args');
t.throws(function () { t.notDeepEqual(undefined); }, err, 'notDeepEqual: one arg');
t.throws(function () { t.notDeepLooseEqual(); }, err, 'notDeepLooseEqual: no args');
t.throws(function () { t.notDeepLooseEqual(undefined); }, err, 'notDeepLooseEqual: one arg');
t.throws(function () { t.equal(); }, err, 'equal: no args');
t.throws(function () { t.equal(undefined); }, err, 'equal: one arg');
t.throws(function () { t.notEqual(); }, err, 'notEqual: no args');
t.throws(function () { t.notEqual(undefined); }, err, 'notEqual: one arg');
t.end();
});

51
tests/node_modules/tape/test/default-messages.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
'use strict';
var tap = require('tap');
var path = require('path');
var spawn = require('child_process').spawn;
var concat = require('concat-stream');
var stripFullStack = require('./common').stripFullStack;
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(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# default messages',
'ok 1 should be truthy',
'ok 2 should be falsy',
'ok 3 should be strictly equal',
'ok 4 should not be strictly equal',
'ok 5 should be loosely equal',
'ok 6 should not be loosely equal',
'ok 7 should be strictly equal',
'ok 8 should not be strictly equal',
'ok 9 should be deeply equivalent',
'not ok 10 should not be deeply equivalent',
' ---',
' operator: notDeepEqual',
' expected: true',
' actual: true',
' at: Test.<anonymous> ($TEST/messages/defaults.js:$LINE:$COL)',
' stack: |-',
' Error: should not be deeply equivalent',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/messages/defaults.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok 11 should be loosely deeply equivalent',
'ok 12 should not be loosely deeply equivalent',
'',
'1..12',
'# tests 12',
'# pass 11',
'# fail 1',
'',
''
]);
}));
});

64
tests/node_modules/tape/test/double_end.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
'use strict';
var test = require('tap').test;
var path = require('path');
var concat = require('concat-stream');
var spawn = require('child_process').spawn;
var stripFullStack = require('./common').stripFullStack;
test(function (tt) {
tt.plan(2);
var ps = spawn(process.execPath, [path.join(__dirname, 'double_end', 'double.js')]);
ps.on('exit', function (code) {
tt.equal(code, 1);
});
ps.stdout.pipe(concat(function (body) {
// The implementation of node's timer library has changed over time. We
// need to reverse engineer the error we expect to see.
// 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(); };
var to = setTimeout(doEnd, 5000);
clearTimeout(to);
to._onTimeout = doEnd;
var stackExpected;
var atExpected;
try {
to._onTimeout();
}
catch (e) {
stackExpected = stripFullStack(e.stack)[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'));
tt.same(stripped, [
'TAP version 13',
'# double end',
'ok 1 should be strictly equal',
'not ok 2 .end() already called',
' ---',
' operator: fail',
' ' + atExpected,
' stack: |-',
' Error: .end() already called',
' [... stack stripped ...]',
' ' + stackExpected,
' [... stack stripped ...]',
' ...',
'',
'1..2',
'# tests 2',
'# pass 1',
'# fail 1',
'',
''
]);
}));
});

13
tests/node_modules/tape/test/double_end/double.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
'use strict';
var test = require('../../');
test('double end', function (t) {
function doEnd() {
t.end();
}
t.equal(1 + 1, 2);
t.end();
setTimeout(doEnd, 5);
});

289
tests/node_modules/tape/test/edge-cases.js generated vendored Normal file
View File

@@ -0,0 +1,289 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var stripFullStack = require('./common').stripFullStack;
tap.test('edge cases', function (tt) {
tt.plan(1);
var test = tape.createHarness();
test.createStream().pipe(concat(function (body) {
tt.same(stripFullStack(body.toString('utf8')), [
'TAP version 13',
'# zeroes',
'not ok 1 0 equal to -0',
' ---',
' operator: equal',
' expected: |-',
' -0',
' actual: |-',
' 0',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: 0 equal to -0',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 2 -0 equal to 0',
' ---',
' operator: equal',
' expected: |-',
' 0',
' actual: |-',
' -0',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: -0 equal to 0',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok 3 0 notEqual to -0',
'ok 4 -0 notEqual to 0',
'ok 5 0 looseEqual to -0',
'ok 6 -0 looseEqual to 0',
'not ok 7 0 notLooseEqual to -0',
' ---',
' operator: notLooseEqual',
' expected: |-',
' -0',
' actual: |-',
' 0',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: 0 notLooseEqual to -0',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 8 -0 notLooseEqual to 0',
' ---',
' operator: notLooseEqual',
' expected: |-',
' 0',
' actual: |-',
' -0',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: -0 notLooseEqual to 0',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 9 0 strictEqual to -0',
' ---',
' operator: equal',
' expected: |-',
' -0',
' actual: |-',
' 0',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: 0 strictEqual to -0',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 10 -0 strictEqual to 0',
' ---',
' operator: equal',
' expected: |-',
' 0',
' actual: |-',
' -0',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: -0 strictEqual to 0',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok 11 0 notStrictEqual to -0',
'ok 12 -0 notStrictEqual to 0',
'ok 13 0 deepLooseEqual to -0',
'ok 14 -0 deepLooseEqual to 0',
'not ok 15 0 notDeepLooseEqual to -0',
' ---',
' operator: notDeepLooseEqual',
' expected: |-',
' -0',
' actual: |-',
' 0',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: 0 notDeepLooseEqual to -0',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 16 -0 notDeepLooseEqual to 0',
' ---',
' operator: notDeepLooseEqual',
' expected: |-',
' 0',
' actual: |-',
' -0',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: -0 notDeepLooseEqual to 0',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 17 0 deepEqual to -0',
' ---',
' operator: deepEqual',
' expected: |-',
' -0',
' actual: |-',
' 0',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: 0 deepEqual to -0',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 18 -0 deepEqual to 0',
' ---',
' operator: deepEqual',
' expected: |-',
' 0',
' actual: |-',
' -0',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: -0 deepEqual to 0',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok 19 0 notDeepEqual to -0',
'ok 20 -0 notDeepEqual to 0',
'# NaNs',
'ok 21 NaN equal to NaN',
'not ok 22 NaN notEqual to NaN',
' ---',
' operator: notEqual',
' expected: NaN',
' actual: NaN',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: NaN notEqual to NaN',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 23 NaN looseEqual to NaN',
' ---',
' operator: looseEqual',
' expected: NaN',
' actual: NaN',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: NaN looseEqual to NaN',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok 24 NaN notLooseEqual to NaN',
'ok 25 NaN strictEqual to NaN',
'not ok 26 NaN notStrictEqual to NaN',
' ---',
' operator: notEqual',
' expected: NaN',
' actual: NaN',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: NaN notStrictEqual to NaN',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 27 NaN deepLooseEqual to NaN',
' ---',
' operator: deepLooseEqual',
' expected: NaN',
' actual: NaN',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: NaN deepLooseEqual to NaN',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok 28 NaN notDeepLooseEqual to NaN',
'ok 29 NaN deepEqual to NaN',
'not ok 30 NaN notDeepEqual to NaN',
' ---',
' operator: notDeepEqual',
' expected: NaN',
' actual: NaN',
' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' stack: |-',
' Error: NaN notDeepEqual to NaN',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..30',
'# tests 30',
'# pass 15',
'# fail 15',
''
]);
}));
test('zeroes', function (t) {
t.equal(0, -0, '0 equal to -0');
t.equal(-0, 0, '-0 equal to 0');
t.notEqual(0, -0, '0 notEqual to -0');
t.notEqual(-0, 0, '-0 notEqual to 0');
t.looseEqual(0, -0, '0 looseEqual to -0');
t.looseEqual(-0, 0, '-0 looseEqual to 0');
t.notLooseEqual(0, -0, '0 notLooseEqual to -0');
t.notLooseEqual(-0, 0, '-0 notLooseEqual to 0');
t.strictEqual(0, -0, '0 strictEqual to -0');
t.strictEqual(-0, 0, '-0 strictEqual to 0');
t.notStrictEqual(0, -0, '0 notStrictEqual to -0');
t.notStrictEqual(-0, 0, '-0 notStrictEqual to 0');
t.deepLooseEqual(0, -0, '0 deepLooseEqual to -0');
t.deepLooseEqual(-0, 0, '-0 deepLooseEqual to 0');
t.notDeepLooseEqual(0, -0, '0 notDeepLooseEqual to -0');
t.notDeepLooseEqual(-0, 0, '-0 notDeepLooseEqual to 0');
t.deepEqual(0, -0, '0 deepEqual to -0');
t.deepEqual(-0, 0, '-0 deepEqual to 0');
t.notDeepEqual(0, -0, '0 notDeepEqual to -0');
t.notDeepEqual(-0, 0, '-0 notDeepEqual to 0');
t.end();
});
test('NaNs', function (t) {
t.equal(NaN, NaN, 'NaN equal to NaN');
t.notEqual(NaN, NaN, 'NaN notEqual to NaN');
t.looseEqual(NaN, NaN, 'NaN looseEqual to NaN');
t.notLooseEqual(NaN, NaN, 'NaN notLooseEqual to NaN');
t.strictEqual(NaN, NaN, 'NaN strictEqual to NaN');
t.notStrictEqual(NaN, NaN, 'NaN notStrictEqual to NaN');
t.deepLooseEqual(NaN, NaN, 'NaN deepLooseEqual to NaN');
t.notDeepLooseEqual(NaN, NaN, 'NaN notDeepLooseEqual to NaN');
t.deepEqual(NaN, NaN, 'NaN deepEqual to NaN');
t.notDeepEqual(NaN, NaN, 'NaN notDeepEqual to NaN');
t.end();
});
});

90
tests/node_modules/tape/test/end-as-callback.js generated vendored Normal file
View File

@@ -0,0 +1,90 @@
'use strict';
var tap = require('tap');
var forEach = require('for-each');
var tape = require('../');
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 strictly equal',
'# do a task and write fail',
'ok 3 null',
'ok 4 should be strictly equal',
'not ok 5 Error: fail',
getStackTrace(rows), // tap error stack
'',
'1..5',
'# tests 5',
'# pass 4',
'# fail 1'
].join('\n') + '\n');
tt.end();
}));
test('do a task and write', function (assert) {
fakeAsyncTask('foo', function (err, value) {
assert.ifError(err);
assert.equal(value, 'taskfoo');
fakeAsyncWrite('bar', assert.end);
});
});
test('do a task and write fail', function (assert) {
fakeAsyncTask('bar', function (err, value) {
assert.ifError(err);
assert.equal(value, 'taskbar');
fakeAsyncWriteFail('baz', assert.end);
});
});
});
function fakeAsyncTask(name, cb) {
cb(null, 'task' + name);
}
function fakeAsyncWrite(name, cb) {
cb(null);
}
function fakeAsyncWriteFail(name, cb) {
cb(new Error('fail'));
}
/**
* extract the stack trace for the failed test.
* this will change dependent on the environment
* so no point hard-coding it in the test assertion
* see: https://git.io/v6hGG for example
* @param String rows - the tap output lines
* @returns String stacktrace - just the error stack part
*/
function getStackTrace(rows) {
var stacktrace = ' ---\n';
var extract = false;
forEach(rows.toString('utf8').split('\n'), function (row) {
if (!extract) {
if (row.indexOf('---') > -1) { // start of stack trace
extract = true;
}
} else {
if (row.indexOf('...') > -1) { // end of stack trace
extract = false;
stacktrace += ' ...';
} else {
stacktrace += row + '\n';
}
}
});
// console.log(stacktrace);
return stacktrace;
}

39
tests/node_modules/tape/test/error.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var stripFullStack = require('./common').stripFullStack;
tap.test('failures', function (tt) {
tt.plan(1);
var test = tape.createHarness();
test.createStream().pipe(concat(function (body) {
tt.same(stripFullStack(body.toString('utf8')), [
'TAP version 13',
'# error',
'not ok 1 Error: this is a message',
' ---',
' operator: error',
' at: Test.<anonymous> ($TEST/error.js:$LINE:$COL)',
' stack: |-',
' Error: this is a message',
' at Test.<anonymous> ($TEST/error.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
}));
test('error', function (t) {
t.plan(1);
t.error(new Error('this is a message'));
});
});

251
tests/node_modules/tape/test/exit.js generated vendored Normal file
View File

@@ -0,0 +1,251 @@
'use strict';
var tap = require('tap');
var path = require('path');
var spawn = require('child_process').spawn;
var concat = require('concat-stream');
var stripFullStack = require('./common').stripFullStack;
tap.test('exit ok', function (t) {
t.plan(2);
var tc = function (rows) {
t.same(rows.toString('utf8'), [
'TAP version 13',
'# array',
'# hi',
'ok 1 should be deeply equivalent',
'ok 2 should be deeply equivalent',
'ok 3 should be deeply equivalent',
'ok 4 should be deeply equivalent',
'ok 5 should be deeply equivalent',
'',
'1..5',
'# tests 5',
'# pass 5',
'',
'# ok',
'', // yes, these double-blank-lines at the end are required.
'' // if you can figure out how to remove them, please do!
].join('\n'));
};
var ps = spawn(process.execPath, [path.join(__dirname, 'exit', 'ok.js')]);
ps.stdout.pipe(concat(tc));
ps.on('exit', function (code) {
t.equal(code, 0);
});
});
tap.test('exit fail', function (t) {
t.plan(2);
var tc = function (rows) {
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# array',
'ok 1 should be deeply equivalent',
'ok 2 should be deeply equivalent',
'ok 3 should be deeply equivalent',
'ok 4 should be deeply equivalent',
'not ok 5 should be deeply equivalent',
' ---',
' operator: deepEqual',
' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]',
' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]',
' at: <anonymous> ($TEST/exit/fail.js:$LINE:$COL)',
' stack: |-',
' Error: should be deeply equivalent',
' [... stack stripped ...]',
' at $TEST/exit/fail.js:$LINE:$COL',
' at eval (eval at <anonymous> ($TEST/exit/fail.js:$LINE:$COL))',
' at eval (eval at <anonymous> ($TEST/exit/fail.js:$LINE:$COL))',
' at Test.<anonymous> ($TEST/exit/fail.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..5',
'# tests 5',
'# pass 4',
'# fail 1',
'',
''
]);
};
var ps = spawn(process.execPath, [path.join(__dirname, 'exit', 'fail.js')]);
ps.stdout.pipe(concat(tc));
ps.on('exit', function (code) {
t.notEqual(code, 0);
});
});
tap.test('too few exit', function (t) {
t.plan(2);
var tc = function (rows) {
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# array',
'ok 1 should be deeply equivalent',
'ok 2 should be deeply equivalent',
'ok 3 should be deeply equivalent',
'ok 4 should be deeply equivalent',
'ok 5 should be deeply equivalent',
'not ok 6 plan != count',
' ---',
' operator: fail',
' expected: 6',
' actual: 5',
' at: process.<anonymous> ($TAPE/index.js:$LINE:$COL)',
' stack: |-',
' Error: plan != count',
' [... stack stripped ...]',
' ...',
'',
'1..6',
'# tests 6',
'# pass 5',
'# fail 1',
'',
''
]);
};
var ps = spawn(process.execPath, [path.join(__dirname, '/exit/too_few.js')]);
ps.stdout.pipe(concat(tc));
ps.on('exit', function (code) {
t.notEqual(code, 0);
});
});
tap.test('more planned in a second test', function (t) {
t.plan(2);
var tc = function (rows) {
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# first',
'ok 1 should be truthy',
'# second',
'ok 2 should be truthy',
'not ok 3 plan != count',
' ---',
' operator: fail',
' expected: 2',
' actual: 1',
' at: process.<anonymous> ($TAPE/index.js:$LINE:$COL)',
' stack: |-',
' Error: plan != count',
' [... stack stripped ...]',
' ...',
'',
'1..3',
'# tests 3',
'# pass 2',
'# fail 1',
'',
''
]);
};
var ps = spawn(process.execPath, [path.join(__dirname, '/exit/second.js')]);
ps.stdout.pipe(concat(tc));
ps.on('exit', function (code) {
t.notEqual(code, 0);
});
});
tap.test('todo passing', function (t) {
t.plan(2);
var tc = function (rows) {
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# TODO todo pass',
'ok 1 should be truthy # TODO',
'',
'1..1',
'# tests 1',
'# pass 1',
'',
'# ok',
'',
''
]);
};
var ps = spawn(process.execPath, [path.join(__dirname, '/exit/todo.js')]);
ps.stdout.pipe(concat(tc));
ps.on('exit', function (code) {
t.equal(code, 0);
});
});
tap.test('todo failing', function (t) {
t.plan(2);
var tc = function (rows) {
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# TODO todo fail',
'not ok 1 should be truthy # TODO',
' ---',
' operator: ok',
' expected: true',
' actual: false',
' at: Test.<anonymous> ($TEST/exit/todo_fail.js:$LINE:$COL)',
' ...',
'',
'1..1',
'# tests 1',
'# pass 1',
'',
'# ok',
'',
''
]);
};
var ps = spawn(process.execPath, [path.join(__dirname, '/exit/todo_fail.js')]);
ps.stdout.pipe(concat(tc));
ps.on('exit', function (code) {
t.equal(code, 0);
});
});
tap.test('forgot to call t.end()', function (t) {
t.plan(2);
var tc = function (rows) {
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# first',
'ok 1 should be truthy',
'# oops forgot end',
'ok 2 should be truthy',
'not ok 3 test exited without ending: oops forgot end',
' ---',
' operator: fail',
' at: process.<anonymous> ($TAPE/index.js:$LINE:$COL)',
' stack: |-',
' Error: test exited without ending: oops forgot end',
' [... stack stripped ...]',
' ...',
'',
'1..3',
'# tests 3',
'# pass 2',
'# fail 1',
'',
''
]);
};
var ps = spawn(process.execPath, [path.join(__dirname, '/exit/missing_end.js')]);
ps.stdout.pipe(concat(tc));
ps.on('exit', function (code) {
t.notEqual(code, 0);
});
});

37
tests/node_modules/tape/test/exit/fail.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
var test = require('../../');
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);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]);
}
);
});

12
tests/node_modules/tape/test/exit/missing_end.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
var test = require('../../');
test('first', function (t) {
t.ok(true);
t.end();
});
test('oops forgot end', function (t) {
t.ok(true);
});

38
tests/node_modules/tape/test/exit/ok.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
'use strict';
var falafel = require('falafel');
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);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
}
);
});

13
tests/node_modules/tape/test/exit/second.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
'use strict';
var test = require('../../');
test('first', function (t) {
t.plan(1);
t.ok(true);
});
test('second', function (t) {
t.plan(2);
t.ok(true);
});

8
tests/node_modules/tape/test/exit/todo.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
'use strict';
var test = require('../../');
test('todo pass', { todo: true }, function (t) {
t.plan(1);
t.ok(true);
});

8
tests/node_modules/tape/test/exit/todo_fail.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
'use strict';
var test = require('../../');
test('todo fail', { todo: true }, function (t) {
t.plan(1);
t.ok(false);
});

37
tests/node_modules/tape/test/exit/too_few.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
var falafel = require('falafel');
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);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
}
);
});

14
tests/node_modules/tape/test/exposed-harness.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
'use strict';
var tape = require('../');
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(tape.getHarness()._results.pass, 0);
assert.end();
});

80
tests/node_modules/tape/test/fail.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
'use strict';
var falafel = require('falafel');
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
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')), [
'TAP version 13',
'# array',
'ok 1 should be deeply equivalent',
'ok 2 should be deeply equivalent',
'ok 3 should be deeply equivalent',
'ok 4 should be deeply equivalent',
'not ok 5 should be deeply equivalent',
' ---',
' operator: deepEqual',
' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]',
' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]',
' at: <anonymous> ($TEST/fail.js:$LINE:$COL)',
' stack: |-',
' Error: should be deeply equivalent',
' [... stack stripped ...]',
' at $TEST/fail.js:$LINE:$COL',
' at eval (eval at <anonymous> ($TEST/fail.js:$LINE:$COL))',
' at eval (eval at <anonymous> ($TEST/fail.js:$LINE:$COL))',
' at Test.<anonymous> ($TEST/fail.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..5',
'# tests 5',
'# pass 4',
'# fail 1',
''
]);
};
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);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]);
}
);
});
});

42
tests/node_modules/tape/test/has spaces.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
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')), [
'TAP version 13',
'# fail',
'not ok 1 this should fail',
' ---',
' operator: fail',
' at: Test.<anonymous> ($TEST/has spaces.js:$LINE:$COL)',
' stack: |-',
' Error: this should fail',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/has spaces.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
};
test.createStream().pipe(concat(tc));
test('fail', function (t) {
t.fail('this should fail');
t.end();
});
});

1
tests/node_modules/tape/test/ignore/.ignore generated vendored Normal file
View File

@@ -0,0 +1 @@
fake_node_modules

View File

@@ -0,0 +1,8 @@
'use strict';
var tape = require('../../../');
tape.test(function (t) {
t.plan(1);
t.fail('Should not print');
});

View File

@@ -0,0 +1,8 @@
'use strict';
var tape = require('../../../');
tape.test(function (t) {
t.fail('Should not print');
t.end();
});

8
tests/node_modules/tape/test/ignore/test.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
'use strict';
var tape = require('../../');
tape.test(function (t) {
t.plan(1);
t.ok('Okay');
});

8
tests/node_modules/tape/test/ignore/test/stub1.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
'use strict';
var tape = require('../../../');
tape.test(function (t) {
t.plan(1);
t.pass('test/stub1');
});

8
tests/node_modules/tape/test/ignore/test/stub2.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
'use strict';
var tape = require('../../../');
tape.test(function (t) {
t.pass('test/stub2');
t.end();
});

View File

@@ -0,0 +1,8 @@
'use strict';
var tape = require('../../../../');
tape.test(function (t) {
t.plan(1);
t.pass('test/sub/stub1');
});

View File

@@ -0,0 +1,8 @@
'use strict';
var tape = require('../../../../');
tape.test(function (t) {
t.pass('test/sub/stub2');
t.end();
});

8
tests/node_modules/tape/test/ignore/test2.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
'use strict';
var tape = require('../../');
tape.test(function (t) {
t.pass('Should print');
t.end();
});

122
tests/node_modules/tape/test/ignore_from_gitignore.js generated vendored Normal file
View File

@@ -0,0 +1,122 @@
'use strict';
var tap = require('tap');
var path = require('path');
var spawn = require('child_process').spawn;
var concat = require('concat-stream');
var stripFullStack = require('./common').stripFullStack;
var tapeBin = path.join(process.cwd(), 'bin/tape');
tap.test('Should pass with ignoring', { skip: process.platform === 'win32' }, function (tt) {
tt.plan(2);
var tc = function (rows) {
tt.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# (anonymous)',
'ok 1 should be truthy',
'# (anonymous)',
'ok 2 test/stub1',
'# (anonymous)',
'ok 3 test/stub2',
'# (anonymous)',
'ok 4 test/sub/stub1',
'# (anonymous)',
'ok 5 test/sub/stub2',
'# (anonymous)',
'ok 6 Should print',
'',
'1..6',
'# tests 6',
'# pass 6',
'',
'# ok',
'',
''
]);
};
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
});
});
tap.test('Should pass', { skip: process.platform === 'win32' }, function (tt) {
tt.plan(2);
var tc = function (rows) {
tt.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# (anonymous)',
'not ok 1 Should not print',
' ---',
' operator: fail',
' at: Test.<anonymous> ($TEST/ignore/fake_node_modules/stub1.js:$LINE:$COL)',
' stack: |-',
' Error: Should not print',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/ignore/fake_node_modules/stub1.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'# (anonymous)',
'not ok 2 Should not print',
' ---',
' operator: fail',
' at: Test.<anonymous> ($TEST/ignore/fake_node_modules/stub2.js:$LINE:$COL)',
' stack: |-',
' Error: Should not print',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/ignore/fake_node_modules/stub2.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'# (anonymous)',
'ok 3 should be truthy',
'# (anonymous)',
'ok 4 test/stub1',
'# (anonymous)',
'ok 5 test/stub2',
'# (anonymous)',
'ok 6 test/sub/stub1',
'# (anonymous)',
'ok 7 test/sub/stub2',
'# (anonymous)',
'ok 8 Should print',
'',
'1..8',
'# tests 8',
'# pass 6',
'# fail 2',
'',
''
]);
};
var ps = spawn(tapeBin, ['**/*.js'], {cwd: path.join(__dirname, 'ignore')});
ps.stdout.pipe(concat(tc));
ps.on('exit', function (code) {
tt.equal(code, 1);
});
});
tap.test('Should fail when ignore file does not exist', { skip: process.platform === 'win32' }, function (tt) {
tt.plan(3);
var testStdout = function (rows) {
tt.same(rows.toString('utf8'), '');
};
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')));
};
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) {
tt.equal(code, 2);
});
});

10
tests/node_modules/tape/test/many.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
'use strict';
var test = require('../');
test('many tests', function (t) {
t.plan(100);
for (var i = 0; i < 100; i++) {
setTimeout(function () { t.pass(); }, Math.random() * 50);
}
});

173
tests/node_modules/tape/test/match.js generated vendored Normal file
View File

@@ -0,0 +1,173 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var stripFullStack = require('./common').stripFullStack;
tap.test('match', function (tt) {
tt.plan(1);
var test = tape.createHarness({ exit: false });
var tc = function (rows) {
tt.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# match',
'ok 1 regex arg must be a regex',
'ok 2 string arg must be a string',
'not ok 3 The input did not match the regular expression /abc/. Input: \'string\'',
' ---',
' operator: match',
' expected: /abc/',
' actual: \'string\'',
' at: Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' stack: |-',
' Error: The input did not match the regular expression /abc/. Input: \'string\'',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 4 "string" does not match /abc/',
' ---',
' operator: match',
' expected: /abc/',
' actual: \'string\'',
' at: Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' stack: |-',
' Error: "string" does not match /abc/',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok 5 The input matched the regular expression /pass$/. Input: \'I will pass\'',
'ok 6 "I will pass" matches /pass$/',
'',
'1..6',
'# tests 6',
'# pass 4',
'# fail 2',
''
]);
};
test.createStream().pipe(concat(tc));
test('match', function (t) {
t.plan(6);
t.throws(
function () { t.match(/abc/, 'string'); },
TypeError,
'regex arg must be a regex'
);
t.throws(
function () { t.match({ abc: 123 }, /abc/); },
TypeError,
'string arg must be a string'
);
t.match('string', /abc/);
t.match('string', /abc/, '"string" does not match /abc/');
t.match('I will pass', /pass$/);
t.match('I will pass', /pass$/, '"I will pass" matches /pass$/');
t.end();
});
});
tap.test('doesNotMatch', function (tt) {
tt.plan(1);
var test = tape.createHarness({ exit: false });
var tc = function (rows) {
tt.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# doesNotMatch',
'ok 1 regex arg must be a regex',
'ok 2 string arg must be a string',
'not ok 3 The input was expected to not match the regular expression /string/. Input: \'string\'',
' ---',
' operator: doesNotMatch',
' expected: /string/',
' actual: \'string\'',
' at: Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' stack: |-',
' Error: The input was expected to not match the regular expression /string/. Input: \'string\'',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 4 "string" should not match /string/',
' ---',
' operator: doesNotMatch',
' expected: /string/',
' actual: \'string\'',
' at: Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' stack: |-',
' Error: "string" should not match /string/',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 5 The input was expected to not match the regular expression /pass$/. Input: \'I will pass\'',
' ---',
' operator: doesNotMatch',
' expected: /pass$/',
' actual: \'I will pass\'',
' at: Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' stack: |-',
' Error: The input was expected to not match the regular expression /pass$/. Input: \'I will pass\'',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 6 "I will pass" should not match /pass$/',
' ---',
' operator: doesNotMatch',
' expected: /pass$/',
' actual: \'I will pass\'',
' at: Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' stack: |-',
' Error: "I will pass" should not match /pass$/',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/match.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..6',
'# tests 6',
'# pass 2',
'# fail 4',
''
]);
};
test.createStream().pipe(concat(tc));
test('doesNotMatch', function (t) {
t.plan(6);
t.throws(
function () { t.doesNotMatch(/abc/, 'string'); },
TypeError,
'regex arg must be a regex'
);
t.throws(
function () { t.doesNotMatch({ abc: 123 }, /abc/); },
TypeError,
'string arg must be a string'
);
t.doesNotMatch('string', /string/);
t.doesNotMatch('string', /string/, '"string" should not match /string/');
t.doesNotMatch('I will pass', /pass$/);
t.doesNotMatch('I will pass', /pass$/, '"I will pass" should not match /pass$/');
t.end();
});
});

12
tests/node_modules/tape/test/max_listeners.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
var spawn = require('child_process').spawn;
var path = require('path');
var ps = spawn(process.execPath, [path.join(__dirname, 'max_listeners', 'source.js')]);
ps.stdout.pipe(process.stdout, { end: false });
ps.stderr.on('data', function (buf) {
console.log('not ok ' + buf);
});

7
tests/node_modules/tape/test/max_listeners/source.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
'use strict';
var test = require('../../');
for (var i = 0; i < 11; i++) {
test(function (t) { t.ok(true, 'true is truthy'); t.end(); });
}

25
tests/node_modules/tape/test/messages/defaults.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
'use strict';
var test = require('../../');
test('default messages', function (t) {
t.plan(12);
t.ok(true);
t.notOk(false);
t.equal(true, true);
t.notEqual(true, false);
t.looseEqual(true, true);
t.notLooseEqual(true, false);
t.strictEqual(true, true);
t.notStrictEqual(true, false);
t.deepEqual(true, true);
t.notDeepEqual(true, true);
t.deepLooseEqual(true, true);
t.notDeepLooseEqual(true, false);
});

View File

@@ -0,0 +1,38 @@
'use strict';
var test = require('../');
test('Harness async test support', function (t) {
t.plan(3);
t.ok(true, 'sync child A');
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 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);
});
});
}, 200);
});

View File

@@ -0,0 +1,45 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
tap.test('nested sync test without plan or end', function (tt) {
tt.plan(1);
var test = tape.createHarness();
var tc = function (rows) {
tt.same(rows.toString('utf8'), [
'TAP version 13',
'# nested without plan or end',
'# first',
'ok 1 should be truthy',
'# second',
'ok 2 should be truthy',
'',
'1..2',
'# tests 2',
'# pass 2',
'',
'# ok'
].join('\n') + '\n');
};
test.createStream().pipe(concat(tc));
test('nested without plan or end', function (t) {
t.test('first', function (q) {
setTimeout(function first() {
q.ok(true);
q.end();
}, 10);
});
t.test('second', function (q) {
setTimeout(function second() {
q.ok(true);
q.end();
}, 10);
});
});
});

85
tests/node_modules/tape/test/nested.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
'use strict';
var falafel = require('falafel');
var tape = require('../');
var tap = require('tap');
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'), [
'TAP version 13',
'# nested array test',
'ok 1 should be deeply equivalent',
'ok 2 should be deeply equivalent',
'ok 3 should be deeply equivalent',
'ok 4 should be deeply equivalent',
'ok 5 should be deeply equivalent',
'# inside test',
'ok 6 should be truthy',
'ok 7 should be truthy',
'# another',
'ok 8 should be truthy',
'',
'1..8',
'# tests 8',
'# pass 8',
'',
'# 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);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
}
);
});
test('another', function (t) {
t.plan(1);
setTimeout(function () {
t.ok(true);
}, 50);
});
});

21
tests/node_modules/tape/test/nested2.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
'use strict';
var test = require('../');
test(function (t) {
var i = 0;
t.test('setup', function (t) {
process.nextTick(function () {
t.equal(i, 0, 'called once');
i++;
t.end();
});
});
t.test('teardown', function (t) {
t.end();
});
t.end();
});

49
tests/node_modules/tape/test/no_callback.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var stripFullStack = require('./common').stripFullStack;
tap.test('no callback', function (tt) {
tt.plan(1);
var test = tape.createHarness();
var tc = function (rows) {
var body = stripFullStack(rows.toString('utf8'));
tt.same(body, [
'TAP version 13',
'# group',
'# No callback.',
'not ok 1 # TODO No callback.',
' ---',
' operator: fail',
' stack: |-',
' Error: # TODO No callback.',
' [... stack stripped ...]',
' ...',
'# SKIP No callback, skipped.',
'# TODO No callback, todo.',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
};
test.createStream().pipe(concat(tc));
test('group', function (t) {
t.plan(3);
t.test('No callback.');
t.test('No callback, skipped.', { skip: true });
t.test('No callback, todo.', { todo: true });
});
});

193
tests/node_modules/tape/test/not-deep-equal-failure.js generated vendored Normal file
View File

@@ -0,0 +1,193 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var tapParser = require('tap-parser');
var common = require('./common');
var getDiag = common.getDiag;
var stripFullStack = common.stripFullStack;
tap.test('deep equal failure', function (assert) {
var test = tape.createHarness({ exit: false });
var stream = test.createStream();
var parser = tapParser();
assert.plan(3);
stream.pipe(parser);
stream.pipe(concat(function (body) {
assert.deepEqual(stripFullStack(body.toString('utf8')), [
'TAP version 13',
'# not deep equal',
'not ok 1 should not be deeply equivalent',
' ---',
' operator: notDeepEqual',
' expected: |-',
' { b: 2 }',
' actual: |-',
' { b: 2 }',
' at: Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)',
' stack: |-',
' Error: should not be deeply equivalent',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
assert.deepEqual(getDiag(body), {
operator: 'notDeepEqual',
expected: '{ b: 2 }',
actual: '{ b: 2 }'
});
}));
parser.once('assert', function (data) {
delete data.diag.stack;
delete data.diag.at;
assert.deepEqual(data, {
ok: false,
id: 1,
name: 'should not be deeply equivalent',
diag: {
operator: 'notDeepEqual',
expected: '{ b: 2 }',
actual: '{ b: 2 }'
}
});
});
test('not deep equal', function (t) {
t.plan(1);
t.notDeepEqual({b: 2}, {b: 2});
});
});
tap.test('not deep equal failure, depth 6, with option', function (assert) {
var test = tape.createHarness({ exit: false });
var stream = test.createStream();
var parser = tapParser();
assert.plan(3);
stream.pipe(parser);
stream.pipe(concat(function (body) {
assert.deepEqual(stripFullStack(body.toString('utf8')), [
'TAP version 13',
'# not deep equal',
'not ok 1 should not be deeply equivalent',
' ---',
' operator: notDeepEqual',
' expected: |-',
' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }',
' actual: |-',
' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }',
' at: Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)',
' stack: |-',
' Error: should not be deeply equivalent',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
assert.deepEqual(getDiag(body), {
operator: 'notDeepEqual',
expected: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }'
});
}));
parser.once('assert', function (data) {
delete data.diag.stack;
delete data.diag.at;
assert.deepEqual(data, {
ok: false,
id: 1,
name: 'should not be deeply equivalent',
diag: {
operator: 'notDeepEqual',
expected: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }'
}
});
});
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 } } } } } });
});
});
tap.test('not deep equal failure, depth 6, without option', function (assert) {
var test = tape.createHarness({ exit: false });
var stream = test.createStream();
var parser = tapParser();
assert.plan(3);
stream.pipe(parser);
stream.pipe(concat(function (body) {
assert.deepEqual(stripFullStack(body.toString('utf8')), [
'TAP version 13',
'# not deep equal',
'not ok 1 should not be deeply equivalent',
' ---',
' operator: notDeepEqual',
' expected: |-',
' { a: { a1: { a2: { a3: { a4: [Object] } } } } }',
' actual: |-',
' { a: { a1: { a2: { a3: { a4: [Object] } } } } }',
' at: Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)',
' stack: |-',
' Error: should not be deeply equivalent',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
assert.deepEqual(getDiag(body), {
operator: 'notDeepEqual',
expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }'
});
}));
parser.once('assert', function (data) {
delete data.diag.stack;
delete data.diag.at;
assert.deepEqual(data, {
ok: false,
id: 1,
name: 'should not be deeply equivalent',
diag: {
operator: 'notDeepEqual',
expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }'
}
});
});
test('not deep equal', function (t) {
t.plan(1);
t.notDeepEqual({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } });
});
});

69
tests/node_modules/tape/test/not-equal-failure.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var tapParser = require('tap-parser');
var common = require('./common');
var getDiag = common.getDiag;
var stripFullStack = common.stripFullStack;
tap.test('not equal failure', function (assert) {
var test = tape.createHarness({ exit: false });
var stream = test.createStream();
var parser = tapParser();
assert.plan(3);
stream.pipe(parser);
stream.pipe(concat(function (body) {
assert.deepEqual(stripFullStack(body.toString('utf8')), [
'TAP version 13',
'# not equal',
'not ok 1 should not be strictly equal',
' ---',
' operator: notEqual',
' expected: 2',
' actual: 2',
' at: Test.<anonymous> ($TEST/not-equal-failure.js:$LINE:$COL)',
' stack: |-',
' Error: should not be strictly equal',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/not-equal-failure.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
''
]);
assert.deepEqual(getDiag(body), {
operator: 'notEqual',
expected: '2',
actual: '2'
});
}));
parser.once('assert', function (data) {
delete data.diag.stack;
delete data.diag.at;
assert.deepEqual(data, {
ok: false,
id: 1,
name: 'should not be strictly equal',
diag: {
operator: 'notEqual',
expected: '2',
actual: '2'
}
});
});
test('not equal', function (t) {
t.plan(1);
t.notEqual(2, 2);
});
});

184
tests/node_modules/tape/test/numerics.js generated vendored Normal file
View File

@@ -0,0 +1,184 @@
'use strict';
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var stripFullStack = require('./common').stripFullStack;
tap.test('numerics', function (tt) {
tt.plan(1);
var test = tape.createHarness();
test.createStream().pipe(concat(function (body) {
tt.same(stripFullStack(body.toString('utf8')), [
'TAP version 13',
'# numeric strings',
'not ok 1 number equal to string',
' ---',
' operator: equal',
' expected: \'3\'',
' actual: 3',
' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' stack: |-',
' Error: number equal to string',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 2 string equal to number',
' ---',
' operator: equal',
' expected: 3',
' actual: \'3\'',
' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' stack: |-',
' Error: string equal to number',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok 3 number notEqual to string',
'ok 4 string notEqual to number',
'ok 5 number looseEqual to string',
'ok 6 string looseEqual to number',
'not ok 7 number notLooseEqual to string',
' ---',
' operator: notLooseEqual',
' expected: \'3\'',
' actual: 3',
' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' stack: |-',
' Error: number notLooseEqual to string',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 8 string notLooseEqual to number',
' ---',
' operator: notLooseEqual',
' expected: 3',
' actual: \'3\'',
' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' stack: |-',
' Error: string notLooseEqual to number',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 9 number strictEqual to string',
' ---',
' operator: equal',
' expected: \'3\'',
' actual: 3',
' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' stack: |-',
' Error: number strictEqual to string',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 10 string strictEqual to number',
' ---',
' operator: equal',
' expected: 3',
' actual: \'3\'',
' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' stack: |-',
' Error: string strictEqual to number',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok 11 number notStrictEqual to string',
'ok 12 string notStrictEqual to number',
'ok 13 number deepLooseEqual to string',
'ok 14 string deepLooseEqual to number',
'not ok 15 number notDeepLooseEqual to string',
' ---',
' operator: notDeepLooseEqual',
' expected: \'3\'',
' actual: 3',
' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' stack: |-',
' Error: number notDeepLooseEqual to string',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 16 string notDeepLooseEqual to number',
' ---',
' operator: notDeepLooseEqual',
' expected: 3',
' actual: \'3\'',
' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' stack: |-',
' Error: string notDeepLooseEqual to number',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 17 number deepEqual to string',
' ---',
' operator: deepEqual',
' expected: \'3\'',
' actual: 3',
' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' stack: |-',
' Error: number deepEqual to string',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'not ok 18 string deepEqual to number',
' ---',
' operator: deepEqual',
' expected: 3',
' actual: \'3\'',
' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' stack: |-',
' Error: string deepEqual to number',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok 19 number notDeepEqual to string',
'ok 20 string notDeepEqual to number',
'',
'1..20',
'# tests 20',
'# pass 10',
'# fail 10',
''
]);
}));
test('numeric strings', function (t) {
t.equal(3, '3', 'number equal to string');
t.equal('3', 3, 'string equal to number');
t.notEqual(3, '3', 'number notEqual to string');
t.notEqual('3', 3, 'string notEqual to number');
t.looseEqual(3, '3', 'number looseEqual to string');
t.looseEqual('3', 3, 'string looseEqual to number');
t.notLooseEqual(3, '3', 'number notLooseEqual to string');
t.notLooseEqual('3', 3, 'string notLooseEqual to number');
t.strictEqual(3, '3', 'number strictEqual to string');
t.strictEqual('3', 3, 'string strictEqual to number');
t.notStrictEqual(3, '3', 'number notStrictEqual to string');
t.notStrictEqual('3', 3, 'string notStrictEqual to number');
t.deepLooseEqual(3, '3', 'number deepLooseEqual to string');
t.deepLooseEqual('3', 3, 'string deepLooseEqual to number');
t.notDeepLooseEqual(3, '3', 'number notDeepLooseEqual to string');
t.notDeepLooseEqual('3', 3, 'string notDeepLooseEqual to number');
t.deepEqual(3, '3', 'number deepEqual to string');
t.deepEqual('3', 3, 'string deepEqual to number');
t.notDeepEqual(3, '3', 'number notDeepEqual to string');
t.notDeepEqual('3', 3, 'string notDeepEqual to number');
t.end();
});
});

71
tests/node_modules/tape/test/objectMode.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
'use strict';
var tap = require('tap');
var tape = require('../');
var forEach = require('for-each');
var through = require('through');
tap.test('object results', function (assert) {
var printer = through({ objectMode: true });
var objects = [];
printer.write = function (obj) {
objects.push(obj);
};
printer.end = function (obj) {
if (obj) objects.push(obj);
var todos = 0;
var skips = 0;
var testIds = [];
var endIds = [];
var asserts = 0;
assert.equal(objects.length, 13);
forEach(objects, function (obj) {
if (obj.type === 'assert') {
asserts++;
} else if (obj.type === 'test') {
testIds.push(obj.id);
if (obj.skip) {
skips++;
} else if (obj.todo) {
todos++;
}
} else if (obj.type === 'end') {
endIds.push(obj.text);
// test object should exist
assert.notEqual(testIds.indexOf(obj.test), -1);
}
});
assert.equal(asserts, 5);
assert.equal(skips, 1);
assert.equal(todos, 2);
assert.equal(testIds.length, endIds.length);
assert.end();
};
tape.createStream({ objectMode: true }).pipe(printer);
tape('parent', function (t1) {
t1.equal(true, true);
t1.test('child1', {skip: true}, function (t2) {
t2.equal(true, true);
t2.equal(true, false);
t2.end();
});
t1.test('child2', {todo: true}, function (t3) {
t3.equal(true, false);
t3.equal(true, true);
t3.end();
});
t1.test('child3', {todo: true});
t1.equal(true, true);
t1.equal(true, true);
t1.end();
});
});

41
tests/node_modules/tape/test/objectModeWithComment.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
'use strict';
var tap = require('tap');
var tape = require('../');
var through = require('through');
tap.test('test.comment() in objectMode', function (assert) {
var printer = through({ objectMode: true });
var objects = [];
printer.on('error', function (e) {
assert.fail(e);
});
printer.write = function (obj) {
objects.push(obj);
};
printer.end = function (obj) {
if (obj) { objects.push(obj); }
assert.equal(objects.length, 3);
assert.deepEqual(objects, [
{
type: 'test',
name: 'test.comment',
id: 0,
skip: false,
todo: false
},
'message',
{ type: 'end', test: 0 }
]);
assert.end();
};
tape.createStream({ objectMode: true }).pipe(printer);
tape('test.comment', function (test) {
test.comment('message');
test.end();
});
});

23
tests/node_modules/tape/test/onFailure.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
'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
var noop = function () {};
var mockSink = {on: noop, removeListener: noop, emit: noop, end: noop};
tape.createStream().pipe(mockSink);
tap.test('on failure', { timeout: 1000 }, function (tt) {
tt.plan(1);
tape('dummy test', function (t) {
t.fail();
t.end();
});
tape.onFailure(function () {
tt.pass('tape ended');
});
});

14
tests/node_modules/tape/test/onFinish.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
'use strict';
var tap = require('tap');
var tape = require('../');
tap.test('on finish', {timeout: 1000}, function (tt) {
tt.plan(1);
tape.onFinish(function () {
tt.pass('tape ended');
});
tape('dummy test', function (t) {
t.end();
});
});

22
tests/node_modules/tape/test/only-twice.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
'use strict';
var tape = require('../');
var tap = require('tap');
tap.test('only twice error', function (assert) {
var test = tape.createHarness({ exit: false });
test.only('first 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'
});
assert.end();
});

47
tests/node_modules/tape/test/only.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
'use strict';
var tap = require('tap');
var tape = require('../');
var concat = require('concat-stream');
tap.test('tape only test', function (tt) {
var test = tape.createHarness({ exit: false });
var ran = [];
var tc = function (rows) {
tt.deepEqual(rows.toString('utf8'), [
'TAP version 13',
'# run success',
'ok 1 assert name',
'',
'1..1',
'# tests 1',
'# pass 1',
'',
'# ok'
].join('\n') + '\n');
tt.deepEqual(ran, [ 3 ]);
tt.end();
};
test.createStream().pipe(concat(tc));
test('never run fail', function (t) {
ran.push(1);
t.equal(true, false);
t.end();
});
test('never run success', function (t) {
ran.push(2);
t.equal(true, true);
t.end();
});
test.only('run success', function (t) {
ran.push(3);
t.ok(true, 'assert name');
t.end();
});
});

11
tests/node_modules/tape/test/only2.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
'use strict';
var test = require('../');
test('only2 test 1', function (t) {
t.end();
});
test.only('only2 test 2', function (t) {
t.end();
});

17
tests/node_modules/tape/test/only3.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
'use strict';
var test = require('../');
test('only3 test 1', function (t) {
t.fail('not 1');
t.end();
});
test.only('only3 test 2', function (t) {
t.end();
});
test('only3 test 3', function (t) {
t.fail('not 3');
t.end();
});

12
tests/node_modules/tape/test/only4.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
var test = require('../');
test('only4 duplicate test name', function (t) {
t.fail('not 1');
t.end();
});
test.only('only4 duplicate test name', function (t) {
t.end();
});

Some files were not shown because too many files have changed in this diff Show More