Permalink
Browse files

add a few more test cases, and fix a few bugs in expressions

  • Loading branch information...
1 parent 6f2d96e commit ce2bdca08e52cd9762aa72dc190186444a22ddcc @maxtaco committed with Dec 19, 2011
Showing with 42 additions and 10 deletions.
  1. +8 −8 lib/coffee-script/parser.js
  2. +1 −1 lib/coffee-script/rewriter.js
  3. +1 −1 src/rewriter.coffee
  4. +32 −0 test/tame.coffee

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -303,7 +303,7 @@ IMPLICIT_UNSPACED_CALL = ['+', '-']
IMPLICIT_BLOCK = ['->', '=>', '{', '[', ',']
# Tokens that always mark the end of an implicit call for single-liners.
-IMPLICIT_END = ['POST_IF', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY', 'LOOP', 'TERMINATOR']
+IMPLICIT_END = ['POST_IF', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY', 'LOOP', 'TERMINATOR', 'AWAIT' ]
# Single-line flavors of block expressions that have unclosed endings.
# The grammar can't disambiguate them, so we insert the implicit indentation.
View
@@ -349,3 +349,35 @@ atest 'tame expressions', (cb) ->
cb(x+1)
ret = (await adder ((await adder 1, defer()) + (await adder 2, defer())), defer())
cb(ret == 6, {})
+
+atest 'arrays and objects', (cb) ->
+ id = "image data"
+ loadImage = (n, cb) ->
+ await delay defer()
+ cb id
+ arr = [
+ (await loadImage "file.jpg", defer()),
+ "another value" ]
+ obj =
+ i : (await loadImage "file.jpg", defer())
+ v : "another value"
+ cb(arr[0] is id and obj.i is id, {})
+
+atest 'chaining', (cb) ->
+ id = "image data"
+ class Img
+ render : -> id
+ loadImage = (n, cb) ->
+ await delay defer()
+ cb new Img
+ x = (await loadImage "test.png", defer()).render()
+ cb(x is id, {})
+
+atest 'nesting', (cb) ->
+ id = "image data"
+ loadImage = (n, cb) ->
+ await delay defer()
+ cb id
+ render = (x) -> x + x
+ y = render(await loadImage "test.png", defer())
+ cb(y is (id + id), {})

0 comments on commit ce2bdca

Please sign in to comment.