mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibJS: Implement constructor/non-constructor function calls
This adds Function::construct() for constructor function calls via `new` keyword. NativeFunction doesn't have constructor behaviour by default, ScriptFunction simply calls call() in construct()
This commit is contained in:
parent
a27884e4be
commit
849e2c77e4
Notes:
sideshowbarker
2024-07-19 08:00:53 +09:00
Author: https://github.com/linusg
Commit: 849e2c77e4
Pull-request: https://github.com/SerenityOS/serenity/pull/1546
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/bugaevc
11 changed files with 66 additions and 1 deletions
|
@ -25,6 +25,27 @@ try {
|
|||
assert(e.message === "undefined is not a function");
|
||||
}
|
||||
|
||||
try {
|
||||
Math();
|
||||
} catch(e) {
|
||||
assert(e.name === "TypeError");
|
||||
assert(e.message === "[object MathObject] is not a function");
|
||||
}
|
||||
|
||||
try {
|
||||
new Math();
|
||||
} catch(e) {
|
||||
assert(e.name === "TypeError");
|
||||
assert(e.message === "[object MathObject] is not a constructor");
|
||||
}
|
||||
|
||||
try {
|
||||
new isNaN();
|
||||
} catch(e) {
|
||||
assert(e.name === "TypeError");
|
||||
assert(e.message === "[object NativeFunction] is not a constructor");
|
||||
}
|
||||
|
||||
console.log("PASS");
|
||||
} catch(e) {
|
||||
console.log("FAIL: " + e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue