aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compress/awaits.js64
-rw-r--r--test/compress/functions.js36
-rw-r--r--test/compress/yields.js64
3 files changed, 142 insertions, 22 deletions
diff --git a/test/compress/awaits.js b/test/compress/awaits.js
index be3cc5a0..8882f1e7 100644
--- a/test/compress/awaits.js
+++ b/test/compress/awaits.js
@@ -614,14 +614,14 @@ functions: {
async function b() {
return !!b;
}
- var c = async function(c) {
+ async function c(c) {
return c;
- };
+ }
if (await c(await b(await a()))) {
- async function d() {}
- async function e() {
- return typeof e;
- }
+ var d = async function() {};
+ var e = async function y() {
+ return typeof y;
+ };
var f = async function(f) {
return f;
};
@@ -672,9 +672,9 @@ functions_use_strict: {
async function b() {
return !!b;
}
- var c = async function(c) {
+ async function c(c) {
return c;
- };
+ }
if (await c(await b(await a()))) {
var d = async function() {};
var e = async function y() {
@@ -691,6 +691,54 @@ functions_use_strict: {
node_version: ">=8"
}
+functions_anonymous: {
+ options = {
+ functions: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var await = async function() {
+ console.log("PASS");
+ };
+ await(await);
+ }
+ expect: {
+ async function await() {
+ console.log("PASS");
+ }
+ await();
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}
+
+functions_inner_var: {
+ options = {
+ functions: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var await = function a() {
+ var a;
+ console.log(a, a);
+ };
+ await(await);
+ }
+ expect: {
+ function await() {
+ var a;
+ console.log(a, a);
+ }
+ await();
+ }
+ expect_stdout: "undefined undefined"
+ node_version: ">=8"
+}
+
issue_4335_1: {
options = {
inline: true,
diff --git a/test/compress/functions.js b/test/compress/functions.js
index e43efcea..2c529f0f 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -2751,17 +2751,17 @@ functions: {
function b() {
return !!b;
}
- var c = function(c) {
+ function c(c) {
return c;
- };
+ }
if (c(b(a()))) {
function d() {}
function e() {
return typeof e;
}
- var f = function(f) {
+ function f(f) {
return f;
- };
+ }
console.log(a(d()), b(e()), c(f(42)), typeof d, e(), typeof f);
}
}();
@@ -2808,9 +2808,9 @@ functions_use_strict: {
function b() {
return !!b;
}
- var c = function(c) {
+ function c(c) {
return c;
- };
+ }
if (c(b(a()))) {
var d = function() {};
var e = function y() {
@@ -2826,6 +2826,30 @@ functions_use_strict: {
expect_stdout: "a true 42 function function function"
}
+functions_inner_var: {
+ options = {
+ functions: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a = function() {
+ var a;
+ console.log(a, a);
+ };
+ a(a);
+ }
+ expect: {
+ function a() {
+ var a;
+ console.log(a, a);
+ }
+ a();
+ }
+ expect_stdout: "undefined undefined"
+}
+
issue_2437: {
options = {
collapse_vars: true,
diff --git a/test/compress/yields.js b/test/compress/yields.js
index 06f46c9d..05972e53 100644
--- a/test/compress/yields.js
+++ b/test/compress/yields.js
@@ -388,14 +388,14 @@ functions: {
function* b() {
return !!b;
}
- var c = function*(c) {
+ function* c(c) {
return c;
- };
+ }
if (yield* c(yield* b(yield* a()))) {
- function* d() {}
- function* e() {
- return typeof e;
- }
+ var d = function*() {};
+ var e = function* y() {
+ return typeof y;
+ };
var f = function*(f) {
return f;
};
@@ -446,9 +446,9 @@ functions_use_strict: {
function* b() {
return !!b;
}
- var c = function*(c) {
+ function* c(c) {
return c;
- };
+ }
if (yield* c(yield* b(yield* a()))) {
var d = function*() {};
var e = function* y() {
@@ -465,6 +465,54 @@ functions_use_strict: {
node_version: ">=4"
}
+functions_anonymous: {
+ options = {
+ functions: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var yield = function*() {
+ return "PASS";
+ };
+ console.log(yield().next(yield).value);
+ }
+ expect: {
+ function* yield() {
+ return "PASS";
+ }
+ console.log(yield().next(yield).value);
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}
+
+functions_inner_var: {
+ options = {
+ functions: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var yield = function* a() {
+ var a;
+ console.log(a, a);
+ };
+ yield().next(yield);
+ }
+ expect: {
+ function* yield() {
+ var a;
+ console.log(a, a);
+ }
+ yield().next(yield);
+ }
+ expect_stdout: "undefined undefined"
+ node_version: ">=4"
+}
+
negate_iife: {
options = {
negate_iife: true,