aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java30
1 files changed, 27 insertions, 3 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 c60067dbef..45e66bf060 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
@@ -247,7 +247,14 @@ public class LexerTest {
assertEquals("STRING(\\$$) NEWLINE EOF", values(tokens("'\\$$'")));
assertEquals("STRING(ab) NEWLINE EOF",
values(tokens("'a\\\nb'"))); // escape end of line
+ assertEquals("STRING(abcd) NEWLINE EOF",
+ values(tokens("\"ab\\ucd\"")));
+ assertEquals("/some/path.txt:1: escape sequence not implemented: \\u",
+ lastError.toString());
+ }
+ @Test
+ public void testRawString() throws Exception {
assertEquals("STRING(abcd) NEWLINE EOF",
values(tokens("r'abcd'")));
assertEquals("STRING(abcd) NEWLINE EOF",
@@ -261,9 +268,26 @@ public class LexerTest {
assertEquals("STRING(ab) IDENTIFIER(r) NEWLINE EOF",
values(tokens("r'ab'r")));
- assertEquals("STRING(abcd) NEWLINE EOF",
- values(tokens("\"ab\\ucd\"")));
- assertEquals("/some/path.txt:1: escape sequence not implemented: \\u",
+ // Unterminated raw string
+ values(tokens("r'\\'")); // r'\'
+ assertEquals("/some/path.txt:1: unterminated string literal at eof",
+ lastError.toString());
+ }
+
+ @Test
+ public void testTripleRawString() throws Exception {
+ // r'''a\ncd'''
+ assertEquals("STRING(ab\\ncd) NEWLINE EOF",
+ values(tokens("r'''ab\\ncd'''")));
+ // r"""ab
+ // cd"""
+ assertEquals(
+ "STRING(ab\ncd) NEWLINE EOF",
+ values(tokens("\"\"\"ab\ncd\"\"\"")));
+
+ // Unterminated raw string
+ values(tokens("r'''\\'''")); // r'''\'''
+ assertEquals("/some/path.txt:1: unterminated string literal at eof",
lastError.toString());
}