aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-27 01:58:21 +0800
committerGitHub <noreply@github.com>2017-03-27 01:58:21 +0800
commitf001e4cb9d5bfe56e25db552bb7ab0951a142a99 (patch)
treee20c946d08e85aca66e67b7532d2d64b1fd4d482 /test
parent57ce5bd9e085546a5c1cb8dd4a3ea71ab6c56f26 (diff)
downloadtracifyjs-f001e4cb9d5bfe56e25db552bb7ab0951a142a99.tar.gz
tracifyjs-f001e4cb9d5bfe56e25db552bb7ab0951a142a99.zip
fix `cascade` on anonymous function reference (#1693)
Unlike normal variables and even function definitions, these cannot be reassigned, even though assignment expressions would "leak" the assigned value as normal.
Diffstat (limited to 'test')
-rw-r--r--test/compress/sequences.js110
1 files changed, 110 insertions, 0 deletions
diff --git a/test/compress/sequences.js b/test/compress/sequences.js
index af6e0c36..f1fa0e87 100644
--- a/test/compress/sequences.js
+++ b/test/compress/sequences.js
@@ -330,3 +330,113 @@ issue_1685: {
}
expect_stdout: true
}
+
+func_def_1: {
+ options = {
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ function f() {
+ return f = 0, !!f;
+ }
+ console.log(f());
+ }
+ expect: {
+ function f() {
+ return !!(f = 0);
+ }
+ console.log(f());
+ }
+ expect_stdout: "false"
+}
+
+func_def_2: {
+ options = {
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ console.log(function f() {
+ return f = 0, !!f;
+ }());
+ }
+ expect: {
+ console.log(function f() {
+ return f = 0, !!f;
+ }());
+ }
+ expect_stdout: "true"
+}
+
+func_def_3: {
+ options = {
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ function f() {
+ function g() {}
+ return g = 0, !!g;
+ }
+ console.log(f());
+ }
+ expect: {
+ function f() {
+ function g() {}
+ return !!(g = 0);
+ }
+ console.log(f());
+ }
+ expect_stdout: "false"
+}
+
+func_def_4: {
+ options = {
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ function f() {
+ function g() {
+ return g = 0, !!g;
+ }
+ return g();
+ }
+ console.log(f());
+ }
+ expect: {
+ function f() {
+ function g() {
+ return !!(g = 0);
+ }
+ return g();
+ }
+ console.log(f());
+ }
+ expect_stdout: "false"
+}
+
+func_def_5: {
+ options = {
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ function f() {
+ return function g(){
+ return g = 0, !!g;
+ }();
+ }
+ console.log(f());
+ }
+ expect: {
+ function f() {
+ return function g(){
+ return g = 0, !!g;
+ }();
+ }
+ console.log(f());
+ }
+ expect_stdout: "true"
+}