ladybird/Libraries/LibJS/Tests/object-basic.js
DexesTTP 4a9485f830 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.
2020-04-06 21:45:20 +02:00

17 lines
No EOL
437 B
JavaScript

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);
}