UNPKG

8.17 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.equal(
15 stripFullStack(body.toString('utf8')),
16 'TAP version 13\n'
17 + '# numeric strings\n'
18 + 'not ok 1 number equal to string\n'
19 + ' ---\n'
20 + ' operator: equal\n'
21 + ' expected: \'3\'\n'
22 + ' actual: 3\n'
23 + ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
24 + ' stack: |-\n'
25 + ' Error: number equal to string\n'
26 + ' [... stack stripped ...]\n'
27 + ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
28 + ' [... stack stripped ...]\n'
29 + ' ...\n'
30 + 'not ok 2 string equal to number\n'
31 + ' ---\n'
32 + ' operator: equal\n'
33 + ' expected: 3\n'
34 + ' actual: \'3\'\n'
35 + ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
36 + ' stack: |-\n'
37 + ' Error: string equal to number\n'
38 + ' [... stack stripped ...]\n'
39 + ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
40 + ' [... stack stripped ...]\n'
41 + ' ...\n'
42 + 'ok 3 number notEqual to string\n'
43 + 'ok 4 string notEqual to number\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'
71 + ' ---\n'
72 + ' operator: equal\n'
73 + ' expected: \'3\'\n'
74 + ' actual: 3\n'
75 + ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
76 + ' stack: |-\n'
77 + ' Error: number strictEqual to string\n'
78 + ' [... stack stripped ...]\n'
79 + ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
80 + ' [... stack stripped ...]\n'
81 + ' ...\n'
82 + 'not ok 10 string strictEqual to number\n'
83 + ' ---\n'
84 + ' operator: equal\n'
85 + ' expected: 3\n'
86 + ' actual: \'3\'\n'
87 + ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
88 + ' stack: |-\n'
89 + ' Error: string strictEqual to number\n'
90 + ' [... stack stripped ...]\n'
91 + ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
92 + ' [... stack stripped ...]\n'
93 + ' ...\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'
99 + ' ---\n'
100 + ' operator: notDeepLooseEqual\n'
101 + ' expected: \'3\'\n'
102 + ' actual: 3\n'
103 + ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
104 + ' stack: |-\n'
105 + ' Error: number notDeepLooseEqual to string\n'
106 + ' [... stack stripped ...]\n'
107 + ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
108 + ' [... stack stripped ...]\n'
109 + ' ...\n'
110 + 'not ok 16 string notDeepLooseEqual to number\n'
111 + ' ---\n'
112 + ' operator: notDeepLooseEqual\n'
113 + ' expected: 3\n'
114 + ' actual: \'3\'\n'
115 + ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
116 + ' stack: |-\n'
117 + ' Error: string notDeepLooseEqual to number\n'
118 + ' [... stack stripped ...]\n'
119 + ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
120 + ' [... stack stripped ...]\n'
121 + ' ...\n'
122 + 'not ok 17 number deepEqual to string\n'
123 + ' ---\n'
124 + ' operator: deepEqual\n'
125 + ' expected: \'3\'\n'
126 + ' actual: 3\n'
127 + ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
128 + ' stack: |-\n'
129 + ' Error: number deepEqual to string\n'
130 + ' [... stack stripped ...]\n'
131 + ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
132 + ' [... stack stripped ...]\n'
133 + ' ...\n'
134 + 'not ok 18 string deepEqual to number\n'
135 + ' ---\n'
136 + ' operator: deepEqual\n'
137 + ' expected: 3\n'
138 + ' actual: \'3\'\n'
139 + ' at: Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
140 + ' stack: |-\n'
141 + ' Error: string deepEqual to number\n'
142 + ' [... stack stripped ...]\n'
143 + ' at Test.<anonymous> ($TEST/numerics.js:$LINE:$COL)\n'
144 + ' [... stack stripped ...]\n'
145 + ' ...\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'
152 );
153 }));
154
155 test('numeric strings', function (t) {
156 t.equal(3, '3', 'number equal to string');
157 t.equal('3', 3, 'string equal to number');
158 t.notEqual(3, '3', 'number notEqual to string');
159 t.notEqual('3', 3, 'string notEqual to number');
160
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
166 t.strictEqual(3, '3', 'number strictEqual to string');
167 t.strictEqual('3', 3, 'string strictEqual to number');
168 t.notStrictEqual(3, '3', 'number notStrictEqual to string');
169 t.notStrictEqual('3', 3, 'string notStrictEqual to number');
170
171 t.deepLooseEqual(3, '3', 'number deepLooseEqual to string');
172 t.deepLooseEqual('3', 3, 'string deepLooseEqual to number');
173 t.notDeepLooseEqual(3, '3', 'number notDeepLooseEqual to string');
174 t.notDeepLooseEqual('3', 3, 'string notDeepLooseEqual to number');
175
176 t.deepEqual(3, '3', 'number deepEqual to string');
177 t.deepEqual('3', 3, 'string deepEqual to number');
178 t.notDeepEqual(3, '3', 'number notDeepEqual to string');
179 t.notDeepEqual('3', 3, 'string notDeepEqual to number');
180
181 t.end();
182 });
183});