diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-12 12:17:30 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-12 12:17:46 +0100 |
commit | 13d7c09125f8eec703d0a43a9a87fc8aa08f7319 (patch) | |
tree | 70fd643c429cea5c1f9362c2674511d17a53f3b5 /Libraries/LibJS/Tests/classes/class-static-setters.js | |
parent | dc28c07fa526841e05e16161c74a6c23984f1dd5 (diff) | |
download | serenity-13d7c09125f8eec703d0a43a9a87fc8aa08f7319.zip |
Libraries: Move to Userland/Libraries/
Diffstat (limited to 'Libraries/LibJS/Tests/classes/class-static-setters.js')
-rw-r--r-- | Libraries/LibJS/Tests/classes/class-static-setters.js | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/Libraries/LibJS/Tests/classes/class-static-setters.js b/Libraries/LibJS/Tests/classes/class-static-setters.js deleted file mode 100644 index 38cbbe2394..0000000000 --- a/Libraries/LibJS/Tests/classes/class-static-setters.js +++ /dev/null @@ -1,112 +0,0 @@ -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(); - }); -}); |