Skip to content

Commit 98b2695

Browse files
committed
[Tests] sync new test cases from master
1 parent d686aa2 commit 98b2695

File tree

4 files changed

+162
-48
lines changed

4 files changed

+162
-48
lines changed

test/default-messages.js

+26-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
'use strict';
2+
13
var tap = require('tap');
24
var path = require('path');
35
var spawn = require('child_process').spawn;
46
var concat = require('concat-stream');
57

8+
var stripFullStack = require('./common').stripFullStack;
9+
610
tap.test('default messages', function (t) {
711
t.plan(1);
812

913
var ps = spawn(process.execPath, [path.join(__dirname, 'messages', 'defaults.js')]);
1014

1115
ps.stdout.pipe(concat(function (rows) {
1216

13-
t.same(rows.toString('utf8'), [
17+
t.same(stripFullStack(rows.toString('utf8')), [
1418
'TAP version 13',
1519
'# default messages',
1620
'ok 1 should be truthy',
@@ -19,13 +23,28 @@ tap.test('default messages', function (t) {
1923
'ok 4 should not be equal',
2024
'ok 5 should be equivalent',
2125
'ok 6 should be equivalent',
22-
'ok 7 should be equivalent',
23-
'',
24-
'1..7',
25-
'# tests 7',
26-
'# pass 7',
26+
'ok 7 should be equal',
27+
'ok 8 should not be equal',
28+
'ok 9 should be equivalent',
29+
'not ok 10 should not be equivalent',
30+
' ---',
31+
' operator: notDeepEqual',
32+
' expected: true',
33+
' actual: true',
34+
' at: Test.<anonymous> ($TEST/messages/defaults.js:$LINE:$COL)',
35+
' stack: |-',
36+
' Error: should not be equivalent',
37+
' [... stack stripped ...]',
38+
' at Test.<anonymous> ($TEST/messages/defaults.js:$LINE:$COL)',
39+
' [... stack stripped ...]',
40+
' ...',
41+
'ok 11 should be equivalent',
42+
'ok 12 should be equivalent',
2743
'',
28-
'# ok'
44+
'1..12',
45+
'# tests 12',
46+
'# pass 11',
47+
'# fail 1'
2948
].join('\n') + '\n\n');
3049
}));
3150
});

test/edge-cases.js

+75-24
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,39 @@ tap.test('edge cases', function (tt) {
4545
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
4646
+ ' [... stack stripped ...]\n'
4747
+ ' ...\n'
48-
+ 'ok 5 0 strictEqual to -0\n'
49-
+ 'ok 6 -0 strictEqual to 0\n'
50-
+ 'not ok 7 0 notStrictEqual to -0\n'
48+
+ 'ok 5 0 looseEqual to -0\n'
49+
+ 'ok 6 -0 looseEqual to 0\n'
50+
+ 'not ok 7 0 notLooseEqual to -0\n'
51+
+ ' ---\n'
52+
+ ' operator: notDeepLooseEqual\n'
53+
+ ' expected: |-\n'
54+
+ ' -0\n'
55+
+ ' actual: |-\n'
56+
+ ' 0\n'
57+
+ ' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
58+
+ ' stack: |-\n'
59+
+ ' Error: 0 notLooseEqual to -0\n'
60+
+ ' [... stack stripped ...]\n'
61+
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
62+
+ ' [... stack stripped ...]\n'
63+
+ ' ...\n'
64+
+ 'not ok 8 -0 notLooseEqual to 0\n'
65+
+ ' ---\n'
66+
+ ' operator: notDeepLooseEqual\n'
67+
+ ' expected: |-\n'
68+
+ ' 0\n'
69+
+ ' actual: |-\n'
70+
+ ' -0\n'
71+
+ ' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
72+
+ ' stack: |-\n'
73+
+ ' Error: -0 notLooseEqual to 0\n'
74+
+ ' [... stack stripped ...]\n'
75+
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
76+
+ ' [... stack stripped ...]\n'
77+
+ ' ...\n'
78+
+ 'ok 9 0 strictEqual to -0\n'
79+
+ 'ok 10 -0 strictEqual to 0\n'
80+
+ 'not ok 11 0 notStrictEqual to -0\n'
5181
+ ' ---\n'
5282
+ ' operator: notEqual\n'
5383
+ ' expected: |-\n'
@@ -61,7 +91,7 @@ tap.test('edge cases', function (tt) {
6191
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
6292
+ ' [... stack stripped ...]\n'
6393
+ ' ...\n'
64-
+ 'not ok 8 -0 notStrictEqual to 0\n'
94+
+ 'not ok 12 -0 notStrictEqual to 0\n'
6595
+ ' ---\n'
6696
+ ' operator: notEqual\n'
6797
+ ' expected: |-\n'
@@ -75,9 +105,9 @@ tap.test('edge cases', function (tt) {
75105
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
76106
+ ' [... stack stripped ...]\n'
77107
+ ' ...\n'
78-
+ 'ok 9 0 deepLooseEqual to -0\n'
79-
+ 'ok 10 -0 deepLooseEqual to 0\n'
80-
+ 'not ok 11 0 notDeepLooseEqual to -0\n'
108+
+ 'ok 13 0 deepLooseEqual to -0\n'
109+
+ 'ok 14 -0 deepLooseEqual to 0\n'
110+
+ 'not ok 15 0 notDeepLooseEqual to -0\n'
81111
+ ' ---\n'
82112
+ ' operator: notDeepLooseEqual\n'
83113
+ ' expected: |-\n'
@@ -91,7 +121,7 @@ tap.test('edge cases', function (tt) {
91121
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
92122
+ ' [... stack stripped ...]\n'
93123
+ ' ...\n'
94-
+ 'not ok 12 -0 notDeepLooseEqual to 0\n'
124+
+ 'not ok 16 -0 notDeepLooseEqual to 0\n'
95125
+ ' ---\n'
96126
+ ' operator: notDeepLooseEqual\n'
97127
+ ' expected: |-\n'
@@ -105,7 +135,7 @@ tap.test('edge cases', function (tt) {
105135
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
106136
+ ' [... stack stripped ...]\n'
107137
+ ' ...\n'
108-
+ 'not ok 13 0 deepEqual to -0\n'
138+
+ 'not ok 17 0 deepEqual to -0\n'
109139
+ ' ---\n'
110140
+ ' operator: deepEqual\n'
111141
+ ' expected: |-\n'
@@ -119,7 +149,7 @@ tap.test('edge cases', function (tt) {
119149
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
120150
+ ' [... stack stripped ...]\n'
121151
+ ' ...\n'
122-
+ 'not ok 14 -0 deepEqual to 0\n'
152+
+ 'not ok 18 -0 deepEqual to 0\n'
123153
+ ' ---\n'
124154
+ ' operator: deepEqual\n'
125155
+ ' expected: |-\n'
@@ -133,10 +163,10 @@ tap.test('edge cases', function (tt) {
133163
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
134164
+ ' [... stack stripped ...]\n'
135165
+ ' ...\n'
136-
+ 'ok 15 0 notDeepEqual to -0\n'
137-
+ 'ok 16 -0 notDeepEqual to 0\n'
166+
+ 'ok 19 0 notDeepEqual to -0\n'
167+
+ 'ok 20 -0 notDeepEqual to 0\n'
138168
+ '# NaNs\n'
139-
+ 'not ok 17 NaN equal to NaN\n'
169+
+ 'not ok 21 NaN equal to NaN\n'
140170
+ ' ---\n'
141171
+ ' operator: equal\n'
142172
+ ' expected: NaN\n'
@@ -148,8 +178,21 @@ tap.test('edge cases', function (tt) {
148178
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
149179
+ ' [... stack stripped ...]\n'
150180
+ ' ...\n'
151-
+ 'ok 18 NaN notEqual to NaN\n'
152-
+ 'not ok 19 NaN strictEqual to NaN\n'
181+
+ 'ok 22 NaN notEqual to NaN\n'
182+
+ 'not ok 23 NaN looseEqual to NaN\n'
183+
+ ' ---\n'
184+
+ ' operator: deepLooseEqual\n'
185+
+ ' expected: NaN\n'
186+
+ ' actual: NaN\n'
187+
+ ' at: Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
188+
+ ' stack: |-\n'
189+
+ ' Error: NaN looseEqual to NaN\n'
190+
+ ' [... stack stripped ...]\n'
191+
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
192+
+ ' [... stack stripped ...]\n'
193+
+ ' ...\n'
194+
+ 'ok 24 NaN notLooseEqual to NaN\n'
195+
+ 'not ok 25 NaN strictEqual to NaN\n'
153196
+ ' ---\n'
154197
+ ' operator: equal\n'
155198
+ ' expected: NaN\n'
@@ -161,8 +204,8 @@ tap.test('edge cases', function (tt) {
161204
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
162205
+ ' [... stack stripped ...]\n'
163206
+ ' ...\n'
164-
+ 'ok 20 NaN notStrictEqual to NaN\n'
165-
+ 'not ok 21 NaN deepLooseEqual to NaN\n'
207+
+ 'ok 26 NaN notStrictEqual to NaN\n'
208+
+ 'not ok 27 NaN deepLooseEqual to NaN\n'
166209
+ ' ---\n'
167210
+ ' operator: deepLooseEqual\n'
168211
+ ' expected: NaN\n'
@@ -174,9 +217,9 @@ tap.test('edge cases', function (tt) {
174217
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
175218
+ ' [... stack stripped ...]\n'
176219
+ ' ...\n'
177-
+ 'ok 22 NaN notDeepLooseEqual to NaN\n'
178-
+ 'ok 23 NaN deepEqual to NaN\n'
179-
+ 'not ok 24 NaN notDeepEqual to NaN\n'
220+
+ 'ok 28 NaN notDeepLooseEqual to NaN\n'
221+
+ 'ok 29 NaN deepEqual to NaN\n'
222+
+ 'not ok 30 NaN notDeepEqual to NaN\n'
180223
+ ' ---\n'
181224
+ ' operator: notDeepEqual\n'
182225
+ ' expected: NaN\n'
@@ -188,10 +231,10 @@ tap.test('edge cases', function (tt) {
188231
+ ' at Test.<anonymous> ($TEST/edge-cases.js:$LINE:$COL)\n'
189232
+ ' [... stack stripped ...]\n'
190233
+ ' ...\n'
191-
+ '\n1..24\n'
192-
+ '# tests 24\n'
193-
+ '# pass 12\n'
194-
+ '# fail 12\n'
234+
+ '\n1..30\n'
235+
+ '# tests 30\n'
236+
+ '# pass 15\n'
237+
+ '# fail 15\n'
195238
);
196239
}));
197240

@@ -201,6 +244,11 @@ tap.test('edge cases', function (tt) {
201244
t.notEqual(0, -0, '0 notEqual to -0');
202245
t.notEqual(-0, 0, '-0 notEqual to 0');
203246

247+
t.looseEqual(0, -0, '0 looseEqual to -0');
248+
t.looseEqual(-0, 0, '-0 looseEqual to 0');
249+
t.notLooseEqual(0, -0, '0 notLooseEqual to -0');
250+
t.notLooseEqual(-0, 0, '-0 notLooseEqual to 0');
251+
204252
t.strictEqual(0, -0, '0 strictEqual to -0');
205253
t.strictEqual(-0, 0, '-0 strictEqual to 0');
206254
t.notStrictEqual(0, -0, '0 notStrictEqual to -0');
@@ -223,6 +271,9 @@ tap.test('edge cases', function (tt) {
223271
t.equal(NaN, NaN, 'NaN equal to NaN');
224272
t.notEqual(NaN, NaN, 'NaN notEqual to NaN');
225273

274+
t.looseEqual(NaN, NaN, 'NaN looseEqual to NaN');
275+
t.notLooseEqual(NaN, NaN, 'NaN notLooseEqual to NaN');
276+
226277
t.strictEqual(NaN, NaN, 'NaN strictEqual to NaN');
227278
t.notStrictEqual(NaN, NaN, 'NaN notStrictEqual to NaN');
228279

test/messages/defaults.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1+
'use strict';
2+
13
var test = require('../../');
24

35
test('default messages', function (t) {
4-
t.plan(7);
6+
t.plan(12);
7+
58
t.ok(true);
69
t.notOk(false);
10+
711
t.equal(true, true);
812
t.notEqual(true, false);
13+
14+
t.looseEqual(true, true);
15+
t.notLooseEqual(true, false);
16+
17+
t.strictEqual(true, true);
18+
t.notStrictEqual(true, false);
19+
920
t.deepEqual(true, true);
21+
t.notDeepEqual(true, true);
22+
1023
t.deepLooseEqual(true, true);
1124
t.notDeepLooseEqual(true, false);
1225
});

test/numerics.js

+47-16
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,33 @@ tap.test('numerics', function (tt) {
4141
+ ' ...\n'
4242
+ 'ok 3 number notEqual to string\n'
4343
+ 'ok 4 string notEqual to number\n'
44-
+ 'not ok 5 number strictEqual to string\n'
44+
+ 'ok 5 number looseEqual to string\n'
45+
+ 'ok 6 string looseEqual to number\n'
46+
+ 'not ok 7 number notLooseEqual to string\n'
47+
+ ' ---\n'
48+
+ ' operator: notDeepLooseEqual\n'
49+
+ ' expected: \'3\'\n'
50+
+ ' actual: 3\n'
51+
+ ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
52+
+ ' stack: |-\n'
53+
+ ' Error: number notLooseEqual to string\n'
54+
+ ' [... stack stripped ...]\n'
55+
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
56+
+ ' [... stack stripped ...]\n'
57+
+ ' ...\n'
58+
+ 'not ok 8 string notLooseEqual to number\n'
59+
+ ' ---\n'
60+
+ ' operator: notDeepLooseEqual\n'
61+
+ ' expected: 3\n'
62+
+ ' actual: \'3\'\n'
63+
+ ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
64+
+ ' stack: |-\n'
65+
+ ' Error: string notLooseEqual to number\n'
66+
+ ' [... stack stripped ...]\n'
67+
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
68+
+ ' [... stack stripped ...]\n'
69+
+ ' ...\n'
70+
+ 'not ok 9 number strictEqual to string\n'
4571
+ ' ---\n'
4672
+ ' operator: equal\n'
4773
+ ' expected: \'3\'\n'
@@ -53,7 +79,7 @@ tap.test('numerics', function (tt) {
5379
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
5480
+ ' [... stack stripped ...]\n'
5581
+ ' ...\n'
56-
+ 'not ok 6 string strictEqual to number\n'
82+
+ 'not ok 10 string strictEqual to number\n'
5783
+ ' ---\n'
5884
+ ' operator: equal\n'
5985
+ ' expected: 3\n'
@@ -65,11 +91,11 @@ tap.test('numerics', function (tt) {
6591
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
6692
+ ' [... stack stripped ...]\n'
6793
+ ' ...\n'
68-
+ 'ok 7 number notStrictEqual to string\n'
69-
+ 'ok 8 string notStrictEqual to number\n'
70-
+ 'ok 9 number deepLooseEqual to string\n'
71-
+ 'ok 10 string deepLooseEqual to number\n'
72-
+ 'not ok 11 number notDeepLooseEqual to string\n'
94+
+ 'ok 11 number notStrictEqual to string\n'
95+
+ 'ok 12 string notStrictEqual to number\n'
96+
+ 'ok 13 number deepLooseEqual to string\n'
97+
+ 'ok 14 string deepLooseEqual to number\n'
98+
+ 'not ok 15 number notDeepLooseEqual to string\n'
7399
+ ' ---\n'
74100
+ ' operator: notDeepLooseEqual\n'
75101
+ ' expected: \'3\'\n'
@@ -81,7 +107,7 @@ tap.test('numerics', function (tt) {
81107
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
82108
+ ' [... stack stripped ...]\n'
83109
+ ' ...\n'
84-
+ 'not ok 12 string notDeepLooseEqual to number\n'
110+
+ 'not ok 16 string notDeepLooseEqual to number\n'
85111
+ ' ---\n'
86112
+ ' operator: notDeepLooseEqual\n'
87113
+ ' expected: 3\n'
@@ -93,7 +119,7 @@ tap.test('numerics', function (tt) {
93119
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
94120
+ ' [... stack stripped ...]\n'
95121
+ ' ...\n'
96-
+ 'not ok 13 number deepEqual to string\n'
122+
+ 'not ok 17 number deepEqual to string\n'
97123
+ ' ---\n'
98124
+ ' operator: deepEqual\n'
99125
+ ' expected: \'3\'\n'
@@ -105,7 +131,7 @@ tap.test('numerics', function (tt) {
105131
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
106132
+ ' [... stack stripped ...]\n'
107133
+ ' ...\n'
108-
+ 'not ok 14 string deepEqual to number\n'
134+
+ 'not ok 18 string deepEqual to number\n'
109135
+ ' ---\n'
110136
+ ' operator: deepEqual\n'
111137
+ ' expected: 3\n'
@@ -117,12 +143,12 @@ tap.test('numerics', function (tt) {
117143
+ ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
118144
+ ' [... stack stripped ...]\n'
119145
+ ' ...\n'
120-
+ 'ok 15 number notDeepEqual to string\n'
121-
+ 'ok 16 string notDeepEqual to number\n'
122-
+ '\n1..16\n'
123-
+ '# tests 16\n'
124-
+ '# pass 8\n'
125-
+ '# fail 8\n'
146+
+ 'ok 19 number notDeepEqual to string\n'
147+
+ 'ok 20 string notDeepEqual to number\n'
148+
+ '\n1..20\n'
149+
+ '# tests 20\n'
150+
+ '# pass 10\n'
151+
+ '# fail 10\n'
126152
);
127153
}));
128154

@@ -132,6 +158,11 @@ tap.test('numerics', function (tt) {
132158
t.notEqual(3, '3', 'number notEqual to string');
133159
t.notEqual('3', 3, 'string notEqual to number');
134160

161+
t.looseEqual(3, '3', 'number looseEqual to string');
162+
t.looseEqual('3', 3, 'string looseEqual to number');
163+
t.notLooseEqual(3, '3', 'number notLooseEqual to string');
164+
t.notLooseEqual('3', 3, 'string notLooseEqual to number');
165+
135166
t.strictEqual(3, '3', 'number strictEqual to string');
136167
t.strictEqual('3', 3, 'string strictEqual to number');
137168
t.notStrictEqual(3, '3', 'number notStrictEqual to string');

0 commit comments

Comments
 (0)