Skip to content

Commit 4ae9c04

Browse files
author
James Halliday
committed
too few assertion test
1 parent 104af1f commit 4ae9c04

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

test/exit.js

+36
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,39 @@ tap.test('exit fail', function (t) {
7070
t.notEqual(code, 0);
7171
});
7272
});
73+
74+
tap.test('too few exit', function (t) {
75+
t.plan(2);
76+
77+
var tc = tap.createConsumer();
78+
79+
var rows = [];
80+
tc.on('data', function (r) { rows.push(r) });
81+
tc.on('end', function () {
82+
var rs = rows.map(function (r) {
83+
if (r && typeof r === 'object') {
84+
return { id : r.id, ok : r.ok, name : r.name.trim() };
85+
}
86+
else return r;
87+
});
88+
t.same(rs, [
89+
'TAP version 13',
90+
'array',
91+
{ id: 1, ok: true, name: 'should be equivalent' },
92+
{ id: 2, ok: true, name: 'should be equivalent' },
93+
{ id: 3, ok: true, name: 'should be equivalent' },
94+
{ id: 4, ok: true, name: 'should be equivalent' },
95+
{ id: 5, ok: true, name: 'should be equivalent' },
96+
{ id: 6, ok: false, name: 'too few assertions' },
97+
'tests 6',
98+
'pass 5',
99+
'fail 1'
100+
]);
101+
});
102+
103+
var ps = spawn(process.execPath, [ __dirname + '/exit/too_few.js' ]);
104+
ps.stdout.pipe(tc);
105+
ps.on('exit', function (code) {
106+
t.notEqual(code, 0);
107+
});
108+
});

test/exit/too_few.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
var falafel = require('falafel');
2+
var test = require('../../');
3+
4+
test('array', function (t) {
5+
t.plan(6);
6+
7+
var src = '(' + function () {
8+
var xs = [ 1, 2, [ 3, 4 ] ];
9+
var ys = [ 5, 6 ];
10+
g([ xs, ys ]);
11+
} + ')()';
12+
13+
var output = falafel(src, function (node) {
14+
if (node.type === 'ArrayExpression') {
15+
node.update('fn(' + node.source() + ')');
16+
}
17+
});
18+
19+
var arrays = [
20+
[ 3, 4 ],
21+
[ 1, 2, [ 3, 4 ] ],
22+
[ 5, 6 ],
23+
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
24+
];
25+
26+
Function(['fn','g'], output)(
27+
function (xs) {
28+
t.same(arrays.shift(), xs);
29+
return xs;
30+
},
31+
function (xs) {
32+
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
33+
}
34+
);
35+
});

0 commit comments

Comments
 (0)