1 | 'use strict';
|
2 |
|
3 | var falafel = require('falafel');
|
4 | var tape = require('../');
|
5 | var tap = require('tap');
|
6 | var concat = require('concat-stream');
|
7 |
|
8 | tap.test('array test', function (tt) {
|
9 | tt.plan(1);
|
10 |
|
11 | var test = tape.createHarness();
|
12 | var tc = function (rows) {
|
13 | tt.same(rows.toString('utf8').split('\n'), [
|
14 | 'TAP version 13',
|
15 | '# nested array test',
|
16 | 'ok 1 should be deeply equivalent',
|
17 | 'ok 2 should be deeply equivalent',
|
18 | 'ok 3 should be deeply equivalent',
|
19 | 'ok 4 should be deeply equivalent',
|
20 | 'ok 5 should be deeply equivalent',
|
21 | '# inside test',
|
22 | 'ok 6 should be truthy',
|
23 | 'ok 7 should be truthy',
|
24 | '# another',
|
25 | 'ok 8 should be truthy',
|
26 | '',
|
27 | '1..8',
|
28 | '# tests 8',
|
29 | '# pass 8',
|
30 | '',
|
31 | '# ok',
|
32 | ''
|
33 | ]);
|
34 | };
|
35 |
|
36 | test.createStream().pipe(concat(tc));
|
37 |
|
38 | test('nested array test', function (t) {
|
39 | t.plan(6);
|
40 |
|
41 | var src = '(' + function () {
|
42 | var xs = [1, 2, [3, 4]];
|
43 | var ys = [5, 6];
|
44 | g([xs, ys]);
|
45 | } + ')()';
|
46 |
|
47 | var output = falafel(src, function (node) {
|
48 | if (node.type === 'ArrayExpression') {
|
49 | node.update('fn(' + node.source() + ')');
|
50 | }
|
51 | });
|
52 |
|
53 | t.test('inside test', function (q) {
|
54 | q.plan(2);
|
55 | q.ok(true);
|
56 |
|
57 | setTimeout(function () {
|
58 | q.ok(true);
|
59 | }, 100);
|
60 | });
|
61 |
|
62 | var arrays = [
|
63 | [3, 4],
|
64 | [1, 2, [3, 4]],
|
65 | [5, 6],
|
66 | [[1, 2, [3, 4]], [5, 6]]
|
67 | ];
|
68 |
|
69 | Function(['fn', 'g'], output)(
|
70 | function (xs) {
|
71 | t.same(arrays.shift(), xs);
|
72 | return xs;
|
73 | },
|
74 | function (xs) {
|
75 | t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
|
76 | }
|
77 | );
|
78 | });
|
79 |
|
80 | test('another', function (t) {
|
81 | t.plan(1);
|
82 | setTimeout(function () {
|
83 | t.ok(true);
|
84 | }, 50);
|
85 | });
|
86 | });
|