aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compress.js14
-rw-r--r--test/compress/global_defs.js14
-rw-r--r--test/compress/ie8.js23
-rw-r--r--test/ufuzz/index.js4
4 files changed, 48 insertions, 7 deletions
diff --git a/test/compress.js b/test/compress.js
index 2fe02806..0afd98a9 100644
--- a/test/compress.js
+++ b/test/compress.js
@@ -269,6 +269,7 @@ function test_case(test) {
quote_style: 3,
});
try {
+ input.validate_ast();
U.parse(input_code);
} catch (ex) {
log([
@@ -315,8 +316,8 @@ function test_case(test) {
output = U.mangle_properties(output, test.mangle.properties);
}
}
- output = make_code(output, output_options);
- if (expect != output) {
+ var output_code = make_code(output, output_options);
+ if (expect != output_code) {
log([
"!!! failed",
"---INPUT---",
@@ -329,14 +330,15 @@ function test_case(test) {
"",
].join("\n"), {
input: input_formatted,
- output: output,
+ output: output_code,
expected: expect
});
return false;
}
// expect == output
try {
- U.parse(output);
+ output.validate_ast();
+ U.parse(output_code);
} catch (ex) {
log([
"!!! Test matched expected result but cannot parse output",
@@ -350,7 +352,7 @@ function test_case(test) {
"",
].join("\n"), {
input: input_formatted,
- output: output,
+ output: output_code,
error: ex,
});
return false;
@@ -409,7 +411,7 @@ function test_case(test) {
});
return false;
}
- actual = run_code(output, toplevel);
+ actual = run_code(output_code, toplevel);
if (!sandbox.same_stdout(test.expect_stdout, actual)) {
log([
"!!! failed",
diff --git a/test/compress/global_defs.js b/test/compress/global_defs.js
index f1ef81d9..006be292 100644
--- a/test/compress/global_defs.js
+++ b/test/compress/global_defs.js
@@ -12,6 +12,20 @@ must_replace: {
}
}
+repeated_nodes: {
+ options = {
+ global_defs: {
+ "@N": "rand()",
+ },
+ }
+ input: {
+ console.log(N, N);
+ }
+ expect: {
+ console.log(rand(), rand());
+ }
+}
+
keyword: {
options = {
global_defs: {
diff --git a/test/compress/ie8.js b/test/compress/ie8.js
index 19437074..6c0aa9e8 100644
--- a/test/compress/ie8.js
+++ b/test/compress/ie8.js
@@ -2691,3 +2691,26 @@ issue_4028: {
}
expect_stdout: "string"
}
+
+issue_2737: {
+ options = {
+ ie8: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function(a) {
+ a();
+ })(function f() {
+ console.log(typeof f);
+ });
+ }
+ expect: {
+ (function(a) {
+ a();
+ })(function f() {
+ console.log(typeof f);
+ });
+ }
+ expect_stdout: "function"
+}
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js
index 8f853c9c..1123d57e 100644
--- a/test/ufuzz/index.js
+++ b/test/ufuzz/index.js
@@ -1148,7 +1148,9 @@ function log(options) {
}
}
errorln("//-------------------------------------------------------------");
- var reduced = reduce_test(original_code, JSON.parse(options), {
+ var reduce_options = JSON.parse(options);
+ reduce_options.validate = true;
+ var reduced = reduce_test(original_code, reduce_options, {
verbose: false,
}).code;
if (reduced) {