diff --git a/test/anonymous-fn.js b/test/anonymous-fn.js index a402eb9c..f28c4340 100644 --- a/test/anonymous-fn.js +++ b/test/anonymous-fn.js @@ -30,8 +30,9 @@ tap.test('inside anonymous functions', function (tt) { '1..1', '# tests 1', '# pass 0', - '# fail 1' - ].join('\n') + '\n'); + '# fail 1', + '' + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/circular-things.js b/test/circular-things.js index dcab2b12..46562e1a 100644 --- a/test/circular-things.js +++ b/test/circular-things.js @@ -9,30 +9,30 @@ tap.test('circular test', function (assert) { assert.plan(1); test.createStream().pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# circular\n' - + 'not ok 1 should be equal\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' {}\n' - + ' actual: |-\n' - + ' { circular: [Circular] }\n' - + ' at: Test. ($TEST/circular-things.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should be equal\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/circular-things.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# circular', + 'not ok 1 should be equal', + ' ---', + ' operator: equal', + ' expected: |-', + ' {}', + ' actual: |-', + ' { circular: [Circular] }', + ' at: Test. ($TEST/circular-things.js:$LINE:$COL)', + ' stack: |-', + ' Error: should be equal', + ' [... stack stripped ...]', + ' at Test. ($TEST/circular-things.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); })); test('circular', function (t) { diff --git a/test/common.js b/test/common.js index 0ddc4312..3f6bab84 100644 --- a/test/common.js +++ b/test/common.js @@ -65,5 +65,5 @@ module.exports.stripFullStack = function (output) { // Handle stack trace variation in Node v0.8 /at(:?) Test\.(?:module\.exports|tap\.test\.err\.code)/g, 'at$1 Test.' - ); + ).split('\n'); }; diff --git a/test/deep-equal-failure.js b/test/deep-equal-failure.js index e1f2659e..b086d2c3 100644 --- a/test/deep-equal-failure.js +++ b/test/deep-equal-failure.js @@ -15,30 +15,30 @@ tap.test('deep equal failure', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# deep equal\n' - + 'not ok 1 should be equal\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' { b: 2 }\n' - + ' actual: |-\n' - + ' { a: 1 }\n' - + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should be equal\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# deep equal', + 'not ok 1 should be equal', + ' ---', + ' operator: equal', + ' expected: |-', + ' { b: 2 }', + ' actual: |-', + ' { a: 1 }', + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should be equal', + ' [... stack stripped ...]', + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'equal', @@ -76,30 +76,30 @@ tap.test('deep equal failure, depth 6, with option', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# deep equal\n' - + 'not ok 1 should be equal\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }\n' - + ' actual: |-\n' - + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n' - + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should be equal\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# deep equal', + 'not ok 1 should be equal', + ' ---', + ' operator: equal', + ' expected: |-', + ' { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }', + ' actual: |-', + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }', + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should be equal', + ' [... stack stripped ...]', + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'equal', @@ -137,30 +137,30 @@ tap.test('deep equal failure, depth 6, without option', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# deep equal\n' - + 'not ok 1 should be equal\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n' - + ' actual: |-\n' - + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n' - + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should be equal\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# deep equal', + 'not ok 1 should be equal', + ' ---', + ' operator: equal', + ' expected: |-', + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }', + ' actual: |-', + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }', + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should be equal', + ' [... stack stripped ...]', + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'equal', diff --git a/test/default-messages.js b/test/default-messages.js index 5651a8ec..799bb2f7 100644 --- a/test/default-messages.js +++ b/test/default-messages.js @@ -13,7 +13,6 @@ tap.test('default messages', function (t) { 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', @@ -44,7 +43,9 @@ tap.test('default messages', function (t) { '1..12', '# tests 12', '# pass 11', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); })); }); diff --git a/test/double_end.js b/test/double_end.js index b2fbc5b9..ff4618b3 100644 --- a/test/double_end.js +++ b/test/double_end.js @@ -29,14 +29,13 @@ test(function (t) { to._onTimeout(); } catch (e) { - stackExpected = stripFullStack(e.stack).split('\n')[1]; + 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')); - t.equal(stripped, [ + t.same(stripFullStack(body.toString('utf8')), [ 'TAP version 13', '# double end', 'ok 1 should be equal', @@ -55,6 +54,8 @@ test(function (t) { '# tests 2', '# pass 1', '# fail 1', - ].join('\n') + '\n\n'); + '', + '' + ]); })); }); diff --git a/test/edge-cases.js b/test/edge-cases.js index 96da8548..78ea70d6 100644 --- a/test/edge-cases.js +++ b/test/edge-cases.js @@ -11,231 +11,232 @@ tap.test('edge cases', function (tt) { var test = tape.createHarness(); test.createStream().pipe(concat(function (body) { - tt.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# zeroes\n' - + 'ok 1 0 equal to -0\n' - + 'ok 2 -0 equal to 0\n' - + 'not ok 3 0 notEqual to -0\n' - + ' ---\n' - + ' operator: notEqual\n' - + ' expected: |-\n' - + ' -0\n' - + ' actual: |-\n' - + ' 0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: 0 notEqual to -0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 4 -0 notEqual to 0\n' - + ' ---\n' - + ' operator: notEqual\n' - + ' expected: |-\n' - + ' 0\n' - + ' actual: |-\n' - + ' -0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: -0 notEqual to 0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 5 0 looseEqual to -0\n' - + 'ok 6 -0 looseEqual to 0\n' - + 'not ok 7 0 notLooseEqual to -0\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: |-\n' - + ' -0\n' - + ' actual: |-\n' - + ' 0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: 0 notLooseEqual to -0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 8 -0 notLooseEqual to 0\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: |-\n' - + ' 0\n' - + ' actual: |-\n' - + ' -0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: -0 notLooseEqual to 0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 9 0 strictEqual to -0\n' - + 'ok 10 -0 strictEqual to 0\n' - + 'not ok 11 0 notStrictEqual to -0\n' - + ' ---\n' - + ' operator: notEqual\n' - + ' expected: |-\n' - + ' -0\n' - + ' actual: |-\n' - + ' 0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: 0 notStrictEqual to -0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 12 -0 notStrictEqual to 0\n' - + ' ---\n' - + ' operator: notEqual\n' - + ' expected: |-\n' - + ' 0\n' - + ' actual: |-\n' - + ' -0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: -0 notStrictEqual to 0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 13 0 deepLooseEqual to -0\n' - + 'ok 14 -0 deepLooseEqual to 0\n' - + 'not ok 15 0 notDeepLooseEqual to -0\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: |-\n' - + ' -0\n' - + ' actual: |-\n' - + ' 0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: 0 notDeepLooseEqual to -0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 16 -0 notDeepLooseEqual to 0\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: |-\n' - + ' 0\n' - + ' actual: |-\n' - + ' -0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: -0 notDeepLooseEqual to 0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 17 0 deepEqual to -0\n' - + ' ---\n' - + ' operator: deepEqual\n' - + ' expected: |-\n' - + ' -0\n' - + ' actual: |-\n' - + ' 0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: 0 deepEqual to -0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 18 -0 deepEqual to 0\n' - + ' ---\n' - + ' operator: deepEqual\n' - + ' expected: |-\n' - + ' 0\n' - + ' actual: |-\n' - + ' -0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: -0 deepEqual to 0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 19 0 notDeepEqual to -0\n' - + 'ok 20 -0 notDeepEqual to 0\n' - + '# NaNs\n' - + 'not ok 21 NaN equal to NaN\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: NaN\n' - + ' actual: NaN\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: NaN equal to NaN\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 22 NaN notEqual to NaN\n' - + 'not ok 23 NaN looseEqual to NaN\n' - + ' ---\n' - + ' operator: deepLooseEqual\n' - + ' expected: NaN\n' - + ' actual: NaN\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: NaN looseEqual to NaN\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 24 NaN notLooseEqual to NaN\n' - + 'not ok 25 NaN strictEqual to NaN\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: NaN\n' - + ' actual: NaN\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: NaN strictEqual to NaN\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 26 NaN notStrictEqual to NaN\n' - + 'not ok 27 NaN deepLooseEqual to NaN\n' - + ' ---\n' - + ' operator: deepLooseEqual\n' - + ' expected: NaN\n' - + ' actual: NaN\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: NaN deepLooseEqual to NaN\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 28 NaN notDeepLooseEqual to NaN\n' - + 'ok 29 NaN deepEqual to NaN\n' - + 'not ok 30 NaN notDeepEqual to NaN\n' - + ' ---\n' - + ' operator: notDeepEqual\n' - + ' expected: NaN\n' - + ' actual: NaN\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: NaN notDeepEqual to NaN\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n1..30\n' - + '# tests 30\n' - + '# pass 15\n' - + '# fail 15\n' - ); + tt.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# zeroes', + 'ok 1 0 equal to -0', + 'ok 2 -0 equal to 0', + 'not ok 3 0 notEqual to -0', + ' ---', + ' operator: notEqual', + ' expected: |-', + ' -0', + ' actual: |-', + ' 0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: 0 notEqual to -0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 4 -0 notEqual to 0', + ' ---', + ' operator: notEqual', + ' expected: |-', + ' 0', + ' actual: |-', + ' -0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: -0 notEqual to 0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 5 0 looseEqual to -0', + 'ok 6 -0 looseEqual to 0', + 'not ok 7 0 notLooseEqual to -0', + ' ---', + ' operator: notDeepLooseEqual', + ' expected: |-', + ' -0', + ' actual: |-', + ' 0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: 0 notLooseEqual to -0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 8 -0 notLooseEqual to 0', + ' ---', + ' operator: notDeepLooseEqual', + ' expected: |-', + ' 0', + ' actual: |-', + ' -0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: -0 notLooseEqual to 0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 9 0 strictEqual to -0', + 'ok 10 -0 strictEqual to 0', + 'not ok 11 0 notStrictEqual to -0', + ' ---', + ' operator: notEqual', + ' expected: |-', + ' -0', + ' actual: |-', + ' 0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: 0 notStrictEqual to -0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 12 -0 notStrictEqual to 0', + ' ---', + ' operator: notEqual', + ' expected: |-', + ' 0', + ' actual: |-', + ' -0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: -0 notStrictEqual to 0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '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. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: 0 notDeepLooseEqual to -0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 16 -0 notDeepLooseEqual to 0', + ' ---', + ' operator: notDeepLooseEqual', + ' expected: |-', + ' 0', + ' actual: |-', + ' -0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: -0 notDeepLooseEqual to 0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 17 0 deepEqual to -0', + ' ---', + ' operator: deepEqual', + ' expected: |-', + ' -0', + ' actual: |-', + ' 0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: 0 deepEqual to -0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 18 -0 deepEqual to 0', + ' ---', + ' operator: deepEqual', + ' expected: |-', + ' 0', + ' actual: |-', + ' -0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: -0 deepEqual to 0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 19 0 notDeepEqual to -0', + 'ok 20 -0 notDeepEqual to 0', + '# NaNs', + 'not ok 21 NaN equal to NaN', + ' ---', + ' operator: equal', + ' expected: NaN', + ' actual: NaN', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: NaN equal to NaN', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 22 NaN notEqual to NaN', + 'not ok 23 NaN looseEqual to NaN', + ' ---', + ' operator: deepLooseEqual', + ' expected: NaN', + ' actual: NaN', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: NaN looseEqual to NaN', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 24 NaN notLooseEqual to NaN', + 'not ok 25 NaN strictEqual to NaN', + ' ---', + ' operator: equal', + ' expected: NaN', + ' actual: NaN', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: NaN strictEqual to NaN', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 26 NaN notStrictEqual to NaN', + 'not ok 27 NaN deepLooseEqual to NaN', + ' ---', + ' operator: deepLooseEqual', + ' expected: NaN', + ' actual: NaN', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: NaN deepLooseEqual to NaN', + ' [... stack stripped ...]', + ' at Test. ($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. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: NaN notDeepEqual to NaN', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..30', + '# tests 30', + '# pass 15', + '# fail 15', + '' + ]); })); test('zeroes', function (t) { diff --git a/test/error.js b/test/error.js new file mode 100644 index 00000000..83e80100 --- /dev/null +++ b/test/error.js @@ -0,0 +1,43 @@ +'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', + ' expected: |-', + ' undefined', + ' actual: |-', + ' [Error: this is a message]', + ' at: Test. ($TEST/error.js:$LINE:$COL)', + ' stack: |-', + ' Error: this is a message', + ' at Test. ($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')); + }); +}); diff --git a/test/exit.js b/test/exit.js index 4ba1f9a5..80ef8ad5 100644 --- a/test/exit.js +++ b/test/exit.js @@ -66,8 +66,10 @@ tap.test('exit fail', function (t) { '1..5', '# tests 5', '# pass 4', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, 'exit', 'fail.js')]); @@ -103,8 +105,10 @@ tap.test('too few exit', function (t) { '1..6', '# tests 6', '# pass 5', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, '/exit/too_few.js')]); @@ -138,8 +142,10 @@ tap.test('more planned in a second test', function (t) { '1..3', '# tests 3', '# pass 2', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, '/exit/second.js')]); @@ -162,8 +168,10 @@ tap.test('todo passing', function (t) { '# tests 1', '# pass 1', '', - '# ok' - ].join('\n') + '\n\n'); + '# ok', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, '/exit/todo.js')]); @@ -192,8 +200,10 @@ tap.test('todo failing', function (t) { '# tests 1', '# pass 1', '', - '# ok' - ].join('\n') + '\n\n'); + '# ok', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, '/exit/todo_fail.js')]); @@ -225,8 +235,10 @@ tap.test('forgot to call t.end()', function (t) { '1..3', '# tests 3', '# pass 2', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, '/exit/missing_end.js')]); diff --git a/test/fail.js b/test/fail.js index 580e40a0..45df8d66 100644 --- a/test/fail.js +++ b/test/fail.js @@ -38,7 +38,7 @@ tap.test('array test', function (tt) { '# pass 4', '# fail 1', '' - ].join('\n')); + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/has spaces.js b/test/has spaces.js index f8630de3..3e8c80db 100644 --- a/test/has spaces.js +++ b/test/has spaces.js @@ -28,7 +28,7 @@ tap.test('array test', function (tt) { '# pass 0', '# fail 1', '' - ].join('\n')); + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/ignore_from_gitignore.js b/test/ignore_from_gitignore.js index 16b076a4..d95260b8 100644 --- a/test/ignore_from_gitignore.js +++ b/test/ignore_from_gitignore.js @@ -35,7 +35,7 @@ tap.test('Should pass with ignoring', { skip: process.platform === 'win32' }, fu '# ok', '', '' - ].join('\n')); + ]); }; var ps = spawn(tapeBin, ['**/*.js', '-i', '.ignore'], {cwd: path.join(__dirname, 'ignore')}); @@ -92,7 +92,7 @@ tap.test('Should pass', { skip: process.platform === 'win32' }, function (tt) { '# fail 2', '', '' - ].join('\n')); + ]); }; var ps = spawn(tapeBin, ['**/*.js'], {cwd: path.join(__dirname, 'ignore')}); @@ -110,7 +110,7 @@ tap.test('Should fail when ignore file does not exist', { skip: process.platform }; var testStderr = function (rows) { - tt.ok(/^ENOENT[:,] no such file or directory,? (?:open )?'\$TEST\/ignore\/.gitignore'\n$/m.test(stripFullStack(rows.toString('utf8')))); + 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')}); diff --git a/test/match.js b/test/match.js index 09ccd343..b598b9db 100644 --- a/test/match.js +++ b/test/match.js @@ -48,7 +48,7 @@ tap.test('match', function (tt) { '# pass 4', '# fail 2', '' - ].join('\n')); + ]); }; test.createStream().pipe(concat(tc)); @@ -142,7 +142,7 @@ tap.test('doesNotMatch', function (tt) { '# pass 2', '# fail 4', '' - ].join('\n')); + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/not-deep-equal-failure.js b/test/not-deep-equal-failure.js index 63fbd614..5ac49cc9 100644 --- a/test/not-deep-equal-failure.js +++ b/test/not-deep-equal-failure.js @@ -15,30 +15,30 @@ tap.test('deep equal failure', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# not deep equal\n' - + 'not ok 1 should not be equivalent\n' - + ' ---\n' - + ' operator: notDeepEqual\n' - + ' expected: |-\n' - + ' { b: 2 }\n' - + ' actual: |-\n' - + ' { b: 2 }\n' - + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should not be equivalent\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# not deep equal', + 'not ok 1 should not be equivalent', + ' ---', + ' operator: notDeepEqual', + ' expected: |-', + ' { b: 2 }', + ' actual: |-', + ' { b: 2 }', + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should not be equivalent', + ' [... stack stripped ...]', + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'notDeepEqual', @@ -76,30 +76,30 @@ tap.test('not deep equal failure, depth 6, with option', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# not deep equal\n' - + 'not ok 1 should not be equivalent\n' - + ' ---\n' - + ' operator: notDeepEqual\n' - + ' expected: |-\n' - + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n' - + ' actual: |-\n' - + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n' - + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should not be equivalent\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# not deep equal', + 'not ok 1 should not be equivalent', + ' ---', + ' operator: notDeepEqual', + ' expected: |-', + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }', + ' actual: |-', + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }', + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should not be equivalent', + ' [... stack stripped ...]', + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'notDeepEqual', @@ -137,30 +137,30 @@ tap.test('not deep equal failure, depth 6, without option', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# not deep equal\n' - + 'not ok 1 should not be equivalent\n' - + ' ---\n' - + ' operator: notDeepEqual\n' - + ' expected: |-\n' - + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n' - + ' actual: |-\n' - + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n' - + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should not be equivalent\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# not deep equal', + 'not ok 1 should not be equivalent', + ' ---', + ' operator: notDeepEqual', + ' expected: |-', + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }', + ' actual: |-', + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }', + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should not be equivalent', + ' [... stack stripped ...]', + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'notDeepEqual', diff --git a/test/not-equal-failure.js b/test/not-equal-failure.js index 28e31a65..bb7f9167 100644 --- a/test/not-equal-failure.js +++ b/test/not-equal-failure.js @@ -15,28 +15,28 @@ tap.test('not equal failure', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# not equal\n' - + 'not ok 1 should not be equal\n' - + ' ---\n' - + ' operator: notEqual\n' - + ' expected: 2\n' - + ' actual: 2\n' - + ' at: Test. ($TEST/not-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should not be equal\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/not-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# not equal', + 'not ok 1 should not be equal', + ' ---', + ' operator: notEqual', + ' expected: 2', + ' actual: 2', + ' at: Test. ($TEST/not-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should not be equal', + ' [... stack stripped ...]', + ' at Test. ($TEST/not-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'notEqual', diff --git a/test/numerics.js b/test/numerics.js index a425de4d..b4e7ef32 100644 --- a/test/numerics.js +++ b/test/numerics.js @@ -11,145 +11,146 @@ tap.test('numerics', function (tt) { var test = tape.createHarness(); test.createStream().pipe(concat(function (body) { - tt.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# numeric strings\n' - + 'not ok 1 number equal to string\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: \'3\'\n' - + ' actual: 3\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: number equal to string\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 2 string equal to number\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: 3\n' - + ' actual: \'3\'\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: string equal to number\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 3 number notEqual to string\n' - + 'ok 4 string notEqual to number\n' - + 'ok 5 number looseEqual to string\n' - + 'ok 6 string looseEqual to number\n' - + 'not ok 7 number notLooseEqual to string\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: \'3\'\n' - + ' actual: 3\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: number notLooseEqual to string\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 8 string notLooseEqual to number\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: 3\n' - + ' actual: \'3\'\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: string notLooseEqual to number\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 9 number strictEqual to string\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: \'3\'\n' - + ' actual: 3\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: number strictEqual to string\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 10 string strictEqual to number\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: 3\n' - + ' actual: \'3\'\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: string strictEqual to number\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 11 number notStrictEqual to string\n' - + 'ok 12 string notStrictEqual to number\n' - + 'ok 13 number deepLooseEqual to string\n' - + 'ok 14 string deepLooseEqual to number\n' - + 'not ok 15 number notDeepLooseEqual to string\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: \'3\'\n' - + ' actual: 3\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: number notDeepLooseEqual to string\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 16 string notDeepLooseEqual to number\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: 3\n' - + ' actual: \'3\'\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: string notDeepLooseEqual to number\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 17 number deepEqual to string\n' - + ' ---\n' - + ' operator: deepEqual\n' - + ' expected: \'3\'\n' - + ' actual: 3\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: number deepEqual to string\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 18 string deepEqual to number\n' - + ' ---\n' - + ' operator: deepEqual\n' - + ' expected: 3\n' - + ' actual: \'3\'\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: string deepEqual to number\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 19 number notDeepEqual to string\n' - + 'ok 20 string notDeepEqual to number\n' - + '\n1..20\n' - + '# tests 20\n' - + '# pass 10\n' - + '# fail 10\n' - ); + 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. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: number equal to string', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 2 string equal to number', + ' ---', + ' operator: equal', + ' expected: 3', + ' actual: \'3\'', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: string equal to number', + ' [... stack stripped ...]', + ' at Test. ($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: notDeepLooseEqual', + ' expected: \'3\'', + ' actual: 3', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: number notLooseEqual to string', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 8 string notLooseEqual to number', + ' ---', + ' operator: notDeepLooseEqual', + ' expected: 3', + ' actual: \'3\'', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: string notLooseEqual to number', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 9 number strictEqual to string', + ' ---', + ' operator: equal', + ' expected: \'3\'', + ' actual: 3', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: number strictEqual to string', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 10 string strictEqual to number', + ' ---', + ' operator: equal', + ' expected: 3', + ' actual: \'3\'', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: string strictEqual to number', + ' [... stack stripped ...]', + ' at Test. ($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. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: number notDeepLooseEqual to string', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 16 string notDeepLooseEqual to number', + ' ---', + ' operator: notDeepLooseEqual', + ' expected: 3', + ' actual: \'3\'', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: string notDeepLooseEqual to number', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 17 number deepEqual to string', + ' ---', + ' operator: deepEqual', + ' expected: \'3\'', + ' actual: 3', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: number deepEqual to string', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 18 string deepEqual to number', + ' ---', + ' operator: deepEqual', + ' expected: 3', + ' actual: \'3\'', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: string deepEqual to number', + ' [... stack stripped ...]', + ' at Test. ($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) { diff --git a/test/skip_explanation.js b/test/skip_explanation.js index 09928ffa..1752dcfd 100644 --- a/test/skip_explanation.js +++ b/test/skip_explanation.js @@ -7,7 +7,7 @@ tap.test('test skip explanations', function (assert) { assert.plan(1); var verify = function (output) { - assert.equal(stripFullStack(output.toString('utf8')), [ + assert.same(stripFullStack(output.toString('utf8')), [ 'TAP version 13', '# SKIP (this skips)', '# some tests might skip', @@ -30,7 +30,7 @@ tap.test('test skip explanations', function (assert) { '', '# ok', '' - ].join('\n')); + ]); }; var tapeTest = test.createHarness(); diff --git a/test/throws.js b/test/throws.js index 1628d822..5cad0334 100644 --- a/test/throws.js +++ b/test/throws.js @@ -29,160 +29,161 @@ tap.test('failures', function (tt) { var test = tape.createHarness(); test.createStream().pipe(concat(function (body) { - tt.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# non functions\n' - + 'not ok 1 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + ' { [TypeError: ' + getNonFunctionMessage() + "] message: '" + getNonFunctionMessage() + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage(undefined) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 2 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + ' { [TypeError: ' + getNonFunctionMessage(null) + "] message: '" + getNonFunctionMessage(null) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage(null) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 3 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + ' { [TypeError: ' + getNonFunctionMessage(true) + "] message: '" + getNonFunctionMessage(true) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage(true) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 4 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + ' { [TypeError: ' + getNonFunctionMessage(false) + "] message: '" + getNonFunctionMessage(false) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage(false) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 5 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + ' { [TypeError: ' + getNonFunctionMessage('abc') + "] message: '" + getNonFunctionMessage('abc') + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage('abc') + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 6 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + ' { [TypeError: ' + getNonFunctionMessage(/a/g) + "] message: '" + getNonFunctionMessage(/a/g) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage(/a/g) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 7 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + ' { [TypeError: ' + getNonFunctionMessage([]) + "] message: '" + getNonFunctionMessage([]) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage([]) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 8 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' undefined\n' - + ' actual: |-\n' - + ' { [TypeError: ' + getNonFunctionMessage({}) + "] message: '" + getNonFunctionMessage({}) + "' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' TypeError: ' + getNonFunctionMessage({}) + '\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '# function\n' - + 'not ok 9 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: undefined\n' - + ' actual: undefined\n' - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should throw\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '# custom error messages\n' - + 'ok 10 "message" is enumerable\n' - + "ok 11 { custom: 'error', message: 'message' }\n" - + 'ok 12 getter is still the same\n' - + '# throws null\n' - + 'ok 13 throws null\n' - + '# wrong type of error\n' - + 'not ok 14 throws actual\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' [Function: TypeError]\n' - + ' actual: |-\n' - + " { [RangeError: actual!] message: 'actual!' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' RangeError: actual!\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n1..14\n' - + '# tests 14\n' - + '# pass 4\n' - + '# fail 10\n' - ); + tt.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# non functions', + 'not ok 1 should throw', + ' ---', + ' operator: throws', + ' expected: |-', + ' undefined', + ' actual: |-', + ' { [TypeError: ' + getNonFunctionMessage() + "] message: '" + getNonFunctionMessage() + "' }", + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' TypeError: ' + getNonFunctionMessage(undefined) + '', + ' [... stack stripped ...]', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 2 should throw', + ' ---', + ' operator: throws', + ' expected: |-', + ' undefined', + ' actual: |-', + ' { [TypeError: ' + getNonFunctionMessage(null) + "] message: '" + getNonFunctionMessage(null) + "' }", + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' TypeError: ' + getNonFunctionMessage(null) + '', + ' [... stack stripped ...]', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 3 should throw', + ' ---', + ' operator: throws', + ' expected: |-', + ' undefined', + ' actual: |-', + ' { [TypeError: ' + getNonFunctionMessage(true) + "] message: '" + getNonFunctionMessage(true) + "' }", + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' TypeError: ' + getNonFunctionMessage(true) + '', + ' [... stack stripped ...]', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 4 should throw', + ' ---', + ' operator: throws', + ' expected: |-', + ' undefined', + ' actual: |-', + ' { [TypeError: ' + getNonFunctionMessage(false) + "] message: '" + getNonFunctionMessage(false) + "' }", + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' TypeError: ' + getNonFunctionMessage(false) + '', + ' [... stack stripped ...]', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 5 should throw', + ' ---', + ' operator: throws', + ' expected: |-', + ' undefined', + ' actual: |-', + ' { [TypeError: ' + getNonFunctionMessage('abc') + "] message: '" + getNonFunctionMessage('abc') + "' }", + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' TypeError: ' + getNonFunctionMessage('abc') + '', + ' [... stack stripped ...]', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 6 should throw', + ' ---', + ' operator: throws', + ' expected: |-', + ' undefined', + ' actual: |-', + ' { [TypeError: ' + getNonFunctionMessage(/a/g) + "] message: '" + getNonFunctionMessage(/a/g) + "' }", + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' TypeError: ' + getNonFunctionMessage(/a/g) + '', + ' [... stack stripped ...]', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 7 should throw', + ' ---', + ' operator: throws', + ' expected: |-', + ' undefined', + ' actual: |-', + ' { [TypeError: ' + getNonFunctionMessage([]) + "] message: '" + getNonFunctionMessage([]) + "' }", + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' TypeError: ' + getNonFunctionMessage([]) + '', + ' [... stack stripped ...]', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 8 should throw', + ' ---', + ' operator: throws', + ' expected: |-', + ' undefined', + ' actual: |-', + ' { [TypeError: ' + getNonFunctionMessage({}) + "] message: '" + getNonFunctionMessage({}) + "' }", + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' TypeError: ' + getNonFunctionMessage({}) + '', + ' [... stack stripped ...]', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '# function', + 'not ok 9 should throw', + ' ---', + ' operator: throws', + ' expected: undefined', + ' actual: undefined', + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' Error: should throw', + ' [... stack stripped ...]', + ' at Test. ($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. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' RangeError: actual!', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..14', + '# tests 14', + '# pass 4', + '# fail 10', + '' + ]); })); test('non functions', function (t) { diff --git a/test/timeoutAfter.js b/test/timeoutAfter.js index 5d198e2a..366b5d6f 100644 --- a/test/timeoutAfter.js +++ b/test/timeoutAfter.js @@ -23,8 +23,9 @@ tap.test('timeoutAfter test', function (tt) { '1..1', '# tests 1', '# pass 0', - '# fail 1' - ].join('\n') + '\n'); + '# fail 1', + '' + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/todo.js b/test/todo.js index 73a8f6a6..5b9351ee 100644 --- a/test/todo.js +++ b/test/todo.js @@ -10,24 +10,24 @@ tap.test('tape todo test', function (assert) { assert.plan(1); test.createStream().pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# success\n' - + 'ok 1 this test runs\n' - + '# TODO failure\n' - + 'not ok 2 should never happen # TODO\n' - + ' ---\n' - + ' operator: fail\n' - + ' at: Test. ($TEST/todo.js:$LINE:$COL)\n' - + ' ...\n' - + '\n' - + '1..2\n' - + '# tests 2\n' - + '# pass 2\n' - + '\n' - + '# ok\n' - ); + assert.same(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. ($TEST/todo.js:$LINE:$COL)', + ' ...', + '', + '1..2', + '# tests 2', + '# pass 2', + '', + '# ok', + '' + ]); })); test('success', function (t) { diff --git a/test/todo_explanation.js b/test/todo_explanation.js index 5269b08f..225d584f 100644 --- a/test/todo_explanation.js +++ b/test/todo_explanation.js @@ -10,42 +10,40 @@ tap.test('tape todo test', { todo: process.versions.node.match(/0\.8\.\d+/) ? 'F assert.plan(1); test.createStream().pipe(concat(function (body) { - assert.equal( - 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. ($TEST/todo_explanation.js:$LINE:$COL)', - ' ...', - 'not ok 3 check vars output # TODO name conflict', - ' ---', - ' operator: equal', - ' expected: 0', - ' actual: 1', - ' at: Test. ($TEST/todo_explanation.js:$LINE:$COL)', - ' ...', - '# incomplete test2', - 'not ok 4 run openssl # TODO installer needs fix', - ' ---', - ' operator: fail', - ' at: Test. ($TEST/todo_explanation.js:$LINE:$COL)', - ' ...', - '# TODO passing test', - '', - '1..4', - '# tests 4', - '# pass 4', - '', - '# ok', - '' - ].join('\n') - ); + assert.same(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. ($TEST/todo_explanation.js:$LINE:$COL)', + ' ...', + 'not ok 3 check vars output # TODO name conflict', + ' ---', + ' operator: equal', + ' expected: 0', + ' actual: 1', + ' at: Test. ($TEST/todo_explanation.js:$LINE:$COL)', + ' ...', + '# incomplete test2', + 'not ok 4 run openssl # TODO installer needs fix', + ' ---', + ' operator: fail', + ' at: Test. ($TEST/todo_explanation.js:$LINE:$COL)', + ' ...', + '# TODO passing test', + '', + '1..4', + '# tests 4', + '# pass 4', + '', + '# ok', + '' + ]); })); test('success', function (t) { diff --git a/test/todo_single.js b/test/todo_single.js index 48cd287e..0359bcfa 100644 --- a/test/todo_single.js +++ b/test/todo_single.js @@ -10,24 +10,24 @@ tap.test('tape todo test', function (assert) { assert.plan(1); test.createStream().pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# TODO failure\n' - + 'not ok 1 should be equal # TODO\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: false\n' - + ' actual: true\n' - + ' at: Test. ($TEST/todo_single.js:$LINE:$COL)\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 1\n' - + '\n' - + '# ok\n' - ); + assert.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# TODO failure', + 'not ok 1 should be equal # TODO', + ' ---', + ' operator: equal', + ' expected: false', + ' actual: true', + ' at: Test. ($TEST/todo_single.js:$LINE:$COL)', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 1', + '', + '# ok', + '' + ]); })); test('failure', { todo: true }, function (t) { diff --git a/test/too_many.js b/test/too_many.js index 946ceb8e..6ac3e164 100644 --- a/test/too_many.js +++ b/test/too_many.js @@ -37,8 +37,9 @@ tap.test('array test', function (tt) { '1..6', '# tests 6', '# pass 5', - '# fail 1' - ].join('\n') + '\n'); + '# fail 1', + '' + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/undef.js b/test/undef.js index 52759ac7..5b219d99 100644 --- a/test/undef.js +++ b/test/undef.js @@ -9,30 +9,30 @@ tap.test('array test', function (tt) { var test = tape.createHarness(); test.createStream().pipe(concat(function (body) { - tt.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# undef\n' - + 'not ok 1 should be equivalent\n' - + ' ---\n' - + ' operator: deepEqual\n' - + ' expected: |-\n' - + ' { beep: undefined }\n' - + ' actual: |-\n' - + ' {}\n' - + ' at: Test. ($TEST/undef.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should be equivalent\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/undef.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + tt.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# undef', + 'not ok 1 should be equivalent', + ' ---', + ' operator: deepEqual', + ' expected: |-', + ' { beep: undefined }', + ' actual: |-', + ' {}', + ' at: Test. ($TEST/undef.js:$LINE:$COL)', + ' stack: |-', + ' Error: should be equivalent', + ' [... stack stripped ...]', + ' at Test. ($TEST/undef.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); })); test('undef', function (t) {