From df3bb8028a7cd8a69a3c76090d12f808ca7abc3b Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sun, 7 Jun 2020 22:23:23 +0100 Subject: fix corner cases related to `in` (#3964) --- test/compress/collapse_vars.js | 31 +++++++++++++++++++++++++++++++ test/compress/pure_funcs.js | 2 +- test/compress/side_effects.js | 23 +++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) (limited to 'test/compress') diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 0c232aa0..f99e0124 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -8164,3 +8164,34 @@ issue_3927: { } expect_stdout: "PASS" } + +operator_in: { + options = { + collapse_vars: true, + } + input: { + function log(msg) { + console.log(msg); + } + var a = "FAIL"; + try { + a = "PASS"; + 0 in null; + log("FAIL", a); + } catch (e) {} + log(a); + } + expect: { + function log(msg) { + console.log(msg); + } + var a = "FAIL"; + try { + a = "PASS"; + 0 in null; + log("FAIL", a); + } catch (e) {} + log(a); + } + expect_stdout: "PASS" +} diff --git a/test/compress/pure_funcs.js b/test/compress/pure_funcs.js index d65399f1..09f0bd45 100644 --- a/test/compress/pure_funcs.js +++ b/test/compress/pure_funcs.js @@ -136,7 +136,7 @@ relational: { side_effects :true, } input: { - foo() in foo(); + foo() in new foo(); foo() instanceof bar(); foo() < "bar"; bar() > foo(); diff --git a/test/compress/side_effects.js b/test/compress/side_effects.js index 63282660..b7ffe47a 100644 --- a/test/compress/side_effects.js +++ b/test/compress/side_effects.js @@ -274,3 +274,26 @@ drop_value: { foo(), bar(); } } + +operator_in: { + options = { + side_effects: true, + } + input: { + try { + "foo" in true; + console.log("FAIL"); + } catch (e) { + console.log("PASS"); + } + } + expect: { + try { + 0 in true; + console.log("FAIL"); + } catch (e) { + console.log("PASS"); + } + } + expect_stdout: "PASS" +} -- cgit v1.2.3