Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

built the browser, can't run the advanced tests though due to lack of

require.  maybe down the road we'll fix this.
  • Loading branch information...
commit 12c1ae1b20d621db25c8bb66c67d8d477c5e33b2 1 parent 3ca31ba
@maxtaco authored
Showing with 68 additions and 63 deletions.
  1. +2 −2 extras/coffee-script.js
  2. +66 −61 test/tame_advanced.coffee
View
4 extras/coffee-script.js
2 additions, 2 deletions not shown
View
127 test/tame_advanced.coffee
@@ -1,61 +1,66 @@
-tameRequire(none)
-
-tame = require('../lib/coffee-script/coffee-script').tame;
-tamelib = require('../lib/coffee-script/tamelib')
-
-atest "rendezvous & windowing example", (cb) ->
-
- slots = []
- call = (i, cb) ->
- slots[i] = 1
- await setTimeout(defer(), 10*Math.random())
- slots[i] |= 2
- cb()
-
- window = (n, window, cb) ->
- rv = new tame.Rendezvous
- nsent = 0
- nrecv = 0
- while nrecv < n
- if nsent - nrecv < window and nsent < n
- call nsent, rv.id(nsent).defer()
- nsent++
- else
- await rv.wait defer(res)
- slots[res] |= 4
- nrecv++
- cb()
-
- await window 10, 3, defer()
- res = true
- for s in slots
- res = false unless s == 7
- cb(res, {})
-
-
-atest "pipeliner example", (cb) ->
-
- slots = []
- call = (i, cb) ->
- slots[i] = 1
- await setTimeout(defer(), 3*Math.random())
- slots[i] |= 2
- cb(4)
-
- window = (n, window, cb) ->
- tmp = {}
- p = new tamelib.Pipeliner window, .01
- for i in [0..n]
- await p.waitInQueue defer()
- call i, p.defer tmp[i]
- await p.flush defer()
- for k,v of tmp
- slots[k] |= tmp[k]
- cb()
-
- await window 100, 10, defer()
-
- ok = true
- for s in slots
- ok = false unless s == 7
- cb(ok, {})
+if require?
+
+ tameRequire(none)
+
+ tame = require('../lib/coffee-script/coffee-script').tame;
+ tamelib = require('../lib/coffee-script/tamelib')
+
+##----------------------------------------------------------------------
+
+ atest "rendezvous & windowing example", (cb) ->
+
+ slots = []
+ call = (i, cb) ->
+ slots[i] = 1
+ await setTimeout(defer(), 10*Math.random())
+ slots[i] |= 2
+ cb()
+
+ window = (n, window, cb) ->
+ rv = new tame.Rendezvous
+ nsent = 0
+ nrecv = 0
+ while nrecv < n
+ if nsent - nrecv < window and nsent < n
+ call nsent, rv.id(nsent).defer()
+ nsent++
+ else
+ await rv.wait defer(res)
+ slots[res] |= 4
+ nrecv++
+ cb()
+
+ await window 10, 3, defer()
+ res = true
+ for s in slots
+ res = false unless s == 7
+ cb(res, {})
+
+##----------------------------------------------------------------------
+
+ atest "pipeliner example", (cb) ->
+
+ slots = []
+ call = (i, cb) ->
+ slots[i] = 1
+ await setTimeout(defer(), 3*Math.random())
+ slots[i] |= 2
+ cb(4)
+
+ window = (n, window, cb) ->
+ tmp = {}
+ p = new tamelib.Pipeliner window, .01
+ for i in [0..n]
+ await p.waitInQueue defer()
+ call i, p.defer tmp[i]
+ await p.flush defer()
+ for k,v of tmp
+ slots[k] |= tmp[k]
+ cb()
+
+ await window 100, 10, defer()
+
+ ok = true
+ for s in slots
+ ok = false unless s == 7
+ cb(ok, {})
Please sign in to comment.
Something went wrong with that request. Please try again.