Skip to content

Commit

Permalink
[Tests] add npm run test:example to test non-failing examples.
Browse files Browse the repository at this point in the history
 - Note: does not work with `nyc` due to falafel usage.
  • Loading branch information
ljharb committed Jan 3, 2021
1 parent 266bc66 commit 4210e44
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
14 changes: 7 additions & 7 deletions example/nested.js
Expand Up @@ -4,7 +4,7 @@ var falafel = require('falafel');
var test = require('../');

test('nested array test', function (t) {
t.plan(5);
t.plan(6);

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
Expand All @@ -28,19 +28,19 @@ test('nested array test', function (t) {
});

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
[3, 4],
[1, 2, [3, 4]],
[5, 6],
[[1, 2, [3, 4]], [5, 6]],
];

Function(['fn','g'], output)(
Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
}
);
});
Expand Down
18 changes: 9 additions & 9 deletions example/not_enough.js → example/not_enough_fail.js
Expand Up @@ -7,9 +7,9 @@ test('array', function (t) {
t.plan(8);

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
var xs = [1, 2, [3, 4]];
var ys = [5, 6];
g([xs, ys]);
} + ')()';

var output = falafel(src, function (node) {
Expand All @@ -19,19 +19,19 @@ test('array', function (t) {
});

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
[3, 4],
[1, 2, [3, 4]],
[5, 6],
[[1, 2, [3, 4]], [5, 6]],
];

Function(['fn','g'], output)(
Function(['fn', 'g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
return xs;
},
function (xs) {
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]);
t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
}
);
});
File renamed without changes.
2 changes: 1 addition & 1 deletion example/stream/test/y.js
Expand Up @@ -3,7 +3,7 @@
var test = require('../../../');
test(function (t) {
t.plan(2);
t.equal(1+1, 2);
t.equal(1 + 1, 2);
t.ok(true);
});

Expand Down
4 changes: 2 additions & 2 deletions example/timing.js
Expand Up @@ -6,9 +6,9 @@ test('timing test', function (t) {
t.plan(2);

t.equal(typeof Date.now, 'function');
var start = new Date;
var start = Date.now();

setTimeout(function () {
t.equal(new Date - start, 100);
t.ok(Date.now() - start > 100);
}, 100);
});
File renamed without changes.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -57,7 +57,8 @@
"pretest": "npm run lint",
"test": "npm run tests-only",
"posttest": "aud --production",
"tests-only": "nyc tap test/*.js"
"tests-only": "nyc tap test/*.js",
"test:example": "find example -name '*.js' | grep -v fail | grep -v static | xargs tap"
},
"testling": {
"files": "test/browser/*.js",
Expand Down

0 comments on commit 4210e44

Please sign in to comment.