1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:07:36 +00:00

LibJS: Throw TypeError when calling non-function object

We now have "undefined is not a function" :^)
This commit is contained in:
Linus Groh 2020-03-30 13:41:17 +01:00 committed by Andreas Kling
parent d4e3688f4f
commit fb0401871c
2 changed files with 34 additions and 2 deletions

View file

@ -0,0 +1,31 @@
function assert(x) { if (!x) throw 1; }
try {
try {
var b = true;
b();
} catch(e) {
assert(e.name === "TypeError");
assert(e.message === "true is not a function");
}
try {
var n = 100 + 20 + 3;
n();
} catch(e) {
assert(e.name === "TypeError");
assert(e.message === "123 is not a function");
}
try {
var o = {};
o.a();
} catch(e) {
assert(e.name === "TypeError");
assert(e.message === "undefined is not a function");
}
console.log("PASS");
} catch(e) {
console.log("FAIL: " + e);
}