mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:58:13 +00:00
LibJS: Implement Error function/constructor
This commit is contained in:
parent
849e2c77e4
commit
ee6472fef2
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