diff options
author | 2016-06-22 15:38:11 +0000 | |
---|---|---|
committer | 2016-06-23 11:03:43 +0000 | |
commit | f3dc0df65c7832b05df5e642af21401b52afbc9a (patch) | |
tree | 1cb4fd7d3e7cbcd5ade67928d382fc595ed5d6b7 /src/test/java/com/google | |
parent | 0861282d10265201ac3c307668ac553e597d14a8 (diff) |
Fix handling of backslash-escaped CRLF line terminators.
The character sequences in the test cases behave the same way Python does.
Fixed #1306.
--
MOS_MIGRATED_REVID=125568600
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java | 19 |
1 files changed, 19 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 31ec265f85..db49b4ed2a 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 @@ -261,6 +261,24 @@ public class LexerTest { } @Test + public void testEscapedCrlfInString() throws Exception { + assertEquals("STRING(ab) NEWLINE EOF", + values(tokens("'a\\\r\nb'"))); + assertEquals("STRING(ab) NEWLINE EOF", + values(tokens("\"a\\\r\nb\""))); + assertEquals("STRING(ab) NEWLINE EOF", + values(tokens("\"\"\"a\\\r\nb\"\"\""))); + assertEquals("STRING(ab) NEWLINE EOF", + values(tokens("'''a\\\r\nb'''"))); + assertEquals("STRING(a\\\nb) NEWLINE EOF", + values(tokens("r'a\\\r\nb'"))); + assertEquals("STRING(a\\\nb) NEWLINE EOF", + values(tokens("r\"a\\\r\nb\""))); + assertEquals("STRING(a\\\n\\\nb) NEWLINE EOF", + values(tokens("r\"a\\\r\n\\\nb\""))); + } + + @Test public void testRawString() throws Exception { assertEquals("STRING(abcd) NEWLINE EOF", values(tokens("r'abcd'"))); @@ -414,6 +432,7 @@ public class LexerTest { public void testBackslash() throws Exception { assertEquals("IDENTIFIER IDENTIFIER NEWLINE EOF", names(tokens("a\\\nb"))); + assertEquals("IDENTIFIER IDENTIFIER NEWLINE EOF", names(tokens("a\\\r\nb"))); assertEquals("IDENTIFIER ILLEGAL IDENTIFIER NEWLINE EOF", names(tokens("a\\ b"))); assertEquals("IDENTIFIER LPAREN INT RPAREN NEWLINE EOF", |