8233116: Escape Sequences For Line Continuation and White Space (Preview)

Reviewed-by: vromero, jlahoda, bchristi, mcimadamore
This commit is contained in:
Jim Laskey 2019-12-03 08:35:21 -04:00
parent 7afaaf1229
commit 234f326d79
6 changed files with 249 additions and 138 deletions

View file

@ -32,6 +32,8 @@
public class TextBlockLang {
public static void main(String... args) {
test1();
test2();
test3();
}
/*
@ -75,6 +77,30 @@ public class TextBlockLang {
""", 4);
}
/*
* Test escape-S.
*/
static void test2() {
if ('\s' != ' ') {
throw new RuntimeException("Failed character escape-S");
}
EQ("\s", " ");
EQ("""
\s
""", " \n");
}
/*
* Test escape line terminator.
*/
static void test3() {
EQ("""
abc \
""", "abc ");
EQ("\\\n".translateEscapes(), "");
EQ("\\\r\n".translateEscapes(), "");
EQ("\\\r".translateEscapes(), "");
}
/*
* Raise an exception if the string is not the expected length.