ladybird/Libraries/LibJS/Tests/Proxy.js
Matthew Olsson 78155a6668 LibJS: Consolidate error messages into ErrorTypes.h
Now, exceptions can be thrown with
interpreter.throw_exception<T>(ErrorType:TYPE, "format", "args",
"here").
2020-06-11 07:46:20 +02:00

30 lines
634 B
JavaScript

load("test-common.js");
try {
new Proxy({}, {});
assertThrowsError(() => {
new Proxy();
}, {
error: TypeError,
message: "Proxy constructor requires at least two arguments",
});
assertThrowsError(() => {
Proxy();
}, {
error: TypeError,
message: "Proxy must be called with the 'new' operator",
});
assertThrowsError(() => {
new Proxy(1, {});
}, {
error: TypeError,
message: "Expected target argument of Proxy constructor to be object, got 1",
});
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}