Added some tests
This commit is contained in:
13
tests/node_modules/tape/test/add-subtest-async.js
generated
vendored
Normal file
13
tests/node_modules/tape/test/add-subtest-async.js
generated
vendored
Normal 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
46
tests/node_modules/tape/test/anonymous-fn.js
generated
vendored
Normal 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();
|
||||
}));
|
||||
});
|
||||
18
tests/node_modules/tape/test/anonymous-fn/test-wrapper.js
generated
vendored
Normal file
18
tests/node_modules/tape/test/anonymous-fn/test-wrapper.js
generated
vendored
Normal 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
63
tests/node_modules/tape/test/array.js
generated
vendored
Normal 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
291
tests/node_modules/tape/test/async-await.js
generated
vendored
Normal 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
32
tests/node_modules/tape/test/async-await/async-bug.js
generated
vendored
Normal 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);
|
||||
});
|
||||
}
|
||||
9
tests/node_modules/tape/test/async-await/async-error.js
generated
vendored
Normal file
9
tests/node_modules/tape/test/async-await/async-error.js
generated
vendored
Normal 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
16
tests/node_modules/tape/test/async-await/async1.js
generated
vendored
Normal 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
15
tests/node_modules/tape/test/async-await/async2.js
generated
vendored
Normal 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
11
tests/node_modules/tape/test/async-await/async3.js
generated
vendored
Normal 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
17
tests/node_modules/tape/test/async-await/async4.js
generated
vendored
Normal 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
59
tests/node_modules/tape/test/async-await/async5.js
generated
vendored
Normal 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
10
tests/node_modules/tape/test/async-await/sync-error.js
generated
vendored
Normal 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
12
tests/node_modules/tape/test/bound.js
generated
vendored
Normal 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
11
tests/node_modules/tape/test/browser/asserts.js
generated
vendored
Normal 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
56
tests/node_modules/tape/test/child_ordering.js
generated
vendored
Normal 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
46
tests/node_modules/tape/test/circular-things.js
generated
vendored
Normal 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
192
tests/node_modules/tape/test/comment.js
generated
vendored
Normal 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
104
tests/node_modules/tape/test/common.js
generated
vendored
Normal 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);
|
||||
});
|
||||
};
|
||||
33
tests/node_modules/tape/test/create_multiple_streams.js
generated
vendored
Normal file
33
tests/node_modules/tape/test/create_multiple_streams.js
generated
vendored
Normal 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
193
tests/node_modules/tape/test/deep-equal-failure.js
generated
vendored
Normal 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
37
tests/node_modules/tape/test/deep.js
generated
vendored
Normal 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
51
tests/node_modules/tape/test/default-messages.js
generated
vendored
Normal 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
64
tests/node_modules/tape/test/double_end.js
generated
vendored
Normal 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
13
tests/node_modules/tape/test/double_end/double.js
generated
vendored
Normal 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
289
tests/node_modules/tape/test/edge-cases.js
generated
vendored
Normal 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
90
tests/node_modules/tape/test/end-as-callback.js
generated
vendored
Normal 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
39
tests/node_modules/tape/test/error.js
generated
vendored
Normal 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
251
tests/node_modules/tape/test/exit.js
generated
vendored
Normal 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
37
tests/node_modules/tape/test/exit/fail.js
generated
vendored
Normal 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
12
tests/node_modules/tape/test/exit/missing_end.js
generated
vendored
Normal 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
38
tests/node_modules/tape/test/exit/ok.js
generated
vendored
Normal 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
13
tests/node_modules/tape/test/exit/second.js
generated
vendored
Normal 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
8
tests/node_modules/tape/test/exit/todo.js
generated
vendored
Normal 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
8
tests/node_modules/tape/test/exit/todo_fail.js
generated
vendored
Normal 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
37
tests/node_modules/tape/test/exit/too_few.js
generated
vendored
Normal 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
14
tests/node_modules/tape/test/exposed-harness.js
generated
vendored
Normal 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
80
tests/node_modules/tape/test/fail.js
generated
vendored
Normal 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
42
tests/node_modules/tape/test/has spaces.js
generated
vendored
Normal 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
1
tests/node_modules/tape/test/ignore/.ignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
fake_node_modules
|
||||
8
tests/node_modules/tape/test/ignore/fake_node_modules/stub1.js
generated
vendored
Normal file
8
tests/node_modules/tape/test/ignore/fake_node_modules/stub1.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var tape = require('../../../');
|
||||
|
||||
tape.test(function (t) {
|
||||
t.plan(1);
|
||||
t.fail('Should not print');
|
||||
});
|
||||
8
tests/node_modules/tape/test/ignore/fake_node_modules/stub2.js
generated
vendored
Normal file
8
tests/node_modules/tape/test/ignore/fake_node_modules/stub2.js
generated
vendored
Normal 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
8
tests/node_modules/tape/test/ignore/test.js
generated
vendored
Normal 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
8
tests/node_modules/tape/test/ignore/test/stub1.js
generated
vendored
Normal 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
8
tests/node_modules/tape/test/ignore/test/stub2.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var tape = require('../../../');
|
||||
|
||||
tape.test(function (t) {
|
||||
t.pass('test/stub2');
|
||||
t.end();
|
||||
});
|
||||
8
tests/node_modules/tape/test/ignore/test/sub/sub.stub1.js
generated
vendored
Normal file
8
tests/node_modules/tape/test/ignore/test/sub/sub.stub1.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var tape = require('../../../../');
|
||||
|
||||
tape.test(function (t) {
|
||||
t.plan(1);
|
||||
t.pass('test/sub/stub1');
|
||||
});
|
||||
8
tests/node_modules/tape/test/ignore/test/sub/sub.stub2.js
generated
vendored
Normal file
8
tests/node_modules/tape/test/ignore/test/sub/sub.stub2.js
generated
vendored
Normal 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
8
tests/node_modules/tape/test/ignore/test2.js
generated
vendored
Normal 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
122
tests/node_modules/tape/test/ignore_from_gitignore.js
generated
vendored
Normal 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
10
tests/node_modules/tape/test/many.js
generated
vendored
Normal 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
173
tests/node_modules/tape/test/match.js
generated
vendored
Normal 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
12
tests/node_modules/tape/test/max_listeners.js
generated
vendored
Normal 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
7
tests/node_modules/tape/test/max_listeners/source.js
generated
vendored
Normal 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
25
tests/node_modules/tape/test/messages/defaults.js
generated
vendored
Normal 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);
|
||||
});
|
||||
38
tests/node_modules/tape/test/nested-async-plan-noend.js
generated
vendored
Normal file
38
tests/node_modules/tape/test/nested-async-plan-noend.js
generated
vendored
Normal 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);
|
||||
});
|
||||
45
tests/node_modules/tape/test/nested-sync-noplan-noend.js
generated
vendored
Normal file
45
tests/node_modules/tape/test/nested-sync-noplan-noend.js
generated
vendored
Normal 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
85
tests/node_modules/tape/test/nested.js
generated
vendored
Normal 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
21
tests/node_modules/tape/test/nested2.js
generated
vendored
Normal 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
49
tests/node_modules/tape/test/no_callback.js
generated
vendored
Normal 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
193
tests/node_modules/tape/test/not-deep-equal-failure.js
generated
vendored
Normal 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
69
tests/node_modules/tape/test/not-equal-failure.js
generated
vendored
Normal 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
184
tests/node_modules/tape/test/numerics.js
generated
vendored
Normal 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
71
tests/node_modules/tape/test/objectMode.js
generated
vendored
Normal 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
41
tests/node_modules/tape/test/objectModeWithComment.js
generated
vendored
Normal 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
23
tests/node_modules/tape/test/onFailure.js
generated
vendored
Normal 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
14
tests/node_modules/tape/test/onFinish.js
generated
vendored
Normal 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
22
tests/node_modules/tape/test/only-twice.js
generated
vendored
Normal 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
47
tests/node_modules/tape/test/only.js
generated
vendored
Normal 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
11
tests/node_modules/tape/test/only2.js
generated
vendored
Normal 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
17
tests/node_modules/tape/test/only3.js
generated
vendored
Normal 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
12
tests/node_modules/tape/test/only4.js
generated
vendored
Normal 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();
|
||||
});
|
||||
12
tests/node_modules/tape/test/only5.js
generated
vendored
Normal file
12
tests/node_modules/tape/test/only5.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('../');
|
||||
|
||||
test.only('only5 duplicate test name', function (t) {
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('only5 duplicate test name', function (t) {
|
||||
t.fail('not 2');
|
||||
t.end();
|
||||
});
|
||||
19
tests/node_modules/tape/test/order.js
generated
vendored
Normal file
19
tests/node_modules/tape/test/order.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('../');
|
||||
var current = 0;
|
||||
|
||||
test(function (t) {
|
||||
t.equal(current++, 0);
|
||||
t.end();
|
||||
});
|
||||
test(function (t) {
|
||||
t.plan(1);
|
||||
setTimeout(function () {
|
||||
t.equal(current++, 1);
|
||||
}, 100);
|
||||
});
|
||||
test(function (t) {
|
||||
t.equal(current++, 2);
|
||||
t.end();
|
||||
});
|
||||
17
tests/node_modules/tape/test/plan_optional.js
generated
vendored
Normal file
17
tests/node_modules/tape/test/plan_optional.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('../');
|
||||
|
||||
test('plan should be optional', function (t) {
|
||||
t.pass('no plan here');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('no plan async', function (t) {
|
||||
setTimeout(function () {
|
||||
t.pass('ok');
|
||||
t.end();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
// vim: set softtabstop=4 shiftwidth=4:
|
||||
105
tests/node_modules/tape/test/promise_fail.js
generated
vendored
Normal file
105
tests/node_modules/tape/test/promise_fail.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
'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('callback returning rejected promise should cause that test (and only that test) to fail', function (tt) {
|
||||
tt.plan(1);
|
||||
|
||||
var ps = spawn(process.execPath, [path.join(__dirname, 'promises', 'fail.js')]);
|
||||
|
||||
ps.stdout.pipe(concat(function (rows) {
|
||||
var rowsString = rows.toString('utf8');
|
||||
|
||||
if (/^skip\n$/.test(rowsString)) {
|
||||
return tt.pass('the test file indicated it should be skipped');
|
||||
}
|
||||
|
||||
var strippedString = stripFullStack(rowsString).filter(function (line) {
|
||||
return !/^(\s+)at(\s+)(?:Test\.)?<anonymous>(?:$|\s)/.test(line);
|
||||
}).join('\n');
|
||||
|
||||
// hack for consistency across all versions of node
|
||||
// some versions produce a longer stack trace for some reason
|
||||
// since this doesn't affect the validity of the test, the extra line is removed if present
|
||||
// the regex just removes the lines "at <anonymous>" and "[... stack stripped ...]" if they occur together
|
||||
strippedString = strippedString
|
||||
.replace(/.+at (?:Test\.)?<anonymous>\n.+\[\.\.\. stack stripped \.\.\.\]\n/g, '')
|
||||
.replace(/(?:(.+)\[\.\.\. stack stripped \.\.\.\]\n)+/g, '$1[... stack stripped ...]\n');
|
||||
|
||||
tt.same(strippedString, [
|
||||
'TAP version 13',
|
||||
'# promise',
|
||||
'not ok 1 Error: rejection message',
|
||||
' ---',
|
||||
' operator: error',
|
||||
' stack: |-',
|
||||
' Error: rejection message',
|
||||
' at $TEST/promises/fail.js:$LINE:$COL',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'# after',
|
||||
'ok 2 should be truthy',
|
||||
'',
|
||||
'1..2',
|
||||
'# tests 2',
|
||||
'# pass 1',
|
||||
'# fail 1',
|
||||
'',
|
||||
''
|
||||
].join('\n'));
|
||||
}));
|
||||
});
|
||||
|
||||
tap.test('subtest callback returning rejected promise should cause that subtest (and only that subtest) to fail', function (tt) {
|
||||
tt.plan(1);
|
||||
|
||||
var ps = spawn(process.execPath, [path.join(__dirname, 'promises', 'subTests.js')]);
|
||||
|
||||
ps.stdout.pipe(concat(function (rows) {
|
||||
var rowsString = rows.toString('utf8');
|
||||
|
||||
if (/^skip\n$/.test(rowsString)) {
|
||||
return tt.pass('the test file indicated it should be skipped');
|
||||
}
|
||||
|
||||
var strippedString = stripFullStack(rowsString).filter(function (line) {
|
||||
return !/^(\s+)at(\s+)(?:Test\.)?<anonymous>(?:$|\s)/.test(line);
|
||||
}).join('\n');
|
||||
|
||||
// hack for consistency across all versions of node
|
||||
// some versions produce a longer stack trace for some reason
|
||||
// since this doesn't affect the validity of the test, the extra line is removed if present
|
||||
// the regex just removes the lines "at <anonymous>" and "[... stack stripped ...]" if they occur together
|
||||
strippedString = strippedString
|
||||
.replace(/.+at (?:Test\.)?<anonymous>\n.+\[\.\.\. stack stripped \.\.\.\]\n/, '')
|
||||
.replace(/(?:(.+)\[\.\.\. stack stripped \.\.\.\]\n)+/g, '$1[... stack stripped ...]\n');
|
||||
|
||||
tt.same(strippedString, [
|
||||
'TAP version 13',
|
||||
'# promise',
|
||||
'# sub test that should fail',
|
||||
'not ok 1 Error: rejection message',
|
||||
' ---',
|
||||
' operator: error',
|
||||
' stack: |-',
|
||||
' Error: rejection message',
|
||||
' at $TEST/promises/subTests.js:$LINE:$COL',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'# sub test that should pass',
|
||||
'ok 2 should be truthy',
|
||||
'',
|
||||
'1..2',
|
||||
'# tests 2',
|
||||
'# pass 1',
|
||||
'# fail 1',
|
||||
'',
|
||||
''
|
||||
].join('\n'));
|
||||
}));
|
||||
});
|
||||
19
tests/node_modules/tape/test/promises/fail.js
generated
vendored
Normal file
19
tests/node_modules/tape/test/promises/fail.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('../../');
|
||||
|
||||
if (typeof Promise === 'function' && typeof Promise.resolve === 'function') {
|
||||
test('promise', function (t) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
reject(new Error('rejection message'));
|
||||
});
|
||||
});
|
||||
|
||||
test('after', function (t) {
|
||||
t.plan(1);
|
||||
t.ok(true);
|
||||
});
|
||||
} else {
|
||||
// if promises aren't supported pass the node-tap test
|
||||
console.log('skip');
|
||||
}
|
||||
20
tests/node_modules/tape/test/promises/subTests.js
generated
vendored
Normal file
20
tests/node_modules/tape/test/promises/subTests.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('../../');
|
||||
|
||||
if (typeof Promise === 'function' && typeof Promise.resolve === 'function') {
|
||||
test('promise', function (t) {
|
||||
t.test('sub test that should fail', function (t) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
reject(new Error('rejection message'));
|
||||
});
|
||||
});
|
||||
t.test('sub test that should pass', function (t) {
|
||||
t.plan(1);
|
||||
t.ok(true);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// if promises aren't supported pass the node-tap test
|
||||
console.log('skip');
|
||||
}
|
||||
71
tests/node_modules/tape/test/require.js
generated
vendored
Normal file
71
tests/node_modules/tape/test/require.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
'use strict';
|
||||
|
||||
var tap = require('tap');
|
||||
var spawn = require('child_process').spawn;
|
||||
var concat = require('concat-stream');
|
||||
|
||||
tap.test('requiring a single module', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var tc = function (rows) {
|
||||
t.same(rows.toString('utf8'), [
|
||||
'TAP version 13',
|
||||
'# module-a',
|
||||
'ok 1 loaded module a',
|
||||
'# test-a',
|
||||
'ok 2 module-a loaded in same context',
|
||||
'ok 3 test ran after module-a was loaded',
|
||||
'',
|
||||
'1..3',
|
||||
'# tests 3',
|
||||
'# pass 3',
|
||||
'',
|
||||
'# ok'
|
||||
].join('\n') + '\n\n');
|
||||
};
|
||||
|
||||
var ps = tape('-r ./require/a require/test-a.js');
|
||||
ps.stdout.pipe(concat(tc));
|
||||
ps.on('exit', function (code) {
|
||||
t.equal(code, 0);
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('requiring multiple modules', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var tc = function (rows) {
|
||||
t.same(rows.toString('utf8'), [
|
||||
'TAP version 13',
|
||||
'# module-a',
|
||||
'ok 1 loaded module a',
|
||||
'# module-b',
|
||||
'ok 2 loaded module b',
|
||||
'# test-a',
|
||||
'ok 3 module-a loaded in same context',
|
||||
'ok 4 test ran after module-a was loaded',
|
||||
'# test-b',
|
||||
'ok 5 module-b loaded in same context',
|
||||
'ok 6 test ran after module-b was loaded',
|
||||
'',
|
||||
'1..6',
|
||||
'# tests 6',
|
||||
'# pass 6',
|
||||
'',
|
||||
'# ok'
|
||||
].join('\n') + '\n\n');
|
||||
};
|
||||
|
||||
var ps = tape('-r ./require/a -r ./require/b require/test-a.js require/test-b.js');
|
||||
ps.stdout.pipe(concat(tc));
|
||||
ps.on('exit', function (code) {
|
||||
t.equal(code, 0);
|
||||
});
|
||||
});
|
||||
|
||||
function tape(args) {
|
||||
var proc = require('child_process');
|
||||
var bin = __dirname + '/../bin/tape';
|
||||
|
||||
return proc.spawn('node', [bin].concat(args.split(' ')), { cwd: __dirname });
|
||||
}
|
||||
10
tests/node_modules/tape/test/require/a.js
generated
vendored
Normal file
10
tests/node_modules/tape/test/require/a.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
var tape = require('../..');
|
||||
|
||||
tape.test('module-a', function (t) {
|
||||
t.plan(1);
|
||||
t.pass('loaded module a');
|
||||
});
|
||||
|
||||
global.module_a = true;
|
||||
10
tests/node_modules/tape/test/require/b.js
generated
vendored
Normal file
10
tests/node_modules/tape/test/require/b.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
var tape = require('../..');
|
||||
|
||||
tape.test('module-b', function (t) {
|
||||
t.plan(1);
|
||||
t.pass('loaded module b');
|
||||
});
|
||||
|
||||
global.module_b = true;
|
||||
9
tests/node_modules/tape/test/require/test-a.js
generated
vendored
Normal file
9
tests/node_modules/tape/test/require/test-a.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var tape = require('../..');
|
||||
|
||||
tape.test('test-a', function (t) {
|
||||
t.ok(global.module_a, 'module-a loaded in same context');
|
||||
t.pass('test ran after module-a was loaded');
|
||||
t.end();
|
||||
});
|
||||
9
tests/node_modules/tape/test/require/test-b.js
generated
vendored
Normal file
9
tests/node_modules/tape/test/require/test-b.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var tape = require('../..');
|
||||
|
||||
tape.test('test-b', function (t) {
|
||||
t.ok(global.module_b, 'module-b loaded in same context');
|
||||
t.pass('test ran after module-b was loaded');
|
||||
t.end();
|
||||
});
|
||||
54
tests/node_modules/tape/test/skip.js
generated
vendored
Normal file
54
tests/node_modules/tape/test/skip.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('../');
|
||||
var ran = 0;
|
||||
|
||||
var concat = require('concat-stream');
|
||||
var tap = require('tap');
|
||||
|
||||
tap.test('test SKIP comment', function (assert) {
|
||||
assert.plan(1);
|
||||
|
||||
var verify = function (output) {
|
||||
assert.equal(output.toString('utf8'), [
|
||||
'TAP version 13',
|
||||
'# SKIP skipped',
|
||||
'',
|
||||
'1..0',
|
||||
'# tests 0',
|
||||
'# pass 0',
|
||||
'',
|
||||
'# ok',
|
||||
''
|
||||
].join('\n'));
|
||||
};
|
||||
|
||||
var tapeTest = test.createHarness();
|
||||
tapeTest.createStream().pipe(concat(verify));
|
||||
tapeTest('skipped', { skip: true }, function (t) {
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('skip this', { skip: true }, function (t) {
|
||||
t.fail('this should not even run');
|
||||
ran++;
|
||||
t.end();
|
||||
});
|
||||
|
||||
test.skip('skip this too', function (t) {
|
||||
t.fail('this should not even run');
|
||||
ran++;
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('skip subtest', function (t) {
|
||||
ran++;
|
||||
t.test('skip this', { skip: true }, function (t) {
|
||||
t.fail('this should not even run');
|
||||
t.end();
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
// vim: set softtabstop=4 shiftwidth=4:
|
||||
84
tests/node_modules/tape/test/skip_explanation.js
generated
vendored
Normal file
84
tests/node_modules/tape/test/skip_explanation.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
'use strict';
|
||||
|
||||
var tap = require('tap');
|
||||
var test = require('../');
|
||||
var concat = require('concat-stream');
|
||||
var stripFullStack = require('./common').stripFullStack;
|
||||
|
||||
tap.test('test skip explanations', function (assert) {
|
||||
assert.plan(1);
|
||||
|
||||
var verify = function (output) {
|
||||
assert.deepEqual(stripFullStack(output.toString('utf8')), [
|
||||
'TAP version 13',
|
||||
'# SKIP (this skips)',
|
||||
'# some tests might skip',
|
||||
'ok 1 this runs',
|
||||
'ok 2 failing assert is skipped # SKIP',
|
||||
'ok 3 this runs',
|
||||
'# incomplete test',
|
||||
'ok 4 run sh',
|
||||
'ok 5 run openssl # SKIP',
|
||||
'# incomplete test with explanation',
|
||||
'ok 6 run sh (conditional skip) # SKIP',
|
||||
'ok 7 run openssl # SKIP can\'t run on windows platforms',
|
||||
'ok 8 this runs',
|
||||
'# too much explanation',
|
||||
'ok 9 run openssl # SKIP Installer cannot work on windows and fails to add to PATH Err: (2401) denied',
|
||||
'',
|
||||
'1..9',
|
||||
'# tests 9',
|
||||
'# pass 9',
|
||||
'',
|
||||
'# ok',
|
||||
''
|
||||
]);
|
||||
};
|
||||
|
||||
var tapeTest = test.createHarness();
|
||||
tapeTest.createStream().pipe(concat(verify));
|
||||
|
||||
tapeTest('(this skips)', { skip: true }, function (t) {
|
||||
t.fail('doesn\'t run');
|
||||
t.fail('this doesn\'t run too', { skip: false });
|
||||
t.end();
|
||||
});
|
||||
|
||||
tapeTest('some tests might skip', function (t) {
|
||||
t.pass('this runs');
|
||||
t.fail('failing assert is skipped', { skip: true });
|
||||
t.pass('this runs');
|
||||
t.end();
|
||||
});
|
||||
|
||||
tapeTest('incomplete test', function (t) {
|
||||
// var platform = process.platform; something like this needed
|
||||
var platform = 'win32';
|
||||
|
||||
t.pass('run sh', { skip: platform !== 'win32' });
|
||||
t.pass('run openssl', { skip: platform === 'win32' });
|
||||
t.end();
|
||||
});
|
||||
|
||||
tapeTest('incomplete test with explanation', function (t) {
|
||||
// var platform = process.platform; something like this needed
|
||||
var platform = 'win32';
|
||||
|
||||
t.fail('run sh (conditional skip)', { skip: platform === 'win32' });
|
||||
t.fail('run openssl', { skip: platform === 'win32' && 'can\'t run on windows platforms' });
|
||||
t.pass('this runs');
|
||||
t.end();
|
||||
});
|
||||
|
||||
tapeTest('too much explanation', function (t) {
|
||||
// var platform = process.platform; something like this needed
|
||||
var platform = 'win32';
|
||||
|
||||
t.fail('run openssl',
|
||||
{ skip: platform === 'win32' && 'Installer cannot work on windows\nand fails to add to PATH\n\n Err: (2401) denied' }
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
// vim: set softtabstop=4 shiftwidth=4:
|
||||
307
tests/node_modules/tape/test/stackTrace.js
generated
vendored
Normal file
307
tests/node_modules/tape/test/stackTrace.js
generated
vendored
Normal file
@@ -0,0 +1,307 @@
|
||||
'use strict';
|
||||
|
||||
var tape = require('../');
|
||||
var tap = require('tap');
|
||||
var concat = require('concat-stream');
|
||||
var tapParser = require('tap-parser');
|
||||
var yaml = require('js-yaml');
|
||||
|
||||
tap.test('preserves stack trace with newlines', function (tt) {
|
||||
tt.plan(3);
|
||||
|
||||
var test = tape.createHarness();
|
||||
var stream = test.createStream();
|
||||
var parser = stream.pipe(tapParser());
|
||||
var stackTrace = 'foo\n bar';
|
||||
|
||||
parser.once('assert', function (data) {
|
||||
delete data.diag.at;
|
||||
tt.deepEqual(data, {
|
||||
ok: false,
|
||||
id: 1,
|
||||
name: 'Error: Preserve stack',
|
||||
diag: {
|
||||
stack: stackTrace,
|
||||
operator: 'error'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
stream.pipe(concat(function (body) {
|
||||
var body = body.toString('utf8');
|
||||
body = stripAt(body);
|
||||
tt.equal(
|
||||
body,
|
||||
'TAP version 13\n'
|
||||
+ '# multiline stack trace\n'
|
||||
+ 'not ok 1 Error: Preserve stack\n'
|
||||
+ ' ---\n'
|
||||
+ ' operator: error\n'
|
||||
+ ' stack: |-\n'
|
||||
+ ' foo\n'
|
||||
+ ' bar\n'
|
||||
+ ' ...\n'
|
||||
+ '\n'
|
||||
+ '1..1\n'
|
||||
+ '# tests 1\n'
|
||||
+ '# pass 0\n'
|
||||
+ '# fail 1\n'
|
||||
);
|
||||
|
||||
tt.deepEqual(getDiag(body), {
|
||||
stack: stackTrace,
|
||||
operator: 'error'
|
||||
});
|
||||
}));
|
||||
|
||||
test('multiline stack trace', function (t) {
|
||||
t.plan(1);
|
||||
var err = new Error('Preserve stack');
|
||||
err.stack = stackTrace;
|
||||
t.error(err);
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('parses function info from original stack', function (tt) {
|
||||
tt.plan(4);
|
||||
|
||||
var test = tape.createHarness();
|
||||
test.createStream();
|
||||
|
||||
test._results._watch = function (t) {
|
||||
t.on('result', function (res) {
|
||||
tt.equal('Test.testFunctionNameParsing', res.functionName);
|
||||
tt.match(res.file, /stackTrace.js/i);
|
||||
tt.ok(Number(res.line) > 0);
|
||||
tt.ok(Number(res.column) > 0);
|
||||
});
|
||||
};
|
||||
|
||||
test('t.equal stack trace', function testFunctionNameParsing(t) {
|
||||
t.equal(true, false, 'true should be false');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('parses function info from original stack for anonymous function', function (tt) {
|
||||
tt.plan(4);
|
||||
|
||||
var test = tape.createHarness();
|
||||
test.createStream();
|
||||
|
||||
test._results._watch = function (t) {
|
||||
t.on('result', function (res) {
|
||||
tt.equal('Test.<anonymous>', res.functionName);
|
||||
tt.match(res.file, /stackTrace.js/i);
|
||||
tt.ok(Number(res.line) > 0);
|
||||
tt.ok(Number(res.column) > 0);
|
||||
});
|
||||
};
|
||||
|
||||
test('t.equal stack trace', function (t) {
|
||||
t.equal(true, false, 'true should be false');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
if (typeof Promise === 'function' && typeof Promise.resolve === 'function') {
|
||||
|
||||
tap.test('parses function info from original stack for Promise scenario', function (tt) {
|
||||
tt.plan(4);
|
||||
|
||||
var test = tape.createHarness();
|
||||
test.createStream();
|
||||
|
||||
test._results._watch = function (t) {
|
||||
t.on('result', function (res) {
|
||||
tt.equal('onfulfilled', res.functionName);
|
||||
tt.match(res.file, /stackTrace.js/i);
|
||||
tt.ok(Number(res.line) > 0);
|
||||
tt.ok(Number(res.column) > 0);
|
||||
});
|
||||
};
|
||||
|
||||
test('t.equal stack trace', function testFunctionNameParsing(t) {
|
||||
new Promise(function (resolve) {
|
||||
resolve();
|
||||
}).then(function onfulfilled() {
|
||||
t.equal(true, false, 'true should be false');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('parses function info from original stack for Promise scenario with anonymous function', function (tt) {
|
||||
tt.plan(4);
|
||||
|
||||
var test = tape.createHarness();
|
||||
test.createStream();
|
||||
|
||||
test._results._watch = function (t) {
|
||||
t.on('result', function (res) {
|
||||
tt.equal('<anonymous>', res.functionName);
|
||||
tt.match(res.file, /stackTrace.js/i);
|
||||
tt.ok(Number(res.line) > 0);
|
||||
tt.ok(Number(res.column) > 0);
|
||||
});
|
||||
};
|
||||
|
||||
test('t.equal stack trace', function testFunctionNameParsing(t) {
|
||||
new Promise(function (resolve) {
|
||||
resolve();
|
||||
}).then(function () {
|
||||
t.equal(true, false, 'true should be false');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
tap.test('preserves stack trace for failed assertions', function (tt) {
|
||||
tt.plan(6);
|
||||
|
||||
var test = tape.createHarness();
|
||||
var stream = test.createStream();
|
||||
var parser = stream.pipe(tapParser());
|
||||
|
||||
var stack = '';
|
||||
parser.once('assert', function (data) {
|
||||
tt.equal(typeof data.diag.at, 'string');
|
||||
tt.equal(typeof data.diag.stack, 'string');
|
||||
var at = data.diag.at || '';
|
||||
stack = data.diag.stack || '';
|
||||
tt.ok(/^Error: true should be false(\n at .+)+/.exec(stack), 'stack should be a stack');
|
||||
tt.deepEqual(data, {
|
||||
ok: false,
|
||||
id: 1,
|
||||
name: 'true should be false',
|
||||
diag: {
|
||||
at: at,
|
||||
stack: stack,
|
||||
operator: 'equal',
|
||||
expected: false,
|
||||
actual: true
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
stream.pipe(concat(function (body) {
|
||||
var body = body.toString('utf8');
|
||||
body = stripAt(body);
|
||||
tt.equal(
|
||||
body,
|
||||
'TAP version 13\n'
|
||||
+ '# t.equal stack trace\n'
|
||||
+ 'not ok 1 true should be false\n'
|
||||
+ ' ---\n'
|
||||
+ ' operator: equal\n'
|
||||
+ ' expected: false\n'
|
||||
+ ' actual: true\n'
|
||||
+ ' stack: |-\n'
|
||||
+ ' '
|
||||
+ stack.replace(/\n/g, '\n ') + '\n'
|
||||
+ ' ...\n'
|
||||
+ '\n'
|
||||
+ '1..1\n'
|
||||
+ '# tests 1\n'
|
||||
+ '# pass 0\n'
|
||||
+ '# fail 1\n'
|
||||
);
|
||||
|
||||
tt.deepEqual(getDiag(body), {
|
||||
stack: stack,
|
||||
operator: 'equal',
|
||||
expected: false,
|
||||
actual: true
|
||||
});
|
||||
}));
|
||||
|
||||
test('t.equal stack trace', function (t) {
|
||||
t.plan(1);
|
||||
t.equal(true, false, 'true should be false');
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('preserves stack trace for failed assertions where actual===falsy', function (tt) {
|
||||
tt.plan(6);
|
||||
|
||||
var test = tape.createHarness();
|
||||
var stream = test.createStream();
|
||||
var parser = stream.pipe(tapParser());
|
||||
|
||||
var stack = '';
|
||||
parser.once('assert', function (data) {
|
||||
tt.equal(typeof data.diag.at, 'string');
|
||||
tt.equal(typeof data.diag.stack, 'string');
|
||||
var at = data.diag.at || '';
|
||||
stack = data.diag.stack || '';
|
||||
tt.ok(/^Error: false should be true(\n at .+)+/.exec(stack), 'stack should be a stack');
|
||||
tt.deepEqual(data, {
|
||||
ok: false,
|
||||
id: 1,
|
||||
name: 'false should be true',
|
||||
diag: {
|
||||
at: at,
|
||||
stack: stack,
|
||||
operator: 'equal',
|
||||
expected: true,
|
||||
actual: false
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
stream.pipe(concat(function (body) {
|
||||
var body = body.toString('utf8');
|
||||
body = stripAt(body);
|
||||
tt.equal(
|
||||
body,
|
||||
'TAP version 13\n'
|
||||
+ '# t.equal stack trace\n'
|
||||
+ 'not ok 1 false should be true\n'
|
||||
+ ' ---\n'
|
||||
+ ' operator: equal\n'
|
||||
+ ' expected: true\n'
|
||||
+ ' actual: false\n'
|
||||
+ ' stack: |-\n'
|
||||
+ ' '
|
||||
+ stack.replace(/\n/g, '\n ') + '\n'
|
||||
+ ' ...\n'
|
||||
+ '\n'
|
||||
+ '1..1\n'
|
||||
+ '# tests 1\n'
|
||||
+ '# pass 0\n'
|
||||
+ '# fail 1\n'
|
||||
);
|
||||
|
||||
tt.deepEqual(getDiag(body), {
|
||||
stack: stack,
|
||||
operator: 'equal',
|
||||
expected: true,
|
||||
actual: false
|
||||
});
|
||||
}));
|
||||
|
||||
test('t.equal stack trace', function (t) {
|
||||
t.plan(1);
|
||||
t.equal(false, true, 'false should be true');
|
||||
});
|
||||
});
|
||||
|
||||
function getDiag(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');
|
||||
|
||||
// Get rid of 'at' variable (which has a line number / path of its own that's
|
||||
// difficult to check).
|
||||
var withStack = yaml.safeLoad(diag);
|
||||
delete withStack.at;
|
||||
return withStack;
|
||||
}
|
||||
|
||||
function stripAt(body) {
|
||||
return body.replace(/^\s*at:\s+Test.*$\n/m, '');
|
||||
}
|
||||
16
tests/node_modules/tape/test/subcount.js
generated
vendored
Normal file
16
tests/node_modules/tape/test/subcount.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('../');
|
||||
|
||||
test('parent test', function (t) {
|
||||
t.plan(2);
|
||||
t.test('first child', function (t) {
|
||||
t.plan(1);
|
||||
t.pass('pass first child');
|
||||
});
|
||||
|
||||
t.test(function (t) {
|
||||
t.plan(1);
|
||||
t.pass('pass second child');
|
||||
});
|
||||
});
|
||||
27
tests/node_modules/tape/test/subtest_and_async.js
generated
vendored
Normal file
27
tests/node_modules/tape/test/subtest_and_async.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('../');
|
||||
|
||||
var asyncFunction = function (callback) {
|
||||
setTimeout(callback, Math.random * 50);
|
||||
};
|
||||
|
||||
test('master test', function (t) {
|
||||
t.test('subtest 1', function (st) {
|
||||
st.pass('subtest 1 before async call');
|
||||
asyncFunction(function () {
|
||||
st.pass('subtest 1 in async callback');
|
||||
st.end();
|
||||
});
|
||||
});
|
||||
|
||||
t.test('subtest 2', function (st) {
|
||||
st.pass('subtest 2 before async call');
|
||||
asyncFunction(function () {
|
||||
st.pass('subtest 2 in async callback');
|
||||
st.end();
|
||||
});
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
23
tests/node_modules/tape/test/subtest_plan.js
generated
vendored
Normal file
23
tests/node_modules/tape/test/subtest_plan.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('../');
|
||||
|
||||
test('parent', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var firstChildRan = false;
|
||||
|
||||
t.pass('assertion in parent');
|
||||
|
||||
t.test('first child', function (t) {
|
||||
t.plan(1);
|
||||
t.pass('pass first child');
|
||||
firstChildRan = true;
|
||||
});
|
||||
|
||||
t.test('second child', function (t) {
|
||||
t.plan(2);
|
||||
t.ok(firstChildRan, 'first child ran first');
|
||||
t.pass('pass second child');
|
||||
});
|
||||
});
|
||||
316
tests/node_modules/tape/test/teardown.js
generated
vendored
Normal file
316
tests/node_modules/tape/test/teardown.js
generated
vendored
Normal file
@@ -0,0 +1,316 @@
|
||||
'use strict';
|
||||
|
||||
var tape = require('../');
|
||||
var tap = require('tap');
|
||||
var concat = require('concat-stream');
|
||||
var forEach = require('for-each');
|
||||
var v = require('es-value-fixtures');
|
||||
var inspect = require('object-inspect');
|
||||
var flatMap = require('array.prototype.flatmap');
|
||||
|
||||
var stripFullStack = require('./common').stripFullStack;
|
||||
|
||||
tap.test('teardowns', function (tt) {
|
||||
tt.plan(1);
|
||||
|
||||
var test = tape.createHarness();
|
||||
test.createStream().pipe(concat(function (body) {
|
||||
tt.same(stripFullStack(body.toString('utf8')), [].concat(
|
||||
'TAP version 13',
|
||||
'# success',
|
||||
'ok 1 should be truthy',
|
||||
'# success teardown',
|
||||
'# success teardown 2',
|
||||
'# success (async)',
|
||||
'ok 2 should be truthy',
|
||||
'# success (async) teardown',
|
||||
'# success (async) teardown 2',
|
||||
'# nested teardowns',
|
||||
'# nested success',
|
||||
'ok 3 should be truthy',
|
||||
'# nested teardown (nested success level)',
|
||||
'# nested teardown (nested success level) 2',
|
||||
'# nested failure',
|
||||
'not ok 4 nested failure!',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' at: Test.<anonymous> ($TEST/teardown.js:$LINE:$COL)',
|
||||
' stack: |-',
|
||||
' Error: nested failure!',
|
||||
' [... stack stripped ...]',
|
||||
' at Test.<anonymous> ($TEST/teardown.js:$LINE:$COL)',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'# nested teardown (nested fail level)',
|
||||
'# nested teardown (nested fail level) 2',
|
||||
'# nested teardown (top level)',
|
||||
'# nested teardown (top level) 2',
|
||||
'# fail',
|
||||
'not ok 5 failure!',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' at: Test.<anonymous> ($TEST/teardown.js:$LINE:$COL)',
|
||||
' stack: |-',
|
||||
' Error: failure!',
|
||||
' [... stack stripped ...]',
|
||||
' at Test.<anonymous> ($TEST/teardown.js:$LINE:$COL)',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'# failure teardown',
|
||||
'# failure teardown 2',
|
||||
'# teardown errors do not stop the next teardown fn from running',
|
||||
'ok 6 should be truthy',
|
||||
'not ok 7 SyntaxError: teardown error!',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' stack: |-',
|
||||
' Error: SyntaxError: teardown error!',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'not ok 8 plan != count',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' expected: 1',
|
||||
' actual: 2',
|
||||
' stack: |-',
|
||||
' Error: plan != count',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'# teardown runs after teardown error',
|
||||
'# teardown given non-function fails the test',
|
||||
'ok 9 should be truthy',
|
||||
flatMap(v.nonFunctions, function (nonFunction, i) {
|
||||
var offset = 10;
|
||||
return [].concat(
|
||||
'not ok ' + (offset + (i > 0 ? i + 1 : i)) + ' teardown: ' + inspect(nonFunction) + ' is not a function',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' at: <anonymous> ($TEST/teardown.js:$LINE:$COL)',
|
||||
' stack: |-',
|
||||
' Error: teardown: ' + inspect(nonFunction) + ' is not a function',
|
||||
' [... stack stripped ...]',
|
||||
' at $TEST/teardown.js:$LINE:$COL',
|
||||
' [... stack stripped ...]',
|
||||
' at Test.<anonymous> ($TEST/teardown.js:$LINE:$COL)',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
i > 0 ? [] : [
|
||||
'not ok '+ (offset + 1) +' plan != count',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' expected: 1',
|
||||
' actual: 2',
|
||||
' at: <anonymous> ($TEST/teardown.js:$LINE:$COL)',
|
||||
' stack: |-',
|
||||
' Error: plan != count',
|
||||
' [... stack stripped ...]',
|
||||
' at $TEST/teardown.js:$LINE:$COL',
|
||||
' [... stack stripped ...]',
|
||||
' at Test.<anonymous> ($TEST/teardown.js:$LINE:$COL)',
|
||||
' [... stack stripped ...]',
|
||||
' ...'
|
||||
]
|
||||
);
|
||||
}),
|
||||
typeof Promise === 'function' ? [
|
||||
'# teardown is only ever called once, even when async',
|
||||
'ok ' + (11 + v.nonFunctions.length) + ' passes',
|
||||
'# teardown: once?',
|
||||
'# success (promise)',
|
||||
'ok ' + (12 + v.nonFunctions.length) + ' should be truthy',
|
||||
'# success (promise) teardown: 1',
|
||||
'# success (promise) teardown: 2',
|
||||
'# success (promise) teardown: 3'
|
||||
] : [
|
||||
'# SKIP teardown is only ever called once, even when async',
|
||||
'# SKIP success (promise)'
|
||||
], [
|
||||
'',
|
||||
'1..' + ((typeof Promise === 'function' ? 2 : 0) + 10 + v.nonFunctions.length),
|
||||
'# tests ' + ((typeof Promise === 'function' ? 2 : 0) + 10 + v.nonFunctions.length),
|
||||
'# pass ' + ((typeof Promise === 'function' ? 2 : 0) + 5),
|
||||
'# fail ' + (5 + v.nonFunctions.length),
|
||||
''
|
||||
]));
|
||||
}));
|
||||
|
||||
test('success', function (t) {
|
||||
t.plan(1);
|
||||
t.teardown(function () {
|
||||
t.comment('success teardown');
|
||||
});
|
||||
t.teardown(function () {
|
||||
t.comment('success teardown 2');
|
||||
});
|
||||
t.ok('success!');
|
||||
});
|
||||
|
||||
test('success (async)', function (t) {
|
||||
t.plan(1);
|
||||
t.teardown(function () {
|
||||
t.comment('success (async) teardown');
|
||||
});
|
||||
t.teardown(function () {
|
||||
t.comment('success (async) teardown 2');
|
||||
});
|
||||
setTimeout(function () {
|
||||
t.ok('success!');
|
||||
}, 10);
|
||||
});
|
||||
|
||||
test('nested teardowns', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
t.teardown(function () {
|
||||
t.comment('nested teardown (top level)');
|
||||
});
|
||||
t.teardown(function () {
|
||||
t.comment('nested teardown (top level) 2');
|
||||
});
|
||||
|
||||
t.test('nested success', function (st) {
|
||||
st.teardown(function () {
|
||||
st.comment('nested teardown (nested success level)');
|
||||
});
|
||||
st.teardown(function () {
|
||||
st.comment('nested teardown (nested success level) 2');
|
||||
});
|
||||
|
||||
st.ok('nested success!');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('nested failure', function (st) {
|
||||
st.plan(1);
|
||||
|
||||
st.teardown(function () {
|
||||
st.comment('nested teardown (nested fail level)');
|
||||
});
|
||||
st.teardown(function () {
|
||||
st.comment('nested teardown (nested fail level) 2');
|
||||
});
|
||||
|
||||
st.fail('nested failure!');
|
||||
});
|
||||
});
|
||||
|
||||
test('fail', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
t.teardown(function () {
|
||||
t.comment('failure teardown');
|
||||
});
|
||||
t.teardown(function () {
|
||||
t.comment('failure teardown 2');
|
||||
});
|
||||
|
||||
t.fail('failure!');
|
||||
});
|
||||
|
||||
test('teardown errors do not stop the next teardown fn from running', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
t.ok('teardown error test');
|
||||
|
||||
t.teardown(function () {
|
||||
throw new SyntaxError('teardown error!');
|
||||
});
|
||||
t.teardown(function () {
|
||||
t.comment('teardown runs after teardown error');
|
||||
});
|
||||
});
|
||||
|
||||
test('teardown given non-function fails the test', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
t.ok('non-function test');
|
||||
|
||||
forEach(v.nonFunctions, function (nonFunction) {
|
||||
t.teardown(nonFunction);
|
||||
});
|
||||
});
|
||||
|
||||
test('teardown is only ever called once, even when async', { skip: typeof Promise !== 'function' }, function (t) {
|
||||
t.plan(1);
|
||||
|
||||
t.teardown(function () {
|
||||
t.comment('teardown: once?');
|
||||
});
|
||||
|
||||
t.pass('passes');
|
||||
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
test('success (promise)', { skip: typeof Promise !== 'function' }, function (t) {
|
||||
t.plan(1);
|
||||
|
||||
t.teardown(function () {
|
||||
return new Promise(function (resolve) {
|
||||
t.comment('success (promise) teardown: 1');
|
||||
setTimeout(resolve, 10);
|
||||
}).then(function () {
|
||||
t.comment('success (promise) teardown: 2');
|
||||
});
|
||||
});
|
||||
t.teardown(function () {
|
||||
t.comment('success (promise) teardown: 3');
|
||||
});
|
||||
|
||||
setTimeout(function () {
|
||||
t.ok('success!');
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('teardown with promise', { skip: typeof Promise !== 'function', timeout: 1e3 }, function (tt) {
|
||||
tt.plan(2);
|
||||
tape('dummy test', function (t) {
|
||||
var resolved = false;
|
||||
t.teardown(function () {
|
||||
tt.pass('tape teardown');
|
||||
var p = Promise.resolve();
|
||||
p.then(function () {
|
||||
resolved = true;
|
||||
});
|
||||
return p;
|
||||
});
|
||||
t.on('end', function () {
|
||||
tt.is(resolved, true);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('teardown only runs once', { skip: typeof Promise !== 'function', timeout: 1e3 }, function (tt) {
|
||||
tt.plan(1);
|
||||
|
||||
var test = tape.createHarness();
|
||||
test.createStream().pipe(concat(function (body) {
|
||||
tt.same(stripFullStack(body.toString('utf8')), [].concat(
|
||||
'TAP version 13',
|
||||
'# teardown is only called once, even with a plan',
|
||||
'ok 1 passes',
|
||||
'# Tearing down!',
|
||||
'',
|
||||
'1..1',
|
||||
'# tests 1',
|
||||
'# pass 1',
|
||||
'',
|
||||
'# ok',
|
||||
''
|
||||
));
|
||||
}));
|
||||
|
||||
test('teardown is only called once, even with a plan', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
t.teardown(function () {
|
||||
t.comment('Tearing down!');
|
||||
});
|
||||
|
||||
t.pass('passes');
|
||||
|
||||
return Promise.resolve();
|
||||
});
|
||||
});
|
||||
315
tests/node_modules/tape/test/throws.js
generated
vendored
Normal file
315
tests/node_modules/tape/test/throws.js
generated
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
'use strict';
|
||||
|
||||
var tape = require('../');
|
||||
var tap = require('tap');
|
||||
var concat = require('concat-stream');
|
||||
var inspect = require('object-inspect');
|
||||
var assign = require('object.assign');
|
||||
|
||||
var stripFullStack = require('./common').stripFullStack;
|
||||
|
||||
function fn() {
|
||||
throw new TypeError('RegExp');
|
||||
}
|
||||
|
||||
function getNonFunctionMessage(fn) {
|
||||
try {
|
||||
fn();
|
||||
} catch (e) {
|
||||
return e.message;
|
||||
}
|
||||
}
|
||||
|
||||
var getter = function () { return 'message'; };
|
||||
var messageGetterError = Object.defineProperty(
|
||||
{ custom: 'error' },
|
||||
'message',
|
||||
{ configurable: true, enumerable: true, get: getter }
|
||||
);
|
||||
var thrower = function () { throw messageGetterError; };
|
||||
|
||||
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',
|
||||
'# non functions',
|
||||
'ok 1 should throw',
|
||||
'ok 2 should throw',
|
||||
'ok 3 should throw',
|
||||
'ok 4 should throw',
|
||||
'ok 5 should throw',
|
||||
'ok 6 should throw',
|
||||
'ok 7 should throw',
|
||||
'ok 8 should throw',
|
||||
'# function',
|
||||
'not ok 9 should throw',
|
||||
' ---',
|
||||
' operator: throws',
|
||||
' expected: undefined',
|
||||
' actual: undefined',
|
||||
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
|
||||
' stack: |-',
|
||||
' Error: should throw',
|
||||
' [... stack stripped ...]',
|
||||
' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'# custom error messages',
|
||||
'ok 10 "message" is enumerable',
|
||||
"ok 11 { custom: 'error', message: 'message' }",
|
||||
'ok 12 getter is still the same',
|
||||
'# throws null',
|
||||
'ok 13 throws null',
|
||||
'# wrong type of error',
|
||||
'not ok 14 throws actual',
|
||||
' ---',
|
||||
' operator: throws',
|
||||
' expected: |-',
|
||||
' [Function: TypeError]',
|
||||
' actual: |-',
|
||||
" { [RangeError: actual!] message: 'actual!' }",
|
||||
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
|
||||
' stack: |-',
|
||||
' RangeError: actual!',
|
||||
' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'# object',
|
||||
'ok 15 object properties are validated',
|
||||
'# object with regexes',
|
||||
'ok 16 object with regex values is validated',
|
||||
'# similar error object',
|
||||
'ok 17 throwing a similar error',
|
||||
'# validate with regex',
|
||||
'ok 18 regex against toString of error',
|
||||
'# custom error validation',
|
||||
'ok 19 error is SyntaxError',
|
||||
'ok 20 error matches /value/',
|
||||
'ok 21 unexpected error',
|
||||
'# throwing primitives',
|
||||
'ok 22 primitive: null',
|
||||
'ok 23 primitive: undefined',
|
||||
'ok 24 primitive: 0',
|
||||
'ok 25 primitive: NaN',
|
||||
'ok 26 primitive: 42',
|
||||
'ok 27 primitive: Infinity',
|
||||
'ok 28 primitive: \'\'',
|
||||
'ok 29 primitive: \'foo\'',
|
||||
'ok 30 primitive: true',
|
||||
'ok 31 primitive: false',
|
||||
'# ambiguous arguments',
|
||||
'ok 32 Second',
|
||||
'ok 33 Second',
|
||||
'ok 34 Second',
|
||||
'ok 35 should throw',
|
||||
'not ok 36 should throw',
|
||||
' ---',
|
||||
' operator: throws',
|
||||
' expected: |-',
|
||||
' \'/Second$/\'',
|
||||
' actual: |-',
|
||||
' { [Error: First] message: \'First\' }',
|
||||
' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
|
||||
' stack: |-',
|
||||
' Error: First',
|
||||
' at throwingFirst ($TEST/throws.js:$LINE:$COL)',
|
||||
' [... stack stripped ...]',
|
||||
' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'',
|
||||
'1..36',
|
||||
'# tests 36',
|
||||
'# pass 33',
|
||||
'# fail 3',
|
||||
''
|
||||
]);
|
||||
}));
|
||||
|
||||
test('non functions', function (t) {
|
||||
t.plan(8);
|
||||
t.throws();
|
||||
t.throws(null);
|
||||
t.throws(true);
|
||||
t.throws(false);
|
||||
t.throws('abc');
|
||||
t.throws(/a/g);
|
||||
t.throws([]);
|
||||
t.throws({});
|
||||
});
|
||||
|
||||
test('function', function (t) {
|
||||
t.plan(1);
|
||||
t.throws(function () {});
|
||||
});
|
||||
|
||||
test('custom error messages', function (t) {
|
||||
t.plan(3);
|
||||
t.equal(Object.prototype.propertyIsEnumerable.call(messageGetterError, 'message'), true, '"message" is enumerable');
|
||||
t.throws(thrower, "{ custom: 'error', message: 'message' }");
|
||||
t.equal(Object.getOwnPropertyDescriptor(messageGetterError, 'message').get, getter, 'getter is still the same');
|
||||
});
|
||||
|
||||
test('throws null', function (t) {
|
||||
t.plan(1);
|
||||
t.throws(function () { throw null; }, 'throws null');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('wrong type of error', function (t) {
|
||||
t.plan(1);
|
||||
var actual = new RangeError('actual!');
|
||||
t.throws(function () { throw actual; }, TypeError, 'throws actual');
|
||||
t.end();
|
||||
});
|
||||
|
||||
// taken from https://nodejs.org/api/assert.html#assert_assert_throws_fn_error_message
|
||||
var err = new TypeError('Wrong value');
|
||||
err.code = 404;
|
||||
err.foo = 'bar';
|
||||
err.info = {
|
||||
nested: true,
|
||||
baz: 'text'
|
||||
};
|
||||
err.reg = /abc/i;
|
||||
|
||||
test('object', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
t.throws(
|
||||
function () { throw err; },
|
||||
{
|
||||
name: 'TypeError',
|
||||
message: 'Wrong value',
|
||||
info: {
|
||||
nested: true,
|
||||
baz: 'text'
|
||||
}
|
||||
// Only properties on the validation object will be tested for.
|
||||
// Using nested objects requires all properties to be present. Otherwise
|
||||
// the validation is going to fail.
|
||||
},
|
||||
'object properties are validated'
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('object with regexes', function (t) {
|
||||
t.plan(1);
|
||||
t.throws(
|
||||
function () { throw err; },
|
||||
{
|
||||
// The `name` and `message` properties are strings and using regular
|
||||
// expressions on those will match against the string. If they fail, an
|
||||
// error is thrown.
|
||||
name: /^TypeError$/,
|
||||
message: /Wrong/,
|
||||
foo: 'bar',
|
||||
info: {
|
||||
nested: true,
|
||||
// It is not possible to use regular expressions for nested properties!
|
||||
baz: 'text'
|
||||
},
|
||||
// The `reg` property contains a regular expression and only if the
|
||||
// validation object contains an identical regular expression, it is going
|
||||
// to pass.
|
||||
reg: /abc/i
|
||||
},
|
||||
'object with regex values is validated'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('similar error object', function (t) {
|
||||
t.plan(1);
|
||||
t.throws(
|
||||
function () {
|
||||
var otherErr = new TypeError('Not found');
|
||||
// Copy all enumerable properties from `err` to `otherErr`.
|
||||
assign(otherErr, err);
|
||||
throw otherErr;
|
||||
},
|
||||
// The error's `message` and `name` properties will also be checked when using
|
||||
// an error as validation object.
|
||||
err,
|
||||
'throwing a similar error'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('validate with regex', function (t) {
|
||||
t.plan(1);
|
||||
t.throws(
|
||||
function () { throw new Error('Wrong value'); },
|
||||
/^Error: Wrong value$/,
|
||||
'regex against toString of error'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('custom error validation', function (t) {
|
||||
t.plan(3);
|
||||
t.throws(
|
||||
function () { throw new SyntaxError('Wrong value'); },
|
||||
function (error) {
|
||||
t.ok(error instanceof SyntaxError, 'error is SyntaxError');
|
||||
t.ok((/value/).test(error), 'error matches /value/');
|
||||
// Avoid returning anything from validation functions besides `true`.
|
||||
// Otherwise, it's not clear what part of the validation failed. Instead,
|
||||
// throw an error about the specific validation that failed (as done in this
|
||||
// example) and add as much helpful debugging information to that error as
|
||||
// possible.
|
||||
return true;
|
||||
},
|
||||
'unexpected error'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('throwing primitives', function (t) {
|
||||
[null, undefined, 0, NaN, 42, Infinity, '', 'foo', true, false].forEach(function (primitive) {
|
||||
t.throws(function () { throw primitive; }, 'primitive: ' + inspect(primitive));
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('ambiguous arguments', function (t) {
|
||||
function throwingFirst() {
|
||||
throw new Error('First');
|
||||
}
|
||||
|
||||
function throwingSecond() {
|
||||
throw new Error('Second');
|
||||
}
|
||||
|
||||
function notThrowing() {}
|
||||
|
||||
// The second argument is a string and the input function threw an Error.
|
||||
// The first case will not throw as it does not match for the error message
|
||||
// thrown by the input function!
|
||||
t.throws(throwingFirst, 'Second');
|
||||
// In the next example the message has no benefit over the message from the
|
||||
// error and since it is not clear if the user intended to actually match
|
||||
// against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error.
|
||||
t.throws(throwingSecond, 'Second');
|
||||
// TypeError [ERR_AMBIGUOUS_ARGUMENT]
|
||||
|
||||
// The string is only used (as message) in case the function does not throw:
|
||||
t.doesNotThrow(notThrowing, 'Second');
|
||||
// AssertionError [ERR_ASSERTION]: Missing expected exception: Second
|
||||
|
||||
// If it was intended to match for the error message do this instead:
|
||||
// It does not fail because the error messages match.
|
||||
t.throws(throwingSecond, /Second$/);
|
||||
|
||||
// If the error message does not match, an AssertionError is thrown.
|
||||
t.throws(throwingFirst, /Second$/);
|
||||
// AssertionError [ERR_ASSERTION]
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
17
tests/node_modules/tape/test/timeout.js
generated
vendored
Normal file
17
tests/node_modules/tape/test/timeout.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('../');
|
||||
var ran = 0;
|
||||
|
||||
test('timeout', function (t) {
|
||||
t.pass('this should run');
|
||||
ran++;
|
||||
setTimeout(function () {
|
||||
t.end();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
test('should still run', { timeout: 50 }, function (t) {
|
||||
t.equal(ran, 1);
|
||||
t.end();
|
||||
});
|
||||
101
tests/node_modules/tape/test/timeoutAfter.js
generated
vendored
Normal file
101
tests/node_modules/tape/test/timeoutAfter.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
'use strict';
|
||||
|
||||
var tape = require('../');
|
||||
var tap = require('tap');
|
||||
var concat = require('concat-stream');
|
||||
|
||||
var stripFullStack = require('./common').stripFullStack;
|
||||
|
||||
tap.test('timeoutAfter test', function (tt) {
|
||||
tt.plan(1);
|
||||
|
||||
var test = tape.createHarness();
|
||||
var tc = function (rows) {
|
||||
tt.same(stripFullStack(rows.toString('utf8')), [
|
||||
'TAP version 13',
|
||||
'# timeoutAfter',
|
||||
'not ok 1 timeoutAfter timed out after 1ms',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' stack: |-',
|
||||
' Error: timeoutAfter timed out after 1ms',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'',
|
||||
'1..1',
|
||||
'# tests 1',
|
||||
'# pass 0',
|
||||
'# fail 1',
|
||||
''
|
||||
]);
|
||||
};
|
||||
|
||||
test.createStream().pipe(concat(tc));
|
||||
|
||||
test('timeoutAfter', function (t) {
|
||||
t.plan(1);
|
||||
t.timeoutAfter(1);
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('timeoutAfter with Promises', { skip: typeof Promise === 'undefined' }, function (tt) {
|
||||
tt.plan(1);
|
||||
|
||||
var test = tape.createHarness();
|
||||
var tc = function (rows) {
|
||||
tt.same(stripFullStack(rows.toString('utf8')), [
|
||||
'TAP version 13',
|
||||
'# timeoutAfter with promises',
|
||||
'# fulfilled promise',
|
||||
'not ok 1 fulfilled promise timed out after 1ms',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' stack: |-',
|
||||
' Error: fulfilled promise timed out after 1ms',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'# rejected promise',
|
||||
'not ok 2 rejected promise timed out after 1ms',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' stack: |-',
|
||||
' Error: rejected promise timed out after 1ms',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'',
|
||||
'1..2',
|
||||
'# tests 2',
|
||||
'# pass 0',
|
||||
'# fail 2',
|
||||
''
|
||||
]);
|
||||
};
|
||||
|
||||
test.createStream().pipe(concat(tc));
|
||||
|
||||
test('timeoutAfter with promises', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
t.test('fulfilled promise', function (st) {
|
||||
st.plan(1);
|
||||
st.timeoutAfter(1);
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
setTimeout(function () {
|
||||
resolve();
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
|
||||
t.test('rejected promise', function (st) {
|
||||
st.plan(1);
|
||||
st.timeoutAfter(1);
|
||||
|
||||
return new Promise(function (reject) {
|
||||
setTimeout(function () {
|
||||
reject();
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
44
tests/node_modules/tape/test/todo.js
generated
vendored
Normal file
44
tests/node_modules/tape/test/todo.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
var tap = require('tap');
|
||||
var tape = require('../');
|
||||
var concat = require('concat-stream');
|
||||
|
||||
var common = require('./common');
|
||||
var stripFullStack = common.stripFullStack;
|
||||
|
||||
tap.test('tape todo 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',
|
||||
'# success',
|
||||
'ok 1 this test runs',
|
||||
'# TODO failure',
|
||||
'not ok 2 should never happen # TODO',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' at: Test.<anonymous> ($TEST/todo.js:$LINE:$COL)',
|
||||
' ...',
|
||||
'',
|
||||
'1..2',
|
||||
'# tests 2',
|
||||
'# pass 2',
|
||||
'',
|
||||
'# ok',
|
||||
''
|
||||
]);
|
||||
}));
|
||||
|
||||
test('success', function (t) {
|
||||
t.equal(true, true, 'this test runs');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('failure', { todo: true }, function (t) {
|
||||
t.fail('should never happen');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
72
tests/node_modules/tape/test/todo_explanation.js
generated
vendored
Normal file
72
tests/node_modules/tape/test/todo_explanation.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
'use strict';
|
||||
|
||||
var tap = require('tap');
|
||||
var tape = require('../');
|
||||
var concat = require('concat-stream');
|
||||
|
||||
var common = require('./common');
|
||||
var stripFullStack = common.stripFullStack;
|
||||
|
||||
tap.test('tape todo test', { todo: process.versions.node.match(/0\.8\.\d+/) ? 'Fails on node 0.8': false }, function (assert) {
|
||||
var test = tape.createHarness({ exit: false });
|
||||
assert.plan(1);
|
||||
|
||||
test.createStream().pipe(concat(function (body) {
|
||||
assert.deepEqual(
|
||||
stripFullStack(body.toString('utf8')), [
|
||||
'TAP version 13',
|
||||
'# success',
|
||||
'ok 1 this test runs',
|
||||
'# TODO incomplete test1',
|
||||
'not ok 2 check output # TODO',
|
||||
' ---',
|
||||
' operator: equal',
|
||||
' expected: false',
|
||||
' actual: true',
|
||||
' at: Test.<anonymous> ($TEST/todo_explanation.js:$LINE:$COL)',
|
||||
' ...',
|
||||
'not ok 3 check vars output # TODO name conflict',
|
||||
' ---',
|
||||
' operator: equal',
|
||||
' expected: 0',
|
||||
' actual: 1',
|
||||
' at: Test.<anonymous> ($TEST/todo_explanation.js:$LINE:$COL)',
|
||||
' ...',
|
||||
'# incomplete test2',
|
||||
'not ok 4 run openssl # TODO installer needs fix',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' at: Test.<anonymous> ($TEST/todo_explanation.js:$LINE:$COL)',
|
||||
' ...',
|
||||
'# TODO passing test',
|
||||
'',
|
||||
'1..4',
|
||||
'# tests 4',
|
||||
'# pass 4',
|
||||
'',
|
||||
'# ok',
|
||||
''
|
||||
]
|
||||
);
|
||||
}));
|
||||
|
||||
test('success', function (t) {
|
||||
t.equal(true, true, 'this test runs');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('incomplete test1', { todo: true }, function (t) {
|
||||
t.equal(true, false, 'check output');
|
||||
t.equal(1, 0, 'check vars output', { todo: 'name conflict' });
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('incomplete test2', function (t) {
|
||||
t.fail('run openssl', { todo: 'installer needs fix' });
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('passing test', { todo: 'yet incomplete' }, function (t) {
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
39
tests/node_modules/tape/test/todo_single.js
generated
vendored
Normal file
39
tests/node_modules/tape/test/todo_single.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
var tap = require('tap');
|
||||
var tape = require('../');
|
||||
var concat = require('concat-stream');
|
||||
|
||||
var common = require('./common');
|
||||
var stripFullStack = common.stripFullStack;
|
||||
|
||||
tap.test('tape todo 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',
|
||||
'# TODO failure',
|
||||
'not ok 1 should be strictly equal # TODO',
|
||||
' ---',
|
||||
' operator: equal',
|
||||
' expected: false',
|
||||
' actual: true',
|
||||
' at: Test.<anonymous> ($TEST/todo_single.js:$LINE:$COL)',
|
||||
' ...',
|
||||
'',
|
||||
'1..1',
|
||||
'# tests 1',
|
||||
'# pass 1',
|
||||
'',
|
||||
'# ok',
|
||||
''
|
||||
]);
|
||||
}));
|
||||
|
||||
test('failure', { todo: true }, function (t) {
|
||||
t.equal(true, false);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
81
tests/node_modules/tape/test/too_many.js
generated
vendored
Normal file
81
tests/node_modules/tape/test/too_many.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
'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 plan != count',
|
||||
' ---',
|
||||
' operator: fail',
|
||||
' expected: 3',
|
||||
' actual: 4',
|
||||
' at: <anonymous> ($TEST/too_many.js:$LINE:$COL)',
|
||||
' stack: |-',
|
||||
' Error: plan != count',
|
||||
' [... stack stripped ...]',
|
||||
' at $TEST/too_many.js:$LINE:$COL',
|
||||
' at eval (eval at <anonymous> ($TEST/too_many.js:$LINE:$COL))',
|
||||
' at eval (eval at <anonymous> ($TEST/too_many.js:$LINE:$COL))',
|
||||
' at Test.<anonymous> ($TEST/too_many.js:$LINE:$COL)',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'ok 6 should be deeply equivalent',
|
||||
'',
|
||||
'1..6',
|
||||
'# tests 6',
|
||||
'# pass 5',
|
||||
'# fail 1',
|
||||
''
|
||||
]);
|
||||
};
|
||||
|
||||
test.createStream().pipe(concat(tc));
|
||||
|
||||
test('array', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var src = '(' + function () {
|
||||
var xs = [ 1, 2, [ 3, 4 ] ];
|
||||
var ys = [ 5, 6 ];
|
||||
g([ xs, ys ]);
|
||||
} + ')()';
|
||||
|
||||
var output = falafel(src, function (node) {
|
||||
if (node.type === 'ArrayExpression') {
|
||||
node.update('fn(' + node.source() + ')');
|
||||
}
|
||||
});
|
||||
|
||||
var arrays = [
|
||||
[ 3, 4 ],
|
||||
[ 1, 2, [ 3, 4 ] ],
|
||||
[ 5, 6 ],
|
||||
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]
|
||||
];
|
||||
|
||||
Function(['fn','g'], output)(
|
||||
function (xs) {
|
||||
t.same(arrays.shift(), xs);
|
||||
return xs;
|
||||
},
|
||||
function (xs) {
|
||||
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
44
tests/node_modules/tape/test/undef.js
generated
vendored
Normal file
44
tests/node_modules/tape/test/undef.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
'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();
|
||||
test.createStream().pipe(concat(function (body) {
|
||||
tt.same(stripFullStack(body.toString('utf8')), [
|
||||
'TAP version 13',
|
||||
'# undef',
|
||||
'not ok 1 should be deeply equivalent',
|
||||
' ---',
|
||||
' operator: deepEqual',
|
||||
' expected: |-',
|
||||
' { beep: undefined }',
|
||||
' actual: |-',
|
||||
' {}',
|
||||
' at: Test.<anonymous> ($TEST/undef.js:$LINE:$COL)',
|
||||
' stack: |-',
|
||||
' Error: should be deeply equivalent',
|
||||
' [... stack stripped ...]',
|
||||
' at Test.<anonymous> ($TEST/undef.js:$LINE:$COL)',
|
||||
' [... stack stripped ...]',
|
||||
' ...',
|
||||
'',
|
||||
'1..1',
|
||||
'# tests 1',
|
||||
'# pass 0',
|
||||
'# fail 1',
|
||||
''
|
||||
]);
|
||||
}));
|
||||
|
||||
test('undef', function (t) {
|
||||
t.plan(1);
|
||||
t.deepEqual({}, { beep: undefined });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user