mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-16 18:44:56 -05:00
Fix #1069. Non-callable literals shouldn't compile
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
# shared identity function
|
||||
id = (_) -> if arguments.length is 1 then _ else [arguments...]
|
||||
|
||||
# helper to assert that a string should fail compilation
|
||||
cantCompile = (code) ->
|
||||
throws -> CoffeeScript.compile code
|
||||
|
||||
test "basic argument passing", ->
|
||||
|
||||
@@ -649,3 +652,25 @@ test "Loose tokens inside of explicit call lists", ->
|
||||
bar = first( first
|
||||
one: 1)
|
||||
eq bar.one, 1
|
||||
|
||||
test "Non-callable literals shouldn't compile", ->
|
||||
cantCompile '1(2)'
|
||||
cantCompile '1 2'
|
||||
cantCompile '/t/(2)'
|
||||
cantCompile '/t/ 2'
|
||||
cantCompile '///t///(2)'
|
||||
cantCompile '///t/// 2'
|
||||
cantCompile "''(2)"
|
||||
cantCompile "'' 2"
|
||||
cantCompile '""(2)'
|
||||
cantCompile '"" 2'
|
||||
cantCompile '""""""(2)'
|
||||
cantCompile '"""""" 2'
|
||||
cantCompile '{}(2)'
|
||||
cantCompile '{} 2'
|
||||
cantCompile '[](2)'
|
||||
cantCompile '[] 2'
|
||||
cantCompile '[2..9] 2'
|
||||
cantCompile '[2..9](2)'
|
||||
cantCompile '[1..10][2..9] 2'
|
||||
cantCompile '[1..10][2..9](2)'
|
||||
|
||||
@@ -130,5 +130,5 @@ test "soaked constructor invocations with caching and property access", ->
|
||||
eq 1, semaphore
|
||||
|
||||
test "soaked function invocation safe on non-functions", ->
|
||||
eq undefined, 0?(1)
|
||||
eq undefined, 0? 1, 2
|
||||
eq undefined, (0)?(1)
|
||||
eq undefined, (0)? 1, 2
|
||||
|
||||
Reference in New Issue
Block a user