1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

LibJS: Indent tests with 4 spaces instead of 2

This commit is contained in:
Matthew Olsson 2020-07-06 07:37:45 -07:00 committed by Andreas Kling
parent 15de2eda2b
commit 1ef573eb30
261 changed files with 8536 additions and 8497 deletions

View file

@ -1,74 +1,74 @@
describe("[[Has]] trap normal behavior", () => {
test("forwarding when not defined in handler", () => {
expect("foo" in new Proxy({}, { has: null })).toBeFalse();
expect("foo" in new Proxy({}, { has: undefined })).toBeFalse();
expect("foo" in new Proxy({}, {})).toBeFalse();
});
test("correct arguments supplied to trap", () => {
let o = {};
let p = new Proxy(o, {
has(target, prop) {
expect(target).toBe(o);
expect(prop).toBe("foo");
return true;
},
test("forwarding when not defined in handler", () => {
expect("foo" in new Proxy({}, { has: null })).toBeFalse();
expect("foo" in new Proxy({}, { has: undefined })).toBeFalse();
expect("foo" in new Proxy({}, {})).toBeFalse();
});
"foo" in p;
});
test("correct arguments supplied to trap", () => {
let o = {};
let p = new Proxy(o, {
has(target, prop) {
expect(target).toBe(o);
expect(prop).toBe("foo");
return true;
},
});
test("conditional return", () => {
let o = {};
let p = new Proxy(o, {
has(target, prop) {
if (target.checkedFoo) return true;
if (prop === "foo") target.checkedFoo = true;
return false;
},
"foo" in p;
});
expect("foo" in p).toBeFalse();
expect("foo" in p).toBeTrue();
});
test("conditional return", () => {
let o = {};
let p = new Proxy(o, {
has(target, prop) {
if (target.checkedFoo) return true;
if (prop === "foo") target.checkedFoo = true;
return false;
},
});
expect("foo" in p).toBeFalse();
expect("foo" in p).toBeTrue();
});
});
describe("[[Has]] invariants", () => {
test("cannot return false if the property exists and is non-configurable", () => {
let o = {};
Object.defineProperty(o, "foo", { configurable: false });
test("cannot return false if the property exists and is non-configurable", () => {
let o = {};
Object.defineProperty(o, "foo", { configurable: false });
p = new Proxy(o, {
has() {
return false;
},
p = new Proxy(o, {
has() {
return false;
},
});
expect(() => {
"foo" in p;
}).toThrowWithMessage(
TypeError,
"Proxy handler's has trap violates invariant: a property cannot be reported as non-existent if it exists on the target as a non-configurable property"
);
});
expect(() => {
"foo" in p;
}).toThrowWithMessage(
TypeError,
"Proxy handler's has trap violates invariant: a property cannot be reported as non-existent if it exists on the target as a non-configurable property"
);
});
test("cannot return false if the property exists and the target is non-extensible", () => {
let o = {};
Object.defineProperty(o, "foo", { value: 10, configurable: true });
test("cannot return false if the property exists and the target is non-extensible", () => {
let o = {};
Object.defineProperty(o, "foo", { value: 10, configurable: true });
let p = new Proxy(o, {
has() {
return false;
},
});
let p = new Proxy(o, {
has() {
return false;
},
Object.preventExtensions(o);
expect(() => {
"foo" in p;
}).toThrowWithMessage(
TypeError,
"Proxy handler's has trap violates invariant: a property cannot be reported as non-existent if it exists on the target and the target is non-extensible"
);
});
Object.preventExtensions(o);
expect(() => {
"foo" in p;
}).toThrowWithMessage(
TypeError,
"Proxy handler's has trap violates invariant: a property cannot be reported as non-existent if it exists on the target and the target is non-extensible"
);
});
});