diff options
Diffstat (limited to 'Userland/Libraries/LibJS/Tests/classes/class-inheritance.js')
-rw-r--r-- | Userland/Libraries/LibJS/Tests/classes/class-inheritance.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/classes/class-inheritance.js b/Userland/Libraries/LibJS/Tests/classes/class-inheritance.js index 36c6bd9f2c..336e2b729b 100644 --- a/Userland/Libraries/LibJS/Tests/classes/class-inheritance.js +++ b/Userland/Libraries/LibJS/Tests/classes/class-inheritance.js @@ -170,3 +170,32 @@ test("issue #7045, super constructor call from child class in catch {}", () => { const c = new Child(); expect(c.x).toBe("Error in Child constructor"); }); + +test("Issue #7044, super property access before super() call", () => { + class Foo { + constructor() { + super.bar; + } + } + + new Foo(); +}); + +test("Issue #8574, super property access before super() call", () => { + var hit = false; + + class Foo extends Object { + constructor() { + expect(() => { + const foo = super.bar(); + }).toThrowWithMessage(ReferenceError, "|this| has not been initialized"); + hit = true; + } + } + + // Note: We catch two exceptions here. + expect(() => { + new Foo(); + }).toThrowWithMessage(ReferenceError, "|this| has not been initialized"); + expect(hit).toBeTrue(); +}); |