added another language extension test for a << b into a.push(b)

This commit is contained in:
Jeremy Ashkenas 2010-03-23 20:42:40 -04:00
parent 5a4d401582
commit ad93d2fe4d
1 changed files with 13 additions and 0 deletions

View File

@ -54,5 +54,18 @@ js: CoffeeScript.compile 'puts %w{one two three}', {no_wrap: on}
ok js is 'puts(["one", "two", "three"]);'
# Finally, let's try an extension that converts `a << b` into `a.push(b)`.
CoffeeScript.extend ->
return false unless @chunk.match(/^<</)
@i: + 2
@token 'PROPERTY_ACCESS', '.'
@token 'IDENTIFIER', 'push'
js: CoffeeScript.compile 'a << b', {no_wrap: on}
ok js is 'a.push(b);'
Lexer.extensions: []