|
@@ -61,6 +61,34 @@ test("line terminators can be mixed (but please don't)", () => {
|
|
|
test("all line terminators are valid for line continuations", () => {
|
|
|
expect(Function('return "a\\\nb"')()).toBe("ab");
|
|
|
expect(Function('return "a\\\rb"')()).toBe("ab");
|
|
|
+ expect(Function('return "a\\\r\nb"')()).toBe("ab");
|
|
|
expect(Function('return "a\\
b"')()).toBe("ab");
|
|
|
expect(Function('return "a\\
b"')()).toBe("ab");
|
|
|
});
|
|
|
+
|
|
|
+test("template-literals raw and real value", () => {
|
|
|
+ let lastTemplate;
|
|
|
+ let lastRaw;
|
|
|
+
|
|
|
+ function tag(cs) {
|
|
|
+ lastTemplate = cs[0];
|
|
|
+ lastRaw = cs.raw[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ function checkTemplate(string_value, expected_template, expected_raw) {
|
|
|
+ eval("tag`" + string_value + "`");
|
|
|
+ expect(lastTemplate).toBe(expected_template);
|
|
|
+ expect(lastRaw).toBe(expected_raw);
|
|
|
+ }
|
|
|
+
|
|
|
+ checkTemplate("", "", "");
|
|
|
+ checkTemplate("\n", "\n", "\n");
|
|
|
+ checkTemplate("\r", "\n", "\n");
|
|
|
+ checkTemplate("\r\n", "\n", "\n");
|
|
|
+ checkTemplate("\n\r\n", "\n\n", "\n\n");
|
|
|
+
|
|
|
+ checkTemplate("a\\\nb", "ab", "a\\\nb");
|
|
|
+ checkTemplate("a\\\rb", "ab", "a\\\nb");
|
|
|
+ checkTemplate("a\\
b", "ab", "a\\
b");
|
|
|
+ checkTemplate("a\\
b", "ab", "a\\
b");
|
|
|
+});
|