mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
126
Libraries/LibJS/Tests/classes/class-static-setters.js
Normal file
126
Libraries/LibJS/Tests/classes/class-static-setters.js
Normal file
|
@ -0,0 +1,126 @@
|
|||
describe("correct behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
class A {
|
||||
static get x() {
|
||||
return this._x;
|
||||
}
|
||||
|
||||
static set x(value) {
|
||||
this._x = value * 2;
|
||||
}
|
||||
}
|
||||
|
||||
expect(A.x).toBeUndefined();
|
||||
expect(A).not.toHaveProperty("_x");
|
||||
A.x = 3;
|
||||
expect(A.x).toBe(6);
|
||||
expect(A).toHaveProperty("_x", 6);
|
||||
});
|
||||
|
||||
test("name", () => {
|
||||
class A {
|
||||
static set x(v) {}
|
||||
}
|
||||
|
||||
const d = Object.getOwnPropertyDescriptor(A, "x");
|
||||
expect(d.set.name).toBe("set x");
|
||||
});
|
||||
|
||||
test("extended name syntax", () => {
|
||||
const s = Symbol("foo");
|
||||
|
||||
class A {
|
||||
static set "method with space"(value) {
|
||||
this.a = value;
|
||||
}
|
||||
|
||||
static set 12(value) {
|
||||
this.b = value;
|
||||
}
|
||||
|
||||
static set [`he${"llo"}`](value) {
|
||||
this.c = value;
|
||||
}
|
||||
|
||||
static set [s](value) {
|
||||
this.d = value;
|
||||
}
|
||||
}
|
||||
|
||||
A["method with space"] = 1;
|
||||
A[12] = 2;
|
||||
A.hello = 3;
|
||||
A[s] = 4;
|
||||
expect(A.a).toBe(1);
|
||||
expect(A.b).toBe(2);
|
||||
expect(A.c).toBe(3);
|
||||
expect(A.d).toBe(4);
|
||||
});
|
||||
|
||||
test("inherited static setter", () => {
|
||||
class Parent {
|
||||
static get x() {
|
||||
return this._x;
|
||||
}
|
||||
|
||||
static set x(value) {
|
||||
this._x = value * 2;
|
||||
}
|
||||
}
|
||||
|
||||
class Child extends Parent {}
|
||||
|
||||
expect(Child.x).toBeUndefined();
|
||||
Child.x = 10;
|
||||
expect(Child.x).toBe(20);
|
||||
});
|
||||
|
||||
test("inherited static setter overriding", () => {
|
||||
class Parent {
|
||||
static get x() {
|
||||
return this._x;
|
||||
}
|
||||
|
||||
static set x(value) {
|
||||
this._x = value * 2;
|
||||
}
|
||||
}
|
||||
|
||||
class Child extends Parent {
|
||||
static get x() {
|
||||
return this._x;
|
||||
}
|
||||
|
||||
static set x(value) {
|
||||
this._x = value * 3;
|
||||
}
|
||||
}
|
||||
|
||||
expect(Child.x).toBeUndefined();
|
||||
Child.x = 10;
|
||||
expect(Child.x).toBe(30);
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test('"set static" is a syntax error', () => {
|
||||
expect(`
|
||||
class A {
|
||||
set static foo(value) {}
|
||||
}`).not.toEval();
|
||||
});
|
||||
});
|
||||
|
||||
test("static setter named 'async'", () => {
|
||||
let called = false;
|
||||
class A {
|
||||
static set async(value) {
|
||||
called = true;
|
||||
expect(value).toBe("value set on static setter named async");
|
||||
}
|
||||
}
|
||||
|
||||
expect("async" in A).toBeTrue();
|
||||
A.async = "value set on static setter named async";
|
||||
expect(called).toBeTrue();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue