aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorkzc <zaxxon2011@gmail.com>2016-09-01 09:24:56 -0400
committerkzc <zaxxon2011@gmail.com>2016-09-01 09:24:56 -0400
commit25fc02743af0e3fec6b10ffdb5cee3b7f22b9889 (patch)
tree9dc3e31bf38451f187b19b67745c36773274697d /test
parent0bd8053524760531eb582ef0716fcfe2104c3014 (diff)
downloadtracifyjs-25fc02743af0e3fec6b10ffdb5cee3b7f22b9889.tar.gz
tracifyjs-25fc02743af0e3fec6b10ffdb5cee3b7f22b9889.zip
Account for side effects in `string + expr` optimization
Diffstat (limited to 'test')
-rw-r--r--test/compress/issue-1275.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/compress/issue-1275.js b/test/compress/issue-1275.js
new file mode 100644
index 00000000..e88e284c
--- /dev/null
+++ b/test/compress/issue-1275.js
@@ -0,0 +1,49 @@
+string_plus_optimization: {
+ options = {
+ side_effects : true,
+ evaluate : true,
+ conditionals : true,
+ comparisons : true,
+ dead_code : true,
+ booleans : true,
+ unused : true,
+ if_return : true,
+ join_vars : true,
+ cascade : true,
+ hoist_funs : true,
+ };
+ input: {
+ function foo(anything) {
+ function throwing_function() {
+ throw "nope";
+ }
+ try {
+ console.log('0' + throwing_function() ? "yes" : "no");
+ } catch (ex) {
+ console.log(ex);
+ }
+ console.log('0' + anything ? "yes" : "no");
+ console.log(anything + '0' ? "Yes" : "No");
+ console.log('' + anything);
+ console.log(anything + '');
+ }
+ foo();
+ }
+ expect: {
+ function foo(anything) {
+ function throwing_function() {
+ throw "nope";
+ }
+ try {
+ console.log('0' + throwing_function() ? "yes" : "no");
+ } catch (ex) {
+ console.log(ex);
+ }
+ console.log("yes");
+ console.log("Yes");
+ console.log('' + anything);
+ console.log(anything + '');
+ }
+ foo();
+ }
+}