Skip to content

Commit b473aab

Browse files
bjohansebasalexander-akait
authored andcommitted
fix(minifier): compare optional eval against engine behavior
1 parent d0f9cf0 commit b473aab

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • test/configCases/optimization/minify-optional-call-semantics

‎test/configCases/optimization/minify-optional-call-semantics/eval.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@ it("should preserve direct eval behind a nullish statement guard", function () {
1717
).toBe(43);
1818
});
1919

20-
it("should preserve an already indirect optional eval", function () {
20+
it("should preserve an existing optional eval call", function () {
21+
// Older engines treat optional eval calls as direct calls.
22+
var expected = new Function(
23+
"eval",
24+
'var localValue = 42; return eval?.("typeof localValue");'
25+
)(eval);
2126
expect(
2227
(function (eval) {
2328
var localValue = 42;
2429
return eval == null ? undefined : eval?.("typeof localValue");
2530
})(eval)
26-
).toBe("undefined");
31+
).toBe(expected);
2732
});

0 commit comments

Comments
 (0)