Created
January 30, 2014 01:13
-
-
Save Raynos/8700797 to your computer and use it in GitHub Desktop.
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
var Assert = require('assert-tap2') | |
var run = require('gens2/run') | |
// NO FRAMEWORK. Just node style assert | |
// that outputs TAP. | |
run(function* () { | |
var assert = Assert('a test case') | |
... | |
assert.stuff() | |
// No assert.end() call ! | |
... | |
var assert = Assert('a second test case') | |
assert.moreStuff() | |
... | |
// repeat forever | |
}) |
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
var Assert = require('assert-tap2') | |
var async = require('gens') | |
var queue = [] | |
/* | |
test('some test case', function* (assert) { | |
// call assert like node | |
// no assert.end() | |
// no assert.ifError(err), just yield errors | |
}) | |
*/ | |
function test(name, gen) { | |
queue.push({ name: name, task: async(gen) }) | |
if (queue.length === 1) process.nextTick(flushQueue) | |
} | |
function flushQueue() { | |
var tuple = queue.shift() | |
if (!tuple) return | |
var assert = Assert(tuple.name) | |
tuple.task(assert, function (err) { | |
assert.ifError(err) | |
flushQueue() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment