Skip to content

Commit 9b2ffe1

Browse files
author
James Halliday
committed
not enough example
1 parent 028e858 commit 9b2ffe1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

example/not_enough.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(8);
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)