Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
})
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
You can’t perform that action at this time.