Permalink
Browse files

yet more tests. this is the one that chris pointed out that had me re…

…evaluate scoping.
  • Loading branch information...
1 parent b6d5285 commit e60d3dc5905c2e30f382acc2c99ba6b3931858df @maxtaco committed Dec 14, 2011
Showing with 30 additions and 0 deletions.
  1. +30 −0 test/tame.coffee
View
@@ -251,3 +251,33 @@ atest "another autocb gotcha", (cb) ->
ok = true
cb(ok, {})
+atest "fat arrow versus tame", (cb) ->
+ class Foo
+ constructor : ->
+ @bindings = {}
+
+ addHandler : (key,cb) ->
+ @bindings[key] = cb
+
+ useHandler : (key, args...) ->
+ @bindings[key](args...)
+
+ delay : (autocb) ->
+ await delay defer()
+
+ addHandlers : ->
+ @addHandler "sleep1", (cb) =>
+ await delay defer()
+ await @delay defer()
+ cb(true)
+ @addHandler "sleep2", (cb) =>
+ await @delay defer()
+ await delay defer()
+ cb(true)
+
+ ok1 = ok2 = false
+ f = new Foo()
+ f.addHandlers()
+ await f.useHandler "sleep1", defer(ok1)
+ await f.useHandler "sleep2", defer(ok2)
+ cb(ok1 and ok2, {})

0 comments on commit e60d3dc

Please sign in to comment.