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

LibJS: Convert some top-level tests to the new system

First test conversions! These look really good :)
This commit is contained in:
Matthew Olsson 2020-07-03 14:39:25 -07:00 committed by Andreas Kling
parent 4b8a3e6d78
commit eea6041302
22 changed files with 464 additions and 451 deletions

View file

@ -1,29 +1,39 @@
load("test-common.js");
try {
test("basic method shorthand", () => {
const o = {
foo: "bar",
getFoo() {
getFoo() {
return this.foo;
},
12() {
return this.getFoo();
},
"hello friends"() {
return this.getFoo();
},
[4 + 10]() {
return this.getFoo();
};
expect(o.getFoo()).toBe("bar");
});
test("numeric literal method shorthand", () => {
const o = {
foo: "bar",
12() {
return this.foo;
},
};
expect(o[12]()).toBe("bar");
});
assert(o.foo === "bar");
assert(o.getFoo() === "bar");
assert(o[12]() === "bar");
assert(o["hello friends"]() === "bar");
assert(o[14]() === "bar");
test("string literal method shorthand", () => {
const o = {
foo: "bar",
"hello friends"() {
return this.foo;
},
};
expect(o["hello friends"]()).toBe("bar");
});
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("computed property method shorthand", () => {
const o = {
foo: "bar",
[4 + 10]() {
return this.foo;
},
};
expect(o[14]()).toBe("bar");
});