1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:17:35 +00:00

LibJS: Add tests for symbol object integration

This commit is contained in:
Matthew Olsson 2020-07-07 21:39:36 -07:00 committed by Andreas Kling
parent 7a1d485b19
commit 119386ffb0
13 changed files with 198 additions and 13 deletions

View file

@ -18,6 +18,8 @@ test("name", () => {
});
test("extended name syntax", () => {
const s = Symbol("foo");
class A {
get "method with space"() {
return 1;
@ -30,12 +32,17 @@ test("extended name syntax", () => {
get [`he${"llo"}`]() {
return 3;
}
get [s]() {
return 4;
}
}
const a = new A();
expect(a["method with space"]).toBe(1);
expect(a[12]).toBe(2);
expect(a.hello).toBe(3);
expect(a[s]).toBe(4);
});
test("inherited getter", () => {

View file

@ -29,6 +29,8 @@ test("name", () => {
});
test("extended name syntax", () => {
const s = Symbol("foo");
class A {
set "method with space"(value) {
this.a = value;
@ -41,15 +43,21 @@ test("extended name syntax", () => {
set [`he${"llo"}`](value) {
this.c = value;
}
set [s](value) {
this.d = value;
}
}
const a = new A();
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 setter", () => {

View file

@ -20,6 +20,8 @@ describe("correct behavior", () => {
});
test("extended name syntax", () => {
const s = Symbol("foo");
class A {
static get "method with space"() {
return 1;
@ -32,11 +34,16 @@ describe("correct behavior", () => {
static get [`he${"llo"}`]() {
return 3;
}
static get [s]() {
return 4;
}
}
expect(A["method with space"]).toBe(1);
expect(A[12]).toBe(2);
expect(A.hello).toBe(3);
expect(A[s]).toBe(4);
});
test("inherited static getter", () => {

View file

@ -27,6 +27,8 @@ describe("correct behavior", () => {
});
test("extended name syntax", () => {
const s = Symbol("foo");
class A {
static set "method with space"(value) {
this.a = value;
@ -39,14 +41,20 @@ describe("correct behavior", () => {
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", () => {