1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:57:35 +00:00

LibJS: Reorganize tests into subfolders

This commit is contained in:
Matthew Olsson 2020-07-02 16:09:21 -07:00 committed by Andreas Kling
parent 21064a1883
commit 4c48c9d69d
213 changed files with 10 additions and 2 deletions

View file

@ -0,0 +1,39 @@
load("test-common.js");
try {
let p = new Proxy(() => 5, { apply: null });
assert(p() === 5);
let p = new Proxy(() => 5, { apply: undefined });
assert(p() === 5);
let p = new Proxy(() => 5, {});
assert(p() === 5);
const f = (a, b) => a + b;
const handler = {
apply(target, this_, arguments) {
assert(target === f);
assert(this_ === handler);
if (arguments[2])
return arguments[0] * arguments[1];
return f(...arguments);
},
};
p = new Proxy(f, handler);
assert(p(2, 4) === 6);
assert(p(2, 4, true) === 8);
// Invariants
[{}, [], new Proxy({}, {})].forEach(item => {
assertThrowsError(() => {
new Proxy(item, {})();
}, {
error: TypeError,
message: "[object ProxyObject] is not a function",
});
});
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}