-
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mostly compatible with node-tap assertions, stubbed out assertion-to-…
…TAP logic
- Loading branch information
James Halliday
committed
Nov 25, 2012
1 parent
da360eb
commit 7948e2e
Showing
7 changed files
with
408 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var falafel = require('falafel'); | ||
var test = require('../'); | ||
|
||
test('array', function (t) { | ||
t.plan(5); | ||
|
||
var src = '(' + function () { | ||
var xs = [ 1, 2, [ 3, 4 ] ]; | ||
var ys = [ 5, 6 ]; | ||
g([ xs, ys ]); | ||
} + ')()'; | ||
|
||
var output = falafel(src, function (node) { | ||
if (node.type === 'ArrayExpression') { | ||
node.update('fn(' + node.source() + ')'); | ||
} | ||
}); | ||
|
||
var arrays = [ | ||
[ 3, 4 ], | ||
[ 1, 2, [ 3, 4 ] ], | ||
[ 5, 6 ], | ||
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], | ||
]; | ||
|
||
Function(['fn','g'], output)( | ||
function (xs) { | ||
t.same(arrays.shift(), xs); | ||
return xs; | ||
}, | ||
function (xs) { | ||
t.same(xs, [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var falafel = require('falafel'); | ||
var test = require('../'); | ||
|
||
test('array', function (t) { | ||
t.plan(5); | ||
|
||
var src = '(' + function () { | ||
var xs = [ 1, 2, [ 3, 4 ] ]; | ||
var ys = [ 5, 6 ]; | ||
g([ xs, ys ]); | ||
} + ')()'; | ||
|
||
var output = falafel(src, function (node) { | ||
if (node.type === 'ArrayExpression') { | ||
node.update('fn(' + node.source() + ')'); | ||
} | ||
}); | ||
|
||
var arrays = [ | ||
[ 3, 4 ], | ||
[ 1, 2, [ 3, 4 ] ], | ||
[ 5, 6 ], | ||
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ], | ||
]; | ||
|
||
Function(['fn','g'], output)( | ||
function (xs) { | ||
t.same(arrays.shift(), xs); | ||
return xs; | ||
}, | ||
function (xs) { | ||
t.same(xs, [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
var createDefaultStream = require('./lib/default_stream'); | ||
var Render = require('./lib/render'); | ||
var Test = require('./lib/test'); | ||
|
||
exports = module.exports = createHarness(); | ||
exports.createHarness = createHarness; | ||
exports.Test = Test; | ||
|
||
function createHarness () { | ||
var pending = []; | ||
var running = false; | ||
var out = new Render(); | ||
|
||
return function (name, conf, cb) { | ||
if (typeof conf === 'function') { | ||
cb = conf; | ||
conf = {}; | ||
} | ||
var t = new Test; | ||
out.push(t); | ||
|
||
var piped = false; | ||
|
||
t.pipe = function () { | ||
piped = true; | ||
}; | ||
|
||
t.once('pipe', function () { | ||
piped = true; | ||
}); | ||
|
||
process.nextTick(function () { | ||
if (!piped) out.pipe(createDefaultStream()); | ||
|
||
var run = function () { | ||
running = true; | ||
cb(t); | ||
}; | ||
|
||
if (running) { | ||
pending.push(run); | ||
} | ||
else run(); | ||
}); | ||
|
||
t.on('end', function () { | ||
running = false; | ||
process.nextTick(function () { | ||
if (pending.length) pending.shift()() | ||
else out.close() | ||
}); | ||
}); | ||
}; | ||
|
||
return out; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var Stream = require('stream'); | ||
|
||
module.exports = function () { | ||
if (typeof process !== 'undefined' && process.stdout | ||
&& typeof process.stdout.pipe === 'function') { | ||
return process.stdout; | ||
} | ||
|
||
var out = new Stream; | ||
out.writable = true; | ||
|
||
out.write = function (buf) { | ||
console.log(String(buf)); | ||
}; | ||
|
||
out.destroy = function () { | ||
out.emit('close'); | ||
}; | ||
|
||
out.end = function () { | ||
out.emit('close'); | ||
}; | ||
|
||
return out; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var Stream = require('stream'); | ||
|
||
module.exports = Render; | ||
|
||
function Render () { | ||
Stream.call(this); | ||
this.readable = true; | ||
} | ||
|
||
Render.prototype = new Stream; | ||
|
||
Render.prototype.push = function (t) { | ||
t.on('result', function (res) { | ||
console.dir(res); | ||
}); | ||
}; | ||
|
||
Render.prototype.close = function () { | ||
console.log('__END__'); | ||
}; |
Oops, something went wrong.