Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 73 lines (52 sloc) 1.665 kB
dcbe62b @michaelficarra test reorganization waypoint 3
michaelficarra authored
1 # Compilation
2 # -----------
3
4 # helper to assert that a string should fail compilation
5 cantCompile = (code) ->
6 throws -> CoffeeScript.compile code
7
8
2b1aea8 @jashkenas testified compilation.coffee, removed empty command.coffee
authored
9 test "ensure that carriage returns don't break compilation on Windows", ->
10 doesNotThrow -> CoffeeScript.compile 'one\r\ntwo', bare: on
dcbe62b @michaelficarra test reorganization waypoint 3
michaelficarra authored
11
7efea4b @michaelficarra removed "globals" option of CoffeeScript.compile and enhanced fix from
michaelficarra authored
12 test "--bare", ->
13 eq -1, CoffeeScript.compile('x = y', bare: on).indexOf 'function'
2b1aea8 @jashkenas testified compilation.coffee, removed empty command.coffee
authored
14 ok 'passed' is CoffeeScript.eval '"passed"', bare: on, filename: 'test'
dcbe62b @michaelficarra test reorganization waypoint 3
michaelficarra authored
15
36a6986 @TrevorBurnham Adding support for a header with version number to CoffeeScript.compi…
TrevorBurnham authored
16 test "header (#1778)", ->
17 header = "// Generated by CoffeeScript #{CoffeeScript.VERSION}\n"
18 eq 0, CoffeeScript.compile('x = y', header: on).indexOf header
19
16e297a @TrevorBurnham Adding test to ensure that header is disabled by default
TrevorBurnham authored
20 test "header is disabled by default", ->
21 header = "// Generated by CoffeeScript #{CoffeeScript.VERSION}\n"
22 eq -1, CoffeeScript.compile('x = y').indexOf header
23
2b1aea8 @jashkenas testified compilation.coffee, removed empty command.coffee
authored
24 test "multiple generated references", ->
dcbe62b @michaelficarra test reorganization waypoint 3
michaelficarra authored
25 a = {b: []}
26 a.b[true] = -> this == a.b
27 c = 0
28 d = []
29 ok a.b[0<++c<2] d...
30
2b1aea8 @jashkenas testified compilation.coffee, removed empty command.coffee
authored
31 test "splat on a line by itself is invalid", ->
32 cantCompile "x 'a'\n...\n"
33
34 test "Issue 750", ->
dcbe62b @michaelficarra test reorganization waypoint 3
michaelficarra authored
35
2b1aea8 @jashkenas testified compilation.coffee, removed empty command.coffee
authored
36 cantCompile 'f(->'
dcbe62b @michaelficarra test reorganization waypoint 3
michaelficarra authored
37
2b1aea8 @jashkenas testified compilation.coffee, removed empty command.coffee
authored
38 cantCompile 'a = (break)'
dcbe62b @michaelficarra test reorganization waypoint 3
michaelficarra authored
39
2b1aea8 @jashkenas testified compilation.coffee, removed empty command.coffee
authored
40 cantCompile 'a = (return 5 for item in list)'
dcbe62b @michaelficarra test reorganization waypoint 3
michaelficarra authored
41
2b1aea8 @jashkenas testified compilation.coffee, removed empty command.coffee
authored
42 cantCompile 'a = (return 5 while condition)'
dcbe62b @michaelficarra test reorganization waypoint 3
michaelficarra authored
43
2b1aea8 @jashkenas testified compilation.coffee, removed empty command.coffee
authored
44 cantCompile 'a = for x in y\n return 5'
dcbe62b @michaelficarra test reorganization waypoint 3
michaelficarra authored
45
2b1aea8 @jashkenas testified compilation.coffee, removed empty command.coffee
authored
46 test "Issue #986: Unicode identifiers", ->
47 λ = 5
48 eq λ, 5
dcbe62b @michaelficarra test reorganization waypoint 3
michaelficarra authored
49
50 test "don't accidentally stringify keywords", ->
51 ok (-> this == 'this')() is false
9b3197c @jashkenas #1026
authored
52
53 test "#1026", ->
54 cantCompile '''
55 if a
56 b
57 else
58 c
59 else
60 d
61 '''
4b78790 @jashkenas Making #1050 a syntax error.
authored
62
63 test "#1050", ->
ac85fa2 @jashkenas merged stable
authored
64 cantCompile "### */ ###"
cd8492d @michaelficarra test for #1106
michaelficarra authored
65
66 test "#1106: __proto__ compilation", ->
67 object = eq
5cd5821 @michaelficarra #1106 test case: making sure `__proto__` exists in case v8 ever remov…
michaelficarra authored
68 @["__proto__"] = true
cd8492d @michaelficarra test for #1106
michaelficarra authored
69 ok __proto__
d0b8cde @michaelficarra 1e25c9da306f38ddf7bd3c63ed7c9540b75384e0#commitcomment-719177
michaelficarra authored
70
71 test "reference named hasOwnProperty", ->
72 CoffeeScript.compile 'hasOwnProperty = 0; a = 1'
Something went wrong with that request. Please try again.