git ssb

3+

cel / ssb-npm-registry



Tree: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3

Files: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3 / node_modules / looper / test / test.js

629 bytesRaw
1
2var tape = require('tape')
3var looper = require('../')
4
5tape('n=1000000, with no RangeError', function (t) {
6 var n = 1000000, c = 0
7 looper(function (next) {
8 c ++
9 if(--n) return next()
10 t.equal(c, 1000000)
11 t.end()
12 })
13})
14
15tape('async is okay', function (t) {
16
17 var n = 100, c = 0
18 looper(function (next) {
19 c ++
20 if(--n) return setTimeout(next)
21 t.equal(c, 100)
22 t.end()
23 })
24
25})
26
27tape('sometimes async is okay', function (t) {
28 var i = 1000; c = 0
29 looper(function (next) {
30 c++
31 if(--i) return Math.random() < 0.1 ? setTimeout(next) : next()
32 t.equal(c, 1000)
33 t.end()
34 })
35
36})
37
38

Built with git-ssb-web