Permalink
Browse files

take regtests in the hizzie!

  • Loading branch information...
1 parent ba63b4e commit 42690b1e9c7723b31f5aaebb81319357abd29cd8 @maxtaco committed Dec 3, 2011
Showing with 34 additions and 2 deletions.
  1. +2 −2 Cakefile
  2. +32 −0 test/tame.coffee
View
@@ -185,9 +185,9 @@ runTests = (CoffeeScript) ->
e.description = description if description?
e.source = fn.toString() if fn.toString?
failures.push filename: currentFile, error: e
-
+
# An async testing primitive
- global.atest = (description, fn, cb) ->
+ global.atest = (description, fn) ->
fn.test = { description, currentFile }
await fn.call(fn, defer(ok, e))
if ok
View
@@ -0,0 +1,32 @@
+
+atest "basic tame waiting", (cb) ->
+ i = 1
+ await setTimeout(defer(), 10)
+ i++
+ cb(i == 2, {})
+
+foo = (i, cb) ->
+ await setTimeout(defer(), i);
+ cb(i)
+
+atest "basic tame waiting", (cb) ->
+ i = 1
+ await setTimeout(defer(), 10)
+ i++
+ cb(i == 2, {})
+
+atest "basic tame trigger values", (cb) ->
+ i = 10
+ await foo(i, defer (j))
+ cb(i == j, {})
+
+atest "basic tame set structs", (cb) ->
+ field = "yo"
+ i = 10
+ obj = { cat : { dog : 0 } }
+ await
+ foo(i, defer(obj.cat[field]))
+ field = "bar" # change the field to make sure that we captured "yo"
+ cb(obj.cat.yo == i, {})
+
+

0 comments on commit 42690b1

Please sign in to comment.