mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
LibJS: Allow all line terminators to be used for line continuations
This commit is contained in:
parent
1319ad476d
commit
66e315959d
3 changed files with 21 additions and 4 deletions
|
@ -18,13 +18,13 @@ test("CARRIAGE RETURN is a line terminator", () => {
|
|||
|
||||
test("LINE SEPARATOR is a line terminator", () => {
|
||||
expect(() => {
|
||||
Function(`
@`);
|
||||
Function("
@");
|
||||
}).toThrowWithMessage(SyntaxError, "line: 3, column: 1");
|
||||
});
|
||||
|
||||
test("PARAGRAPH SEPARATOR is a line terminator", () => {
|
||||
expect(() => {
|
||||
Function(`
@`);
|
||||
Function("
@");
|
||||
}).toThrowWithMessage(SyntaxError, "line: 3, column: 1");
|
||||
});
|
||||
|
||||
|
@ -48,6 +48,13 @@ test("LS/PS are allowed in string literal", () => {
|
|||
|
||||
test("line terminators can be mixed (but please don't)", () => {
|
||||
expect(() => {
|
||||
Function(`\r\
\r\n
\n\r@`);
|
||||
Function("\r
\r\n
\n\r@");
|
||||
}).toThrowWithMessage(SyntaxError, "line: 7, column: 1");
|
||||
});
|
||||
|
||||
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\\
b"')()).toBe("ab");
|
||||
expect(Function('return "a\\
b"')()).toBe("ab");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue