Skip to content

Commit

Permalink
Test opt-chain arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ShortDevelopment committed Oct 13, 2024
1 parent 55dea9f commit 2aaa1c9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/es12/optional-calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,23 @@ const tests = [
assert.areEqual(6, eval("x + y"));
assert.throws(() => eval?.("x + y"), ReferenceError, "Should not have access to local scope", "'x' is not defined");
}
},
{
name: "Opt-chain arguments should work in JIT",
body() {
function passArg(arg1) {
return arg1;
}
assert.areEqual(undefined, passArg(simpleObj.null?.something));
assert.areEqual(undefined, passArg(simpleObj.undefined?.something));
assert.areEqual(undefined, passArg(simpleObj.something?.something));

assert.areEqual(null, passArg(simpleObj?.null));
assert.areEqual(undefined, passArg(simpleObj?.undefined));
assert.areEqual(42, passArg(simpleObj?.something));
assert.areEqual("42", passArg(simpleObj?.something.toString()));
assert.areEqual("42", passArg(simpleObj?.something?.toString()));
}
}
];

Expand Down

0 comments on commit 2aaa1c9

Please sign in to comment.