summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests/parser-line-terminators.js
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-01-15 17:26:06 +0100
committerLinus Groh <mail@linusgroh.de>2022-01-16 01:54:48 +0100
commite8519156bcb1d142a5a43cfcd8891c48015297fc (patch)
treed267a6788f53f1de8e506c829860af1dca2b1ef8 /Userland/Libraries/LibJS/Tests/parser-line-terminators.js
parent13fe4e8c64972ef91af9035a746f3fb55dff9c8e (diff)
downloadserenity-e8519156bcb1d142a5a43cfcd8891c48015297fc.zip
LibJS: Implement create_dynamic_function() according to the spec
The three major changes are: - Parsing parameters, the function body, and then the full assembled function source all separately. This is required by the spec, as function parameters and body must be valid each on their own, which cannot be guaranteed if we only ever parse the full function. - Returning an ECMAScriptFunctionObject instead of a FunctionExpression that needs to be evaluated separately. This vastly simplifies the {Async,AsyncGenerator,Generator,}Function constructor implementations. Drop '_node' from the function name accordingly. - The prototype is now determined via GetPrototypeFromConstructor and passed to OrdinaryFunctionCreate.
Diffstat (limited to 'Userland/Libraries/LibJS/Tests/parser-line-terminators.js')
-rw-r--r--Userland/Libraries/LibJS/Tests/parser-line-terminators.js30
1 files changed, 24 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/Tests/parser-line-terminators.js b/Userland/Libraries/LibJS/Tests/parser-line-terminators.js
index 9b75eb4af0..63c7009f18 100644
--- a/Userland/Libraries/LibJS/Tests/parser-line-terminators.js
+++ b/Userland/Libraries/LibJS/Tests/parser-line-terminators.js
@@ -13,31 +13,46 @@ function anonymous(
test("LINE FEED is a line terminator", () => {
expect(() => {
Function("\n\n@");
- }).toThrowWithMessage(SyntaxError, "line: 5, column: 1");
+ }).toThrowWithMessage(
+ SyntaxError,
+ "Unexpected token Invalid. Expected CurlyClose (line: 4, column: 1)"
+ );
});
test("CARRIAGE RETURN is a line terminator", () => {
expect(() => {
Function("\r\r@");
- }).toThrowWithMessage(SyntaxError, "line: 5, column: 1");
+ }).toThrowWithMessage(
+ SyntaxError,
+ "Unexpected token Invalid. Expected CurlyClose (line: 4, column: 1)"
+ );
});
test("LINE SEPARATOR is a line terminator", () => {
expect(() => {
Function("

@");
- }).toThrowWithMessage(SyntaxError, "line: 5, column: 1");
+ }).toThrowWithMessage(
+ SyntaxError,
+ "Unexpected token Invalid. Expected CurlyClose (line: 4, column: 1)"
+ );
});
test("PARAGRAPH SEPARATOR is a line terminator", () => {
expect(() => {
Function("

@");
- }).toThrowWithMessage(SyntaxError, "line: 5, column: 1");
+ }).toThrowWithMessage(
+ SyntaxError,
+ "Unexpected token Invalid. Expected CurlyClose (line: 4, column: 1)"
+ );
});
test("CR LF is counted as only one line terminator", () => {
expect(() => {
Function("\r\n\r\n@");
- }).toThrowWithMessage(SyntaxError, "line: 5, column: 1");
+ }).toThrowWithMessage(
+ SyntaxError,
+ "Unexpected token Invalid. Expected CurlyClose (line: 4, column: 1)"
+ );
});
test("LF/CR are not allowed in string literal", () => {
@@ -55,7 +70,10 @@ 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@");
- }).toThrowWithMessage(SyntaxError, "line: 9, column: 1");
+ }).toThrowWithMessage(
+ SyntaxError,
+ "Unexpected token Invalid. Expected CurlyClose (line: 8, column: 1)"
+ );
});
test("all line terminators are valid for line continuations", () => {