mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 00:25:07 +00:00
LibJS: Throw TypeError when calling class constructor without 'new'
This commit is contained in:
parent
b07c7f589f
commit
1b0c862f3a
5 changed files with 21 additions and 5 deletions
|
@ -46,18 +46,18 @@ test("constructor length affects class length", () => {
|
|||
expect(B).toHaveLength(2);
|
||||
});
|
||||
|
||||
test.skip("must be invoked with 'new'", () => {
|
||||
test("must be invoked with 'new'", () => {
|
||||
class A {
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
expect(() => {
|
||||
A();
|
||||
}).toThrow(TypeError); // FIXME: Add message when this test works
|
||||
}).toThrowWithMessage(TypeError, "Class constructor A must be called with 'new'");
|
||||
|
||||
expect(() => {
|
||||
A.prototype.constructor();
|
||||
}).toThrow(TypeError); // FIXME: Add message when this test works
|
||||
}).toThrowWithMessage(TypeError, "Class constructor A must be called with 'new'");
|
||||
});
|
||||
|
||||
test("implicit constructor", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue