Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

58 lines (41 sloc) 1.102 kb
# Compilation
# -----------
# TODO: refactor compilation tests
# helper to assert that a string should fail compilation
cantCompile = (code) ->
throws -> CoffeeScript.compile code
# Ensure that carriage returns don't break compilation on Windows.
doesNotThrow -> CoffeeScript.compile 'one\r\ntwo', bare: on
# `globals: on` removes `var`s
eq -1, CoffeeScript.compile('x = y', bare: on, globals: on).indexOf 'var'
ok 'passed' is CoffeeScript.eval '"passed"', bare: on, filename: 'test'
# multiple generated references
(->
a = {b: []}
a.b[true] = -> this == a.b
c = 0
d = []
ok a.b[0<++c<2] d...
)()
# Splat on a line by itself is invalid.
cantCompile "x 'a'\n...\n"
#750
cantCompile 'f(->'
cantCompile 'a = (break)'
cantCompile 'a = (return 5 for item in list)'
cantCompile 'a = (return 5 while condition)'
cantCompile 'a = for x in y\n return 5'
# Issue #986: Unicode identifiers.
λ = 5
eq λ, 5
test "don't accidentally stringify keywords", ->
ok (-> this == 'this')() is false
test "#1026", ->
cantCompile '''
if a
b
else
c
else
d
'''
Jump to Line
Something went wrong with that request. Please try again.