mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 22:30:31 +00:00
LibJS: Implement Error function/constructor
This commit is contained in:
parent
849e2c77e4
commit
ee6472fef2
Notes:
sideshowbarker
2024-07-19 08:00:48 +09:00
Author: https://github.com/linusg
Commit: ee6472fef2
Pull-request: https://github.com/SerenityOS/serenity/pull/1568
5 changed files with 134 additions and 0 deletions
29
Libraries/LibJS/Tests/Error.js
Normal file
29
Libraries/LibJS/Tests/Error.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var e;
|
||||
|
||||
e = Error();
|
||||
assert(e.name === "Error");
|
||||
assert(e.message === "");
|
||||
|
||||
e = Error(undefined);
|
||||
assert(e.name === "Error");
|
||||
assert(e.message === "");
|
||||
|
||||
e = Error("test");
|
||||
assert(e.name === "Error");
|
||||
assert(e.message === "test");
|
||||
|
||||
e = Error(42);
|
||||
assert(e.name === "Error");
|
||||
assert(e.message === "42");
|
||||
|
||||
e = Error(null);
|
||||
assert(e.name === "Error");
|
||||
assert(e.message === "null");
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue