Skip to content

Commit

Permalink
Add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ShortDevelopment committed Oct 13, 2024
1 parent 8210f62 commit 4160295
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/es12/optional-calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ const tests = [
const obj = {
fn: () => 42,
};
assert.areEqual(42, eval("obj.fn?.()"));
assert.areEqual(42, eval("obj?.fn?.()"));
assert.areEqual(42, eval("obj?.fn()"));
},
},
{
Expand Down
20 changes: 20 additions & 0 deletions test/es12/optional-chaining.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,26 @@ const tests = [
body() {
assert.areEqual(0, ""?.length, "Expected empty string length");
}
},
{
name: "Unused opt-chain result should not crash jit",
body() {
assert.areEqual(undefined, eval(`boo?.();`));
assert.areEqual("result", eval(`boo?.(); "result"`));
}
},
{
name: "Return register works with opt-chain",
body() {
function shouldReturnUndefined() {
return boo?.();
}
function shouldReturn2() {
return "12"?.length;
}
assert.areEqual(undefined, shouldReturnUndefined());
assert.areEqual(undefined, shouldReturn2());
}
}
];

Expand Down

0 comments on commit 4160295

Please sign in to comment.