mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +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
98
Libraries/LibJS/Tests/classes/class-static-getters.js
Normal file
98
Libraries/LibJS/Tests/classes/class-static-getters.js
Normal file
|
@ -0,0 +1,98 @@
|
|||
describe("correct behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
class A {
|
||||
static get x() {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
expect(A.x).toBe(10);
|
||||
expect(new A()).not.toHaveProperty("x");
|
||||
});
|
||||
|
||||
test("name", () => {
|
||||
class A {
|
||||
static get x() {}
|
||||
}
|
||||
|
||||
const d = Object.getOwnPropertyDescriptor(A, "x");
|
||||
expect(d.get.name).toBe("get x");
|
||||
});
|
||||
|
||||
test("extended name syntax", () => {
|
||||
const s = Symbol("foo");
|
||||
|
||||
class A {
|
||||
static get "method with space"() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static get 12() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
static get [`he${"llo"}`]() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
static get [s]() {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
expect(A["method with space"]).toBe(1);
|
||||
expect(A[12]).toBe(2);
|
||||
expect(A.hello).toBe(3);
|
||||
expect(A[s]).toBe(4);
|
||||
});
|
||||
|
||||
test("inherited static getter", () => {
|
||||
class Parent {
|
||||
static get x() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
class Child extends Parent {}
|
||||
|
||||
expect(Parent.x).toBe(3);
|
||||
expect(Child.x).toBe(3);
|
||||
});
|
||||
|
||||
test("inherited static getter overriding", () => {
|
||||
class Parent {
|
||||
static get x() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
class Child extends Parent {
|
||||
static get x() {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
expect(Parent.x).toBe(3);
|
||||
expect(Child.x).toBe(10);
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test('"get static" is a syntax error', () => {
|
||||
expect(`
|
||||
class A {
|
||||
get static foo() {}
|
||||
}`).not.toEval();
|
||||
});
|
||||
});
|
||||
|
||||
test("static getter named 'async'", () => {
|
||||
class A {
|
||||
static get async() {
|
||||
return "static getter named async";
|
||||
}
|
||||
}
|
||||
|
||||
expect("async" in A).toBeTrue();
|
||||
expect(A.async).toBe("static getter named async");
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue