Skip to content

Commit

Permalink
adding redefine existing property test to LambdaAccessorSlotTests to …
Browse files Browse the repository at this point in the history
…cover that code path
  • Loading branch information
nabacg committed Dec 9, 2024
1 parent d350e81 commit 474c3ba
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,35 @@ public void testOnlyGetterCanBeAccessed() {
});
}

@Test
public void testRedefineExistingProperty() {
Utils.runWithAllOptimizationLevels(
cx -> {
Scriptable scope = cx.initStandardObjects();
var sh = new StatusHolder("PENDING");

sh.defineProperty("value", "oldValueOfValue", DONTENUM);

sh.defineProperty(cx, "value", (thisObj) -> "valueOfValue", null, DONTENUM);

sh.defineProperty(cx, "status", (thisObj) -> 42, null, DONTENUM);

sh.defineProperty(
cx,
"status",
(thisObj) -> self(thisObj).getStatus(),
(thisObj, value) -> self(thisObj).setStatus(value),
DONTENUM);

var status = sh.get("status", sh);
assertEquals("PENDING", status);

var value = sh.get("value", sh);
assertEquals("valueOfValue", value);
return null;
});
}

@Test
public void testWhenNoSetterDefined_InStrictMode_WillThrowException() {
Utils.runWithAllOptimizationLevels(
Expand Down

0 comments on commit 474c3ba

Please sign in to comment.