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

LibJS: Fix impossible member access for negative integers

The PropertyName class able to match a number or an array can only
accept positive numerical values. However, the computed_property_name
method sometimes returned negative values.

This commit also adds a basic object access test case.
This commit is contained in:
DexesTTP 2020-04-06 21:21:11 +02:00 committed by Andreas Kling
parent cb18b2c74d
commit 4a9485f830
2 changed files with 18 additions and 1 deletions

View file

@ -0,0 +1,17 @@
try {
var o = { foo: "bar" };
assert(o.foo === "bar");
assert(o["foo"] === "bar");
o.baz = "test";
assert(o.baz === "test");
assert(o["baz"] === "test");
o[10] = "123";
assert(o[10] === "123");
assert(o["10"] === "123");
o[-1] = "hello friends";
assert(o[-1] === "hello friends");
assert(o["-1"] === "hello friends");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}