From eae26756f1419e7e601bae8b44d69f4e80dd0d61 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 19 May 2017 09:06:29 +0800 Subject: introduce `unsafe_regexp` (#1970) fixes #1964 --- test/compress/evaluate.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'test') diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index b8077564..a1e3d0be 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -990,3 +990,50 @@ Infinity_NaN_undefined_LHS: { "}", ] } + +issue_1964_1: { + options = { + evaluate: true, + reduce_vars: true, + unsafe_regexp: false, + unused: true, + } + input: { + function f() { + var long_variable_name = /\s/; + return "a b c".split(long_variable_name)[1]; + } + console.log(f()); + } + expect: { + function f() { + var long_variable_name = /\s/; + return "a b c".split(long_variable_name)[1]; + } + console.log(f()); + } + expect_stdout: "b" +} + +issue_1964_2: { + options = { + evaluate: true, + reduce_vars: true, + unsafe_regexp: true, + unused: true, + } + input: { + function f() { + var long_variable_name = /\s/; + return "a b c".split(long_variable_name)[1]; + } + console.log(f()); + } + expect: { + function f() { + return "a b c".split(/\s/)[1]; + } + console.log(f()); + } + expect_stdout: "b" +} -- cgit v1.2.3