UNPKG

7.78 kBJavaScriptView Raw
1'use strict';
2
3var tape = require('../');
4var tap = require('tap');
5var concat = require('concat-stream');
6
7var stripFullStack = require('./common').stripFullStack;
8
9tap.test('numerics', function (tt) {
10 tt.plan(1);
11
12 var test = tape.createHarness();
13 test.createStream().pipe(concat(function (body) {
14 tt.same(stripFullStack(body.toString('utf8')), [
15 'TAP version 13',
16 '# numeric strings',
17 'not ok 1 number equal to string',
18 ' ---',
19 ' operator: equal',
20 ' expected: \'3\'',
21 ' actual: 3',
22 ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
23 ' stack: |-',
24 ' Error: number equal to string',
25 ' [... stack stripped ...]',
26 ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
27 ' [... stack stripped ...]',
28 ' ...',
29 'not ok 2 string equal to number',
30 ' ---',
31 ' operator: equal',
32 ' expected: 3',
33 ' actual: \'3\'',
34 ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
35 ' stack: |-',
36 ' Error: string equal to number',
37 ' [... stack stripped ...]',
38 ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
39 ' [... stack stripped ...]',
40 ' ...',
41 'ok 3 number notEqual to string',
42 'ok 4 string notEqual to number',
43 'ok 5 number looseEqual to string',
44 'ok 6 string looseEqual to number',
45 'not ok 7 number notLooseEqual to string',
46 ' ---',
47 ' operator: notLooseEqual',
48 ' expected: \'3\'',
49 ' actual: 3',
50 ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
51 ' stack: |-',
52 ' Error: number notLooseEqual to string',
53 ' [... stack stripped ...]',
54 ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
55 ' [... stack stripped ...]',
56 ' ...',
57 'not ok 8 string notLooseEqual to number',
58 ' ---',
59 ' operator: notLooseEqual',
60 ' expected: 3',
61 ' actual: \'3\'',
62 ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
63 ' stack: |-',
64 ' Error: string notLooseEqual to number',
65 ' [... stack stripped ...]',
66 ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
67 ' [... stack stripped ...]',
68 ' ...',
69 'not ok 9 number strictEqual to string',
70 ' ---',
71 ' operator: equal',
72 ' expected: \'3\'',
73 ' actual: 3',
74 ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
75 ' stack: |-',
76 ' Error: number strictEqual to string',
77 ' [... stack stripped ...]',
78 ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
79 ' [... stack stripped ...]',
80 ' ...',
81 'not ok 10 string strictEqual to number',
82 ' ---',
83 ' operator: equal',
84 ' expected: 3',
85 ' actual: \'3\'',
86 ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
87 ' stack: |-',
88 ' Error: string strictEqual to number',
89 ' [... stack stripped ...]',
90 ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
91 ' [... stack stripped ...]',
92 ' ...',
93 'ok 11 number notStrictEqual to string',
94 'ok 12 string notStrictEqual to number',
95 'ok 13 number deepLooseEqual to string',
96 'ok 14 string deepLooseEqual to number',
97 'not ok 15 number notDeepLooseEqual to string',
98 ' ---',
99 ' operator: notDeepLooseEqual',
100 ' expected: \'3\'',
101 ' actual: 3',
102 ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
103 ' stack: |-',
104 ' Error: number notDeepLooseEqual to string',
105 ' [... stack stripped ...]',
106 ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
107 ' [... stack stripped ...]',
108 ' ...',
109 'not ok 16 string notDeepLooseEqual to number',
110 ' ---',
111 ' operator: notDeepLooseEqual',
112 ' expected: 3',
113 ' actual: \'3\'',
114 ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
115 ' stack: |-',
116 ' Error: string notDeepLooseEqual to number',
117 ' [... stack stripped ...]',
118 ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
119 ' [... stack stripped ...]',
120 ' ...',
121 'not ok 17 number deepEqual to string',
122 ' ---',
123 ' operator: deepEqual',
124 ' expected: \'3\'',
125 ' actual: 3',
126 ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
127 ' stack: |-',
128 ' Error: number deepEqual to string',
129 ' [... stack stripped ...]',
130 ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
131 ' [... stack stripped ...]',
132 ' ...',
133 'not ok 18 string deepEqual to number',
134 ' ---',
135 ' operator: deepEqual',
136 ' expected: 3',
137 ' actual: \'3\'',
138 ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
139 ' stack: |-',
140 ' Error: string deepEqual to number',
141 ' [... stack stripped ...]',
142 ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)',
143 ' [... stack stripped ...]',
144 ' ...',
145 'ok 19 number notDeepEqual to string',
146 'ok 20 string notDeepEqual to number',
147 '',
148 '1..20',
149 '# tests 20',
150 '# pass 10',
151 '# fail 10',
152 ''
153 ]);
154 }));
155
156 test('numeric strings', function (t) {
157 t.equal(3, '3', 'number equal to string');
158 t.equal('3', 3, 'string equal to number');
159 t.notEqual(3, '3', 'number notEqual to string');
160 t.notEqual('3', 3, 'string notEqual to number');
161
162 t.looseEqual(3, '3', 'number looseEqual to string');
163 t.looseEqual('3', 3, 'string looseEqual to number');
164 t.notLooseEqual(3, '3', 'number notLooseEqual to string');
165 t.notLooseEqual('3', 3, 'string notLooseEqual to number');
166
167 t.strictEqual(3, '3', 'number strictEqual to string');
168 t.strictEqual('3', 3, 'string strictEqual to number');
169 t.notStrictEqual(3, '3', 'number notStrictEqual to string');
170 t.notStrictEqual('3', 3, 'string notStrictEqual to number');
171
172 t.deepLooseEqual(3, '3', 'number deepLooseEqual to string');
173 t.deepLooseEqual('3', 3, 'string deepLooseEqual to number');
174 t.notDeepLooseEqual(3, '3', 'number notDeepLooseEqual to string');
175 t.notDeepLooseEqual('3', 3, 'string notDeepLooseEqual to number');
176
177 t.deepEqual(3, '3', 'number deepEqual to string');
178 t.deepEqual('3', 3, 'string deepEqual to number');
179 t.notDeepEqual(3, '3', 'number notDeepEqual to string');
180 t.notDeepEqual('3', 3, 'string notDeepEqual to number');
181
182 t.end();
183 });
184});