test(es/minifier): Execute more tests (#4636)

This commit is contained in:
Donny/강동윤 2022-05-12 16:28:52 +09:00 committed by GitHub
parent cb5ca547aa
commit 79f87e03db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 19 deletions

View File

@ -633,7 +633,7 @@ where
}
self.changed = true;
report_change!("inline: Replacing a variable with cheap expression");
report_change!("inline: Replacing a variable `{}` with cheap expression", i);
*e = *value;
return;

View File

@ -11,9 +11,6 @@ drop_unused/keep_assign/input.js
drop_unused/reassign_const/input.js
drop_unused/var_catch_toplevel/input.js
evaluate/issue_2535_1/input.js
expansions/avoid_spread_getset_object/input.js
expansions/avoid_spread_hole/input.js
functions/avoid_generating_duplicate_functions_compared_together_3/input.js
harmony/array_literal_with_spread_4a/input.js
harmony/default_assign/input.js
if_return/if_var_return/input.js
@ -23,12 +20,8 @@ issue_1034/non_hoisted_function_after_return_2a/input.js
issue_1034/non_hoisted_function_after_return_2b/input.js
issue_1052/defun_else_if_return/input.js
issue_1052/defun_if_return/input.js
issue_1443/keep_fnames/input.js
issue_1443/unsafe_undefined/input.js
issue_281/inner_var_for_in_1/input.js
issue_368/collapse/input.js
issue_417/test_unexpected_crash/input.js
issue_417/test_unexpected_crash_2/input.js
nullish/conditional_to_nullish_coalescing_2/input.js
parameters/destructuring_arguments_2/input.js
properties/dot_properties/input.js

View File

@ -194,6 +194,8 @@ evaluate/unsafe_object/input.js
evaluate/unsafe_object_complex/input.js
evaluate/unsafe_object_nested/input.js
evaluate/unsafe_object_repeated/input.js
expansions/avoid_spread_getset_object/input.js
expansions/avoid_spread_hole/input.js
export/export_default_named_async_function/input.js
export/export_default_named_generator/input.js
export/issue_2126/input.js
@ -210,6 +212,7 @@ export/name_cache_import_star_as_name_from_module/input.js
export/name_cache_mangle_export_default_class/input.js
export/name_cache_mangle_export_default_function/input.js
export/name_cache_mangle_local_import_and_export_aliases/input.js
functions/avoid_generating_duplicate_functions_compared_together_3/input.js
functions/duplicate_arg_var/input.js
functions/empty_body/input.js
functions/hoist_funs/input.js
@ -366,6 +369,8 @@ issue_1431/level_one/input.js
issue_1431/level_three/input.js
issue_1431/level_two/input.js
issue_1431/level_zero/input.js
issue_1443/keep_fnames/input.js
issue_1443/unsafe_undefined/input.js
issue_1446/typeof_eq_undefined_ie8/input.js
issue_1446/undefined_redefined_mangle/input.js
issue_1447/conditional_false_stray_else_in_loop/input.js
@ -410,6 +415,8 @@ issue_2719/warn/input.js
issue_281/collapse_vars_constants/input.js
issue_281/issue_1758/input.js
issue_2871/comparison_with_undefined/input.js
issue_417/test_unexpected_crash/input.js
issue_417/test_unexpected_crash_2/input.js
issue_44/issue_44_valid_ast_1/input.js
issue_44/issue_44_valid_ast_2/input.js
issue_597/issue_1724/input.js

View File

@ -34,6 +34,9 @@ use testing::assert_eq;
#[testing::fixture(
"tests/terser/compress/**/input.js",
exclude(
"expansions/avoid_spread_getset_object/",
"expansions/avoid_spread_hole/",
"functions/avoid_generating_duplicate_functions_compared_together_3/",
// We don't care about ie8
"ie8",
// tests with infinite loops
@ -69,13 +72,21 @@ fn terser_exec(input: PathBuf) {
return Ok(());
}
let expected_src = read_to_string(&dir.join("output.terser.js")).map_err(|_| {
eprintln!("This test does not have `output.terser.js`");
})?;
let mut expected_src = None;
let expected_stdout =
stdout_of(&expected_src, Duration::from_millis(500)).map_err(|_| {
eprintln!("This test is not executable test");
let expected_stdout = read_to_string(&dir.join("expected.stdout"))
.or_else(|_| {
let src = read_to_string(&dir.join("output.terser.js"))
.context("This test does not have `output.terser.js`")?;
expected_src = Some(src.clone());
stdout_of(&src, Duration::from_millis(500))
.context("This test is not executable test")
})
.context("This test is not an excutable test")
.map_err(|err| {
eprintln!("{}", err);
})?;
if input_stdout != expected_stdout {
@ -94,11 +105,13 @@ fn terser_exec(input: PathBuf) {
let actual = print(cm, &[output_module], false, false);
let actual_stdout = stdout_of(&actual, Duration::from_secs(5)).unwrap();
eprintln!(
"---- {} -----\n{}",
Color::Green.paint("Expected"),
expected_src
);
if let Some(expected_src) = expected_src {
eprintln!(
"---- {} -----\n{}",
Color::Green.paint("Expected"),
expected_src
);
}
eprintln!("---- {} -----\n{}", Color::Green.paint("Actual"), actual);

View File

@ -0,0 +1,6 @@
function f(undefined) {
return function () {
if (a) return b;
if (c) return d;
};
}

View File

@ -0,0 +1,6 @@
function f__1(undefined__2) {
return function() {
if (a) return b;
if (c) return d;
};
}