diff options
author | 2016-05-24 10:42:34 +0000 | |
---|---|---|
committer | 2016-05-24 11:58:17 +0000 | |
commit | 34d4e6f1bbe80e8b0d42caddc22b5b941a3efeb1 (patch) | |
tree | 68a2af9c00deeca426f617e0442d2f384b97b14a /src/test/java | |
parent | d654c550a385a94da0388d77a9482e802ceb4aba (diff) |
Make the parser handle CRLF correctly.
Fixes #1300 .
--
MOS_MIGRATED_REVID=123090421
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java b/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java index 45e66bf060..31ec265f85 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java @@ -169,6 +169,13 @@ public class LexerTest { } @Test + public void testCrLf() throws Exception { + assertEquals("NEWLINE EOF", names(tokens("\r\n\r\n"))); + assertEquals("NEWLINE INT NEWLINE EOF", names(tokens("\r\n\r1\r\r\n"))); + assertEquals("COMMENT NEWLINE COMMENT NEWLINE EOF", names(tokens("# foo\r\n# bar\r\n"))); + } + + @Test public void testIntegers() throws Exception { // Detection of MINUS immediately following integer constant proves we // don't consume too many chars. @@ -338,6 +345,20 @@ public class LexerTest { } @Test + public void testIndentationWithCrLf() throws Exception { + assertEquals("INT(1) NEWLINE INDENT INT(2) NEWLINE OUTDENT NEWLINE EOF", + values(tokens("1\r\n 2\r\n"))); + assertEquals("INT(1) NEWLINE INDENT INT(2) NEWLINE OUTDENT NEWLINE EOF", + values(tokens("1\r\n 2\r\n\r\n"))); + assertEquals("INT(1) NEWLINE INDENT INT(2) NEWLINE INDENT INT(3) NEWLINE OUTDENT INT(4) " + + "NEWLINE OUTDENT INT(5) NEWLINE EOF", + values(tokens("1\r\n 2\r\n 3\r\n 4\r\n5"))); + assertEquals( + "INT(1) NEWLINE INDENT INT(2) NEWLINE INT(3) NEWLINE OUTDENT INT(4) NEWLINE EOF", + values(tokens("1\r\n 2\r\n\r\n 3\r\n4"))); + } + + @Test public void testIndentationInsideParens() throws Exception { // Indentation is ignored inside parens: assertEquals("INT(1) LPAREN INT(2) INT(3) INT(4) INT(5) NEWLINE EOF", |