aboutsummaryrefslogtreecommitdiff
path: root/test/compress/functions.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-26 21:25:35 +0800
committerGitHub <noreply@github.com>2017-12-26 21:25:35 +0800
commit4832bc5d88e37ca35f1dd5f5d8ddd95cd8bbdd7d (patch)
tree925053e75bf5109861b7fdb54e30f0e5ae4b960f /test/compress/functions.js
parent7f342cb3e3abd3e39b18e62a2e9d6b8020d82773 (diff)
downloadtracifyjs-4832bc5d88e37ca35f1dd5f5d8ddd95cd8bbdd7d.tar.gz
tracifyjs-4832bc5d88e37ca35f1dd5f5d8ddd95cd8bbdd7d.zip
replace single-use recursive functions (#2659)
fixes #2628
Diffstat (limited to 'test/compress/functions.js')
-rw-r--r--test/compress/functions.js27
1 files changed, 23 insertions, 4 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 7f35de76..83a27a06 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -1345,11 +1345,10 @@ issue_2630_3: {
expect: {
var x = 2, a = 1;
(function() {
- function f1(a) {
+ (function f1(a) {
f2();
--x >= 0 && f1({});
- }
- f1(a++);
+ })(a++);
function f2() {
a++;
}
@@ -1424,7 +1423,7 @@ issue_2630_5: {
expect_stdout: "155"
}
-recursive_inline: {
+recursive_inline_1: {
options = {
inline: true,
reduce_funcs: true,
@@ -1448,6 +1447,26 @@ recursive_inline: {
expect: {}
}
+recursive_inline_2: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function f(n) {
+ return n ? n * f(n - 1) : 1;
+ }
+ console.log(f(5));
+ }
+ expect: {
+ console.log(function f(n) {
+ return n ? n * f(n - 1) : 1;
+ }(5));
+ }
+ expect_stdout: "120"
+}
+
issue_2657: {
options = {
inline: true,