2022-11-28 07:54:38 +03:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2022-07-13 13:29:03 +03:00
|
|
|
use swc_common::{chain, Mark};
|
|
|
|
use swc_ecma_transforms_base::resolver;
|
2021-01-05 08:29:52 +03:00
|
|
|
use swc_ecma_transforms_compat::es2015::arrow;
|
2022-11-28 07:54:38 +03:00
|
|
|
use swc_ecma_transforms_testing::{compare_stdout, test, test_fixture};
|
2022-07-13 13:29:03 +03:00
|
|
|
use swc_ecma_visit::Fold;
|
|
|
|
|
|
|
|
fn tr() -> impl Fold {
|
|
|
|
let unresolved = Mark::new();
|
|
|
|
let global = Mark::new();
|
|
|
|
chain!(resolver(unresolved, global, false), arrow(unresolved))
|
|
|
|
}
|
2018-11-21 12:59:17 +03:00
|
|
|
|
2021-09-09 14:45:20 +03:00
|
|
|
compare_stdout!(
|
2021-04-19 18:50:44 +03:00
|
|
|
::swc_ecma_parser::Syntax::default(),
|
2022-07-13 13:29:03 +03:00
|
|
|
|_| tr(),
|
2021-04-19 18:50:44 +03:00
|
|
|
arguments_nested_arrow,
|
2021-09-09 14:45:20 +03:00
|
|
|
"
|
|
|
|
function test() {
|
2021-04-19 18:50:44 +03:00
|
|
|
console.log(arguments[0]);
|
|
|
|
return () => {
|
2021-09-09 14:45:20 +03:00
|
|
|
console.log(arguments[0]);
|
|
|
|
return () => {
|
|
|
|
console.log(arguments[0])
|
2021-04-19 18:50:44 +03:00
|
|
|
};
|
2021-09-09 14:45:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test()(1)(2);
|
|
|
|
"
|
2021-04-19 18:50:44 +03:00
|
|
|
);
|
|
|
|
|
2021-09-09 14:45:20 +03:00
|
|
|
compare_stdout!(
|
2021-04-19 18:50:44 +03:00
|
|
|
::swc_ecma_parser::Syntax::default(),
|
2022-07-13 13:29:03 +03:00
|
|
|
|_| tr(),
|
2021-04-19 18:50:44 +03:00
|
|
|
arguments_nested_fn,
|
2021-09-09 14:45:20 +03:00
|
|
|
"
|
|
|
|
function test() {
|
2021-04-19 18:50:44 +03:00
|
|
|
console.log(arguments[0]);
|
2021-09-09 14:45:20 +03:00
|
|
|
return () => {
|
2021-04-19 18:50:44 +03:00
|
|
|
console.log(arguments[0]);
|
|
|
|
return function() {
|
2021-09-09 14:45:20 +03:00
|
|
|
console.log(arguments[0]);
|
|
|
|
return () => {
|
|
|
|
console.log(arguments[0])
|
|
|
|
};
|
2021-04-19 18:50:44 +03:00
|
|
|
};
|
2021-09-09 14:45:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
test()(1)(2)(3);
|
|
|
|
"
|
2021-04-19 18:50:44 +03:00
|
|
|
);
|
|
|
|
|
2022-11-28 07:54:38 +03:00
|
|
|
#[testing::fixture("tests/arrow/**/input.js")]
|
|
|
|
fn fixture(input: PathBuf) {
|
|
|
|
let output = input.with_file_name("output.js");
|
|
|
|
|
|
|
|
test_fixture(
|
|
|
|
Default::default(),
|
|
|
|
&|_| {
|
|
|
|
let unresolved_mark = Mark::new();
|
|
|
|
chain!(
|
|
|
|
resolver(unresolved_mark, Mark::new(), false),
|
|
|
|
arrow(unresolved_mark)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
&input,
|
|
|
|
&output,
|
|
|
|
Default::default(),
|
|
|
|
);
|
2021-11-24 03:59:06 +03:00
|
|
|
}
|