mirror of
https://github.com/Instadapp/Swap-Aggregator-Subgraph.git
synced 2024-07-29 21:57:12 +00:00
38 lines
629 B
JavaScript
38 lines
629 B
JavaScript
|
|
var tape = require('tape')
|
|
var looper = require('../')
|
|
|
|
tape('n=1000000, with no RangeError', function (t) {
|
|
var n = 1000000, c = 0
|
|
looper(function (next) {
|
|
c ++
|
|
if(--n) return next()
|
|
t.equal(c, 1000000)
|
|
t.end()
|
|
})
|
|
})
|
|
|
|
tape('async is okay', function (t) {
|
|
|
|
var n = 100, c = 0
|
|
looper(function (next) {
|
|
c ++
|
|
if(--n) return setTimeout(next)
|
|
t.equal(c, 100)
|
|
t.end()
|
|
})
|
|
|
|
})
|
|
|
|
tape('sometimes async is okay', function (t) {
|
|
var i = 1000; c = 0
|
|
looper(function (next) {
|
|
c++
|
|
if(--i) return Math.random() < 0.1 ? setTimeout(next) : next()
|
|
t.equal(c, 1000)
|
|
t.end()
|
|
})
|
|
|
|
})
|
|
|