2021-10-20 08:18:55 +03:00
|
|
|
use std::path::PathBuf;
|
|
|
|
use swc_common::chain;
|
|
|
|
use swc_ecma_parser::{EsConfig, Syntax};
|
2021-10-23 17:25:14 +03:00
|
|
|
use swc_ecma_transforms_compat::es2022::class_properties;
|
2021-10-20 08:18:55 +03:00
|
|
|
use swc_ecma_transforms_proposal::static_blocks;
|
|
|
|
use swc_ecma_transforms_testing::test_fixture;
|
|
|
|
use swc_ecma_visit::Fold;
|
|
|
|
|
|
|
|
#[testing::fixture("tests/static-blocks/**/input.js")]
|
|
|
|
fn fixture(input: PathBuf) {
|
|
|
|
let parent = input.parent().unwrap();
|
|
|
|
|
|
|
|
let output = parent.join("output.js");
|
|
|
|
test_fixture(
|
|
|
|
Syntax::Es(EsConfig {
|
|
|
|
static_blocks: true,
|
|
|
|
..Default::default()
|
|
|
|
}),
|
|
|
|
&|_t| {
|
|
|
|
let pass: Box<dyn Fold> = if input.to_string_lossy().contains("class-properties") {
|
|
|
|
Box::new(chain!(
|
|
|
|
static_blocks(),
|
|
|
|
class_properties(class_properties::Config::default())
|
|
|
|
))
|
|
|
|
} else {
|
|
|
|
Box::new(static_blocks())
|
|
|
|
};
|
|
|
|
pass
|
|
|
|
},
|
|
|
|
&input,
|
|
|
|
&output,
|
|
|
|
)
|
|
|
|
}
|