mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00:00
LibJS: Add object literal method shorthand
This commit is contained in:
parent
88f7f9712d
commit
28ef654d13
3 changed files with 37 additions and 4 deletions
29
Libraries/LibJS/Tests/object-method-shorthand.js
Normal file
29
Libraries/LibJS/Tests/object-method-shorthand.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
const o = {
|
||||
foo: "bar",
|
||||
getFoo() {
|
||||
return this.foo;
|
||||
},
|
||||
12() {
|
||||
return this.getFoo();
|
||||
},
|
||||
"hello friends"() {
|
||||
return this.getFoo();
|
||||
},
|
||||
[4 + 10]() {
|
||||
return this.getFoo();
|
||||
},
|
||||
};
|
||||
|
||||
assert(o.foo === "bar");
|
||||
assert(o.getFoo() === "bar");
|
||||
assert(o[12]() === "bar");
|
||||
assert(o["hello friends"]() === "bar");
|
||||
assert(o[14]() === "bar");
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue