mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +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
62
Libraries/LibJS/Tests/object-getter-setter-shorthand.js
Normal file
62
Libraries/LibJS/Tests/object-getter-setter-shorthand.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
test("normal methods named get and set", () => {
|
||||
let o = {
|
||||
get() {
|
||||
return 5;
|
||||
},
|
||||
set() {
|
||||
return 10;
|
||||
},
|
||||
};
|
||||
expect(o.get()).toBe(5);
|
||||
expect(o.set()).toBe(10);
|
||||
});
|
||||
|
||||
test("basic get and set", () => {
|
||||
let o = {
|
||||
get x() {
|
||||
return 5;
|
||||
},
|
||||
set x(_) {},
|
||||
};
|
||||
expect(o.x).toBe(5);
|
||||
o.x = 10;
|
||||
expect(o.x).toBe(5);
|
||||
});
|
||||
|
||||
test("get and set with 'this'", () => {
|
||||
let o = {
|
||||
get x() {
|
||||
return this._x + 1;
|
||||
},
|
||||
set x(value) {
|
||||
this._x = value + 1;
|
||||
},
|
||||
};
|
||||
|
||||
expect(o.x).toBeNaN();
|
||||
o.x = 10;
|
||||
expect(o.x).toBe(12);
|
||||
o.x = 20;
|
||||
expect(o.x).toBe(22);
|
||||
});
|
||||
|
||||
test("multiple getters", () => {
|
||||
let o = {
|
||||
get x() {
|
||||
return 5;
|
||||
},
|
||||
get x() {
|
||||
return 10;
|
||||
},
|
||||
};
|
||||
expect(o.x).toBe(10);
|
||||
});
|
||||
|
||||
test("setter return value", () => {
|
||||
o = {
|
||||
set x(value) {
|
||||
return 10;
|
||||
},
|
||||
};
|
||||
expect((o.x = 20)).toBe(20);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue