Skip to content

Commit

Permalink
Add tests for jit
Browse files Browse the repository at this point in the history
  • Loading branch information
ShortDevelopment committed Oct 13, 2024
1 parent 629cb8a commit 55dea9f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/es12/optional-calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const tests = [
},
{
name: "Optional call of root function",
body(){
body() {
assert.areEqual(42, eval?.("42"));

globalThis.doNotUseThisBadGlobalFunction = () => 42;
Expand Down 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 simpleObj.null?.();
}
function shouldReturn2() {
return "12"?.length;
}
assert.areEqual(undefined, shouldReturnUndefined());
assert.areEqual(2, shouldReturn2());
}
}
];

Expand Down

0 comments on commit 55dea9f

Please sign in to comment.