1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:48:11 +00:00
serenity/Libraries/LibJS/Tests/builtins
Linus Groh a10d09faba LibJS: Tweak generated source in 'new Function()' to match ES 2015 spec
ES 5(.1) described parsing of the function body string as:

https://www.ecma-international.org/ecma-262/5.1/#sec-15.3.2.1

7. If P is not parsable as a FormalParameterList[opt] then throw a SyntaxError exception.
8. If body is not parsable as FunctionBody then throw a SyntaxError exception.

We implemented it as building the source string of a complete function
and feeding that to the parser, with the same outcome. ES 2015+ does
exactly that, but with newlines at certain positions:

https://tc39.es/ecma262/#sec-createdynamicfunction

16. Let bodyString be the string-concatenation of 0x000A (LINE FEED), ? ToString(bodyArg), and 0x000A (LINE FEED).
17. Let prefix be the prefix associated with kind in Table 49.
18. Let sourceString be the string-concatenation of prefix, " anonymous(", P, 0x000A (LINE FEED), ") {", bodyString, and "}".

This patch updates the generated source string to match these
requirements. This will make certain edge cases work, e.g.
'new Function("-->")', where the user supplied input must be placed on
its own line to be valid syntax.
2020-10-29 22:27:55 +01:00
..
Array LibJS: Implement rules for duplicate function parameters 2020-10-25 12:56:02 +01:00
BigInt Everywhere: Fix typos 2020-10-02 16:03:17 +02:00
Boolean LibJS: Indent tests with 4 spaces instead of 2 2020-07-06 23:40:35 +02:00
Date LibJS: Add some more tests, mostly around leap years 2020-08-26 08:52:07 +02:00
Error LibJS: Indent tests with 4 spaces instead of 2 2020-07-06 23:40:35 +02:00
Function LibJS: Tweak generated source in 'new Function()' to match ES 2015 spec 2020-10-29 22:27:55 +01:00
functions LibJS: Split isNaN tests into multiple sections 2020-07-06 23:40:35 +02:00
Infinity LibJS: Indent tests with 4 spaces instead of 2 2020-07-06 23:40:35 +02:00
JSON LibJS: Handle getter exception in JSONObject::serialize_json_property() 2020-09-19 14:17:22 +02:00
Math JS Tests: Disable the one failing test when running test-js in Serenity 2020-08-25 21:23:10 +02:00
NaN LibJS: Indent tests with 4 spaces instead of 2 2020-07-06 23:40:35 +02:00
Number LibJS: Add Number.prototype.toString 2020-07-15 18:24:55 +02:00
Object LibJS: Don't change offset when reconfiguring property in unique shape 2020-10-10 23:25:00 +02:00
Proxy LibJS: Indent tests with 4 spaces instead of 2 2020-07-06 23:40:35 +02:00
Reflect LibJS: Object.preventExtensions should allow property modfication 2020-07-07 10:47:10 +02:00
String LibJS: Implement String.prototype.charCodeAt 2020-07-22 15:48:01 +02:00
Symbol LibJS: Allow conversion from Symbol to String via explicit String() call 2020-08-22 10:52:40 +02:00