mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
fixing block comment indentation
This commit is contained in:
5
Cakefile
5
Cakefile
@@ -225,11 +225,12 @@ runTests = (CoffeeScript) ->
|
||||
|
||||
# Run every test in the `test` folder, recording failures.
|
||||
files = fs.readdirSync 'test'
|
||||
for file in files when file.match /\.coffee$/i
|
||||
for file in files when file.match /\.(lit)?coffee$/i
|
||||
literate = path.extname(file) is '.litcoffee'
|
||||
currentFile = filename = path.join 'test', file
|
||||
code = fs.readFileSync filename
|
||||
try
|
||||
CoffeeScript.run code.toString(), {filename}
|
||||
CoffeeScript.run code.toString(), {filename, literate}
|
||||
catch error
|
||||
failures.push {filename, error}
|
||||
return !failures.length
|
||||
|
||||
@@ -487,7 +487,7 @@
|
||||
if (HEREDOC_ILLEGAL.test(doc)) {
|
||||
this.error("block comment cannot contain \"*/\", starting");
|
||||
}
|
||||
if (doc.indexOf('\n') <= 0) {
|
||||
if (doc.indexOf('\n') < 0) {
|
||||
return doc;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -389,7 +389,7 @@ exports.Lexer = class Lexer
|
||||
if herecomment
|
||||
if HEREDOC_ILLEGAL.test doc
|
||||
@error "block comment cannot contain \"*/\", starting"
|
||||
return doc if doc.indexOf('\n') <= 0
|
||||
return doc if doc.indexOf('\n') < 0
|
||||
else
|
||||
while match = HEREDOC_INDENT.exec doc
|
||||
attempt = match[1]
|
||||
|
||||
29
test/literate.litcoffee
Normal file
29
test/literate.litcoffee
Normal file
@@ -0,0 +1,29 @@
|
||||
comment comment
|
||||
|
||||
test "basic literate CoffeeScript parsing", ->
|
||||
ok yes
|
||||
|
||||
now with a...
|
||||
|
||||
test "broken up indentation", ->
|
||||
|
||||
... broken up ...
|
||||
|
||||
do ->
|
||||
|
||||
... nested block.
|
||||
|
||||
ok yes
|
||||
|
||||
Code in `backticks is not parsed` and...
|
||||
|
||||
test "comments in indented blocks work", ->
|
||||
do ->
|
||||
do ->
|
||||
# Regular comment.
|
||||
|
||||
###
|
||||
Block comment.
|
||||
###
|
||||
|
||||
ok yes
|
||||
Reference in New Issue
Block a user