Skip to content

Commit

Permalink
[Tests] sync new test cases from master
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Feb 25, 2020
1 parent d686aa2 commit 98b2695
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 48 deletions.
33 changes: 26 additions & 7 deletions test/default-messages.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
'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(rows.toString('utf8'), [
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# default messages',
'ok 1 should be truthy',
Expand All @@ -19,13 +23,28 @@ tap.test('default messages', function (t) {
'ok 4 should not be equal',
'ok 5 should be equivalent',
'ok 6 should be equivalent',
'ok 7 should be equivalent',
'',
'1..7',
'# tests 7',
'# pass 7',
'ok 7 should be equal',
'ok 8 should not be equal',
'ok 9 should be equivalent',
'not ok 10 should not be equivalent',
' ---',
' operator: notDeepEqual',
' expected: true',
' actual: true',
' at: Test.<anonymous> ($TEST/messages/defaults.js:$LINE:$COL)',
' stack: |-',
' Error: should not be equivalent',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/messages/defaults.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok 11 should be equivalent',
'ok 12 should be equivalent',
'',
'# ok'
'1..12',
'# tests 12',
'# pass 11',
'# fail 1'
].join('\n') + '\n\n');
}));
});
99 changes: 75 additions & 24 deletions test/edge-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,39 @@ tap.test('edge cases', function (tt) {
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'ok 5 0 strictEqual to -0\n'
+ 'ok 6 -0 strictEqual to 0\n'
+ 'not ok 7 0 notStrictEqual to -0\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.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' stack: |-\n'
+ ' Error: 0 notLooseEqual to -0\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($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.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' stack: |-\n'
+ ' Error: -0 notLooseEqual to 0\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($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'
Expand All @@ -61,7 +91,7 @@ tap.test('edge cases', function (tt) {
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'not ok 8 -0 notStrictEqual to 0\n'
+ 'not ok 12 -0 notStrictEqual to 0\n'
+ ' ---\n'
+ ' operator: notEqual\n'
+ ' expected: |-\n'
Expand All @@ -75,9 +105,9 @@ tap.test('edge cases', function (tt) {
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'ok 9 0 deepLooseEqual to -0\n'
+ 'ok 10 -0 deepLooseEqual to 0\n'
+ 'not ok 11 0 notDeepLooseEqual to -0\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'
Expand All @@ -91,7 +121,7 @@ tap.test('edge cases', function (tt) {
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'not ok 12 -0 notDeepLooseEqual to 0\n'
+ 'not ok 16 -0 notDeepLooseEqual to 0\n'
+ ' ---\n'
+ ' operator: notDeepLooseEqual\n'
+ ' expected: |-\n'
Expand All @@ -105,7 +135,7 @@ tap.test('edge cases', function (tt) {
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'not ok 13 0 deepEqual to -0\n'
+ 'not ok 17 0 deepEqual to -0\n'
+ ' ---\n'
+ ' operator: deepEqual\n'
+ ' expected: |-\n'
Expand All @@ -119,7 +149,7 @@ tap.test('edge cases', function (tt) {
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'not ok 14 -0 deepEqual to 0\n'
+ 'not ok 18 -0 deepEqual to 0\n'
+ ' ---\n'
+ ' operator: deepEqual\n'
+ ' expected: |-\n'
Expand All @@ -133,10 +163,10 @@ tap.test('edge cases', function (tt) {
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'ok 15 0 notDeepEqual to -0\n'
+ 'ok 16 -0 notDeepEqual to 0\n'
+ 'ok 19 0 notDeepEqual to -0\n'
+ 'ok 20 -0 notDeepEqual to 0\n'
+ '# NaNs\n'
+ 'not ok 17 NaN equal to NaN\n'
+ 'not ok 21 NaN equal to NaN\n'
+ ' ---\n'
+ ' operator: equal\n'
+ ' expected: NaN\n'
Expand All @@ -148,8 +178,21 @@ tap.test('edge cases', function (tt) {
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'ok 18 NaN notEqual to NaN\n'
+ 'not ok 19 NaN strictEqual to NaN\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.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' stack: |-\n'
+ ' Error: NaN looseEqual to NaN\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($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'
Expand All @@ -161,8 +204,8 @@ tap.test('edge cases', function (tt) {
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'ok 20 NaN notStrictEqual to NaN\n'
+ 'not ok 21 NaN deepLooseEqual to NaN\n'
+ 'ok 26 NaN notStrictEqual to NaN\n'
+ 'not ok 27 NaN deepLooseEqual to NaN\n'
+ ' ---\n'
+ ' operator: deepLooseEqual\n'
+ ' expected: NaN\n'
Expand All @@ -174,9 +217,9 @@ tap.test('edge cases', function (tt) {
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'ok 22 NaN notDeepLooseEqual to NaN\n'
+ 'ok 23 NaN deepEqual to NaN\n'
+ 'not ok 24 NaN notDeepEqual to NaN\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'
Expand All @@ -188,10 +231,10 @@ tap.test('edge cases', function (tt) {
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ '\n1..24\n'
+ '# tests 24\n'
+ '# pass 12\n'
+ '# fail 12\n'
+ '\n1..30\n'
+ '# tests 30\n'
+ '# pass 15\n'
+ '# fail 15\n'
);
}));

Expand All @@ -201,6 +244,11 @@ tap.test('edge cases', function (tt) {
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');
Expand All @@ -223,6 +271,9 @@ tap.test('edge cases', function (tt) {
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');

Expand Down
15 changes: 14 additions & 1 deletion test/messages/defaults.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
'use strict';

var test = require('../../');

test('default messages', function (t) {
t.plan(7);
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);
});
63 changes: 47 additions & 16 deletions test/numerics.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,33 @@ tap.test('numerics', function (tt) {
+ ' ...\n'
+ 'ok 3 number notEqual to string\n'
+ 'ok 4 string notEqual to number\n'
+ 'not ok 5 number strictEqual to string\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.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
+ ' stack: |-\n'
+ ' Error: number notLooseEqual to string\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($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.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
+ ' stack: |-\n'
+ ' Error: string notLooseEqual to number\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($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'
Expand All @@ -53,7 +79,7 @@ tap.test('numerics', function (tt) {
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'not ok 6 string strictEqual to number\n'
+ 'not ok 10 string strictEqual to number\n'
+ ' ---\n'
+ ' operator: equal\n'
+ ' expected: 3\n'
Expand All @@ -65,11 +91,11 @@ tap.test('numerics', function (tt) {
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'ok 7 number notStrictEqual to string\n'
+ 'ok 8 string notStrictEqual to number\n'
+ 'ok 9 number deepLooseEqual to string\n'
+ 'ok 10 string deepLooseEqual to number\n'
+ 'not ok 11 number notDeepLooseEqual to string\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'
Expand All @@ -81,7 +107,7 @@ tap.test('numerics', function (tt) {
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'not ok 12 string notDeepLooseEqual to number\n'
+ 'not ok 16 string notDeepLooseEqual to number\n'
+ ' ---\n'
+ ' operator: notDeepLooseEqual\n'
+ ' expected: 3\n'
Expand All @@ -93,7 +119,7 @@ tap.test('numerics', function (tt) {
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'not ok 13 number deepEqual to string\n'
+ 'not ok 17 number deepEqual to string\n'
+ ' ---\n'
+ ' operator: deepEqual\n'
+ ' expected: \'3\'\n'
Expand All @@ -105,7 +131,7 @@ tap.test('numerics', function (tt) {
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'not ok 14 string deepEqual to number\n'
+ 'not ok 18 string deepEqual to number\n'
+ ' ---\n'
+ ' operator: deepEqual\n'
+ ' expected: 3\n'
Expand All @@ -117,12 +143,12 @@ tap.test('numerics', function (tt) {
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ 'ok 15 number notDeepEqual to string\n'
+ 'ok 16 string notDeepEqual to number\n'
+ '\n1..16\n'
+ '# tests 16\n'
+ '# pass 8\n'
+ '# fail 8\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'
);
}));

Expand All @@ -132,6 +158,11 @@ tap.test('numerics', function (tt) {
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');
Expand Down

0 comments on commit 98b2695

Please sign in to comment.