node/deps/npm/node_modules/dezalgo/test/basic.js

26 lines
400 B
JavaScript
Raw Normal View History

2014-09-25 05:41:07 +08:00
var test = require('tap').test
var dz = require('../dezalgo.js')
test('the dark pony', function(t) {
var n = 0
function foo(cb) {
cb = dz(cb)
if (++n % 2) cb()
else process.nextTick(cb)
}
var called = 0
for (var i = 0; i < 10; i++) {
foo(function() {
called++
})
t.equal(called, 0)
}
setTimeout(function() {
t.equal(called, 10)
t.end()
})
})