aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-05-19 09:06:29 +0800
committerGitHub <noreply@github.com>2017-05-19 09:06:29 +0800
commiteae26756f1419e7e601bae8b44d69f4e80dd0d61 (patch)
tree2b5e4eb11e177db8c7da1e7b666b693d49a9814c /test
parent43add9416b927703471a1a722f6a73dcecb0dac3 (diff)
downloadtracifyjs-eae26756f1419e7e601bae8b44d69f4e80dd0d61.tar.gz
tracifyjs-eae26756f1419e7e601bae8b44d69f4e80dd0d61.zip
introduce `unsafe_regexp` (#1970)
fixes #1964
Diffstat (limited to 'test')
-rw-r--r--test/compress/evaluate.js47
1 files changed, 47 insertions, 0 deletions
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"
+}