mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Make sure the indentation is consistent with the previous level.
This prevents mixing spaces and tabs in the same ‘block’ of code. Mixing is still allowed if each line uses the same mix and if the indentation level returns to 0. This breaks the literate coffeescript test that mixes spaces and tabs.
This commit is contained in:
@@ -76,7 +76,7 @@ test "#2516: Unicode spaces should not be part of identifiers", ->
|
||||
eq 5, {c: 5}[ 'c' ]
|
||||
|
||||
# A line where every space in non-breaking
|
||||
eq 1 + 1, 2
|
||||
eq 1 + 1, 2
|
||||
|
||||
test "don't accidentally stringify keywords", ->
|
||||
ok (-> this == 'this')() is false
|
||||
|
||||
@@ -254,3 +254,33 @@ test "#1275: allow indentation before closing brackets", ->
|
||||
a = 1
|
||||
)
|
||||
eq 1, a
|
||||
|
||||
test "don’t allow mixing of spaces and tabs for indentation", ->
|
||||
try
|
||||
CoffeeScript.compile '''
|
||||
new Layer
|
||||
x: 0
|
||||
y: 1
|
||||
'''
|
||||
ok no
|
||||
catch e
|
||||
eq 'indentation mismatch', e.message
|
||||
|
||||
test "indentation can be a mix of spaces and tabs, if each line is the same", ->
|
||||
doesNotThrow ->
|
||||
CoffeeScript.compile '''
|
||||
new Layer
|
||||
x: 0
|
||||
y: 1
|
||||
'''
|
||||
|
||||
test "each code block that starts at indentation 0 can use a different style", ->
|
||||
doesNotThrow ->
|
||||
CoffeeScript.compile '''
|
||||
new Layer
|
||||
x: 0
|
||||
y: 1
|
||||
new Layer
|
||||
x: 0
|
||||
y: 1
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user