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
49
Libraries/LibJS/Tests/classes/class-advanced-extends.js
Normal file
49
Libraries/LibJS/Tests/classes/class-advanced-extends.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
test("extending function", () => {
|
||||
class A extends function () {
|
||||
this.foo = 10;
|
||||
} {}
|
||||
|
||||
expect(new A().foo).toBe(10);
|
||||
});
|
||||
|
||||
test("extending null", () => {
|
||||
class A extends null {}
|
||||
|
||||
expect(Object.getPrototypeOf(A.prototype)).toBeNull();
|
||||
|
||||
expect(() => {
|
||||
new A();
|
||||
}).toThrowWithMessage(TypeError, "Super constructor is not a constructor");
|
||||
});
|
||||
|
||||
test("extending String", () => {
|
||||
class MyString extends String {}
|
||||
|
||||
const ms = new MyString("abc");
|
||||
expect(ms).toBeInstanceOf(MyString);
|
||||
expect(ms).toBeInstanceOf(String);
|
||||
expect(ms.charAt(1)).toBe("b");
|
||||
|
||||
class MyString2 extends MyString {
|
||||
charAt(i) {
|
||||
return `#${super.charAt(i)}`;
|
||||
}
|
||||
}
|
||||
|
||||
const ms2 = new MyString2("abc");
|
||||
expect(ms2.charAt(1)).toBe("#b");
|
||||
});
|
||||
|
||||
test("class extends value is invalid", () => {
|
||||
expect(() => {
|
||||
class A extends 123 {}
|
||||
}).toThrowWithMessage(TypeError, "Class extends value 123 is not a constructor or null");
|
||||
});
|
||||
|
||||
test("class extends value has invalid prototype", () => {
|
||||
function f() {}
|
||||
f.prototype = 123;
|
||||
expect(() => {
|
||||
class A extends f {}
|
||||
}).toThrowWithMessage(TypeError, "Class extends value has an invalid prototype 123");
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue