Sha256: 75730bfc44d5a9e77a803597cee49978e7ded8d4f1f4553c73886bcf00140c9c

Contents?: true

Size: 1.63 KB

Versions: 10

Compression:

Stored size: 1.63 KB

Contents

# Compilation
# -----------

# helper to assert that a string should fail compilation
cantCompile = (code) ->
  throws -> CoffeeScript.compile code


test "ensure that carriage returns don't break compilation on Windows", ->
  doesNotThrow -> CoffeeScript.compile 'one\r\ntwo', bare: on

test "--bare", ->
  eq -1, CoffeeScript.compile('x = y', bare: on).indexOf 'function'
  ok 'passed' is CoffeeScript.eval '"passed"', bare: on, filename: 'test'

test "header (#1778)", ->
  header = "// Generated by CoffeeScript #{CoffeeScript.VERSION}\n"
  eq 0, CoffeeScript.compile('x = y', header: on).indexOf header

test "header is disabled by default", ->
  header = "// Generated by CoffeeScript #{CoffeeScript.VERSION}\n"
  eq -1, CoffeeScript.compile('x = y').indexOf header

test "multiple generated references", ->
  a = {b: []}
  a.b[true] = -> this == a.b
  c = 0
  d = []
  ok a.b[0<++c<2] d...

test "splat on a line by itself is invalid", ->
  cantCompile "x 'a'\n...\n"

test "Issue 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'

test "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
  '''

test "#1050", ->
  cantCompile "### */ ###"

test "#1106: __proto__ compilation", ->
  object = eq
  @["__proto__"] = true
  ok __proto__

test "reference named hasOwnProperty", ->
  CoffeeScript.compile 'hasOwnProperty = 0; a = 1'

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
guard-mthaml-0.4.0 vendor/coffeescript/coffeescript/tests/cases/compilation.coffee
guard-mthaml-0.3.1 vendor/coffeescript/coffeescript/tests/cases/compilation.coffee
guard-mthaml-0.3.0 vendor/coffeescript/coffeescript/tests/cases/compilation.coffee
guard-mthaml-0.2.5 vendor/coffeescript/coffeescript/tests/cases/compilation.coffee
guard-mthaml-0.2.4 vendor/coffeescript/coffeescript/tests/cases/compilation.coffee
guard-mthaml-0.2.3 vendor/coffeescript/coffeescript/tests/cases/compilation.coffee
guard-mthaml-0.2.2 vendor/coffeescript/coffeescript/tests/cases/compilation.coffee
guard-mthaml-0.2.1 vendor/coffeescript/coffeescript/tests/cases/compilation.coffee
guard-mthaml-0.2.0 vendor/coffeescript/coffeescript/tests/cases/compilation.coffee
guard-mthaml-0.1.0 vendor/coffeescript/coffeescript/tests/cases/compilation.coffee