1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

LibJS: Indent tests with 4 spaces instead of 2

This commit is contained in:
Matthew Olsson 2020-07-06 07:37:45 -07:00 committed by Andreas Kling
parent 15de2eda2b
commit 1ef573eb30
261 changed files with 8536 additions and 8497 deletions

View file

@ -1,133 +1,133 @@
test("method inheritance", () => {
class Parent {
method() {
return 3;
class Parent {
method() {
return 3;
}
}
}
class Child extends Parent {}
class Child extends Parent {}
const p = new Parent();
const c = new Child();
expect(p.method()).toBe(3);
expect(c.method()).toBe(3);
const p = new Parent();
const c = new Child();
expect(p.method()).toBe(3);
expect(c.method()).toBe(3);
});
test("method overriding", () => {
class Parent {
method() {
return 3;
class Parent {
method() {
return 3;
}
}
}
class Child extends Parent {
method() {
return 10;
class Child extends Parent {
method() {
return 10;
}
}
}
const p = new Parent();
const c = new Child();
expect(p.method()).toBe(3);
expect(c.method()).toBe(10);
const p = new Parent();
const c = new Child();
expect(p.method()).toBe(3);
expect(c.method()).toBe(10);
});
test("parent method reference with super", () => {
class Parent {
method() {
return 3;
class Parent {
method() {
return 3;
}
}
}
class Child extends Parent {
method() {
return super.method() * 2;
class Child extends Parent {
method() {
return super.method() * 2;
}
}
}
const p = new Parent();
const c = new Child();
expect(p.method()).toBe(3);
expect(c.method()).toBe(6);
const p = new Parent();
const c = new Child();
expect(p.method()).toBe(3);
expect(c.method()).toBe(6);
});
test("child class access to parent class initialized properties", () => {
class Parent {
constructor() {
this.x = 3;
class Parent {
constructor() {
this.x = 3;
}
}
}
class Child extends Parent {}
class Child extends Parent {}
const p = new Parent();
const c = new Child();
expect(p.x).toBe(3);
expect(c.x).toBe(3);
const p = new Parent();
const c = new Child();
expect(p.x).toBe(3);
expect(c.x).toBe(3);
});
test("child class modification of parent class properties", () => {
class Parent {
constructor() {
this.x = 3;
class Parent {
constructor() {
this.x = 3;
}
}
}
class Child extends Parent {
change() {
this.x = 10;
class Child extends Parent {
change() {
this.x = 10;
}
}
}
const p = new Parent();
const c = new Child();
expect(p.x).toBe(3);
expect(c.x).toBe(3);
const p = new Parent();
const c = new Child();
expect(p.x).toBe(3);
expect(c.x).toBe(3);
c.change();
expect(c.x).toBe(10);
c.change();
expect(c.x).toBe(10);
});
test("inheritance and hasOwnProperty", () => {
class Parent {
constructor() {
this.x = 3;
class Parent {
constructor() {
this.x = 3;
}
}
}
class Child extends Parent {
method() {
this.y = 10;
class Child extends Parent {
method() {
this.y = 10;
}
}
}
const p = new Parent();
const c = new Child();
expect(p.hasOwnProperty("x")).toBeTrue();
expect(p.hasOwnProperty("y")).toBeFalse();
expect(c.hasOwnProperty("x")).toBeTrue();
expect(c.hasOwnProperty("y")).toBeFalse();
const p = new Parent();
const c = new Child();
expect(p.hasOwnProperty("x")).toBeTrue();
expect(p.hasOwnProperty("y")).toBeFalse();
expect(c.hasOwnProperty("x")).toBeTrue();
expect(c.hasOwnProperty("y")).toBeFalse();
c.method();
expect(c.hasOwnProperty("x")).toBeTrue();
expect(c.hasOwnProperty("y")).toBeTrue();
c.method();
expect(c.hasOwnProperty("x")).toBeTrue();
expect(c.hasOwnProperty("y")).toBeTrue();
});
test("super constructor call from child class with argument", () => {
class Parent {
constructor(x) {
this.x = x;
class Parent {
constructor(x) {
this.x = x;
}
}
}
class Child extends Parent {
constructor() {
super(10);
class Child extends Parent {
constructor() {
super(10);
}
}
}
const p = new Parent(3);
const c = new Child(3);
expect(p.x).toBe(3);
expect(c.x).toBe(10);
const p = new Parent(3);
const c = new Child(3);
expect(p.x).toBe(3);
expect(c.x).toBe(10);
});