From 49e3a91d6769226e050bf0127a1a4672fb9bcd64 Mon Sep 17 00:00:00 2001 From: Gerald Lewis Date: Sun, 4 Sep 2011 12:18:38 -0400 Subject: [PATCH] tests for #1195: lex out semicolons before newlines and at end of program --- test/formatting.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/formatting.coffee b/test/formatting.coffee index 89bfdfce..e5c2cdee 100644 --- a/test/formatting.coffee +++ b/test/formatting.coffee @@ -121,3 +121,16 @@ test "indented heredoc", -> test "#1492: Nested blocks don't cause double semicolons", -> js = CoffeeScript.compile '(0;0)' eq -1, js.indexOf ';;' + +test "#1195 Ignore trailing semicolons (before newlines or as the last char in a program)", -> + preNewline = (numSemicolons) -> + """ + nonce = {}; nonce2 = {} + f = -> nonce#{Array(numSemicolons+1).join(';')} + nonce2 + unless f() is nonce then throw new Error('; before linebreak should = newline') + """ + CoffeeScript.run(preNewline(n), bare: true) for n in [1,2,3] + + lastChar = '-> lastChar;' + doesNotThrow -> CoffeeScript.compile lastChar, bare: true