diff --git a/crates/swc_ecma_transforms_testing/src/lib.rs b/crates/swc_ecma_transforms_testing/src/lib.rs index b53006c22bba..05d6fe4e90b0 100644 --- a/crates/swc_ecma_transforms_testing/src/lib.rs +++ b/crates/swc_ecma_transforms_testing/src/lib.rs @@ -154,12 +154,12 @@ impl<'a> Tester<'a> { name: &str, syntax: Syntax, src: &str, - ) -> Result { + ) -> Result { let fm = self .cm .new_source_file(FileName::Real(name.into()), src.into()); - let module = { + let program = { let mut p = Parser::new_from(Lexer::new( syntax, EsVersion::latest(), @@ -167,7 +167,7 @@ impl<'a> Tester<'a> { Some(&self.comments), )); let res = p - .parse_module() + .parse_program() .map_err(|e| e.into_diagnostic(self.handler).emit()); for e in p.take_errors() { @@ -177,14 +177,14 @@ impl<'a> Tester<'a> { res? }; - let module = module + let program = program .fold_with(&mut tr) .fold_with(&mut as_folder(Normalizer)); - Ok(module) + Ok(program) } - pub fn print(&mut self, module: &Module, comments: &Rc) -> String { + pub fn print(&mut self, program: &Program, comments: &Rc) -> String { let mut buf = vec![]; { let mut emitter = Emitter { @@ -200,7 +200,7 @@ impl<'a> Tester<'a> { }; // println!("Emitting: {:?}", module); - emitter.emit_module(module).unwrap(); + emitter.emit_program(program).unwrap(); } let s = String::from_utf8_lossy(&buf); @@ -381,12 +381,12 @@ where Tester::run(|tester| { let tr = make_tr(tr, tester); - let module = tester.apply_transform(tr, "input.js", syntax, input)?; + let program = tester.apply_transform(tr, "input.js", syntax, input)?; match ::std::env::var("PRINT_HYGIENE") { Ok(ref s) if s == "1" => { let hygiene_src = tester.print( - &module.clone().fold_with(&mut HygieneVisualizer), + &program.clone().fold_with(&mut HygieneVisualizer), &tester.comments.clone(), ); println!("----- Hygiene -----\n{}", hygiene_src); @@ -394,14 +394,14 @@ where _ => {} } - let mut module = module + let mut program = program .fold_with(&mut hygiene::hygiene()) .fold_with(&mut fixer::fixer(Some(&tester.comments))); - let src_without_helpers = tester.print(&module, &tester.comments.clone()); - module = module.fold_with(&mut inject_helpers(Mark::fresh(Mark::root()))); + let src_without_helpers = tester.print(&program, &tester.comments.clone()); + program = program.fold_with(&mut inject_helpers(Mark::fresh(Mark::root()))); - let transformed_src = tester.print(&module, &tester.comments.clone()); + let transformed_src = tester.print(&program, &tester.comments.clone()); println!( "\t>>>>> Orig <<<<<\n{}\n\t>>>>> Code <<<<<\n{}", @@ -429,7 +429,7 @@ where Tester::run(|tester| { let tr = make_tr(tr, tester); - let module = tester.apply_transform( + let program = tester.apply_transform( tr, "input.js", syntax, @@ -443,7 +443,7 @@ where match ::std::env::var("PRINT_HYGIENE") { Ok(ref s) if s == "1" => { let hygiene_src = tester.print( - &module.clone().fold_with(&mut HygieneVisualizer), + &program.clone().fold_with(&mut HygieneVisualizer), &tester.comments.clone(), ); println!("----- Hygiene -----\n{}", hygiene_src); @@ -451,14 +451,14 @@ where _ => {} } - let mut module = module + let mut program = program .fold_with(&mut hygiene::hygiene()) .fold_with(&mut fixer::fixer(Some(&tester.comments))); - let src_without_helpers = tester.print(&module, &tester.comments.clone()); - module = module.fold_with(&mut inject_helpers(Mark::fresh(Mark::root()))); + let src_without_helpers = tester.print(&program, &tester.comments.clone()); + program = program.fold_with(&mut inject_helpers(Mark::fresh(Mark::root()))); - let src = tester.print(&module, &tester.comments.clone()); + let src = tester.print(&program, &tester.comments.clone()); println!( "\t>>>>> {} <<<<<\n{}\n\t>>>>> {} <<<<<\n{}", @@ -699,9 +699,9 @@ pub fn test_fixture

( let expected = expected.unwrap_or_default(); let expected_src = Tester::run(|tester| { - let expected_module = tester.apply_transform(noop(), "expected.js", syntax, &expected)?; + let expected_program = tester.apply_transform(noop(), "expected.js", syntax, &expected)?; - let expected_src = tester.print(&expected_module, &tester.comments.clone()); + let expected_src = tester.print(&expected_program, &tester.comments.clone()); println!( "----- {} -----\n{}", @@ -747,7 +747,7 @@ pub fn test_fixture

( .fold_with(&mut crate::fixer::fixer(Some(&tester.comments))); let actual_src = { - let module = &actual; + let program = &actual; let comments: &Rc = &tester.comments.clone(); let mut buf = vec![]; { @@ -764,7 +764,7 @@ pub fn test_fixture

( }; // println!("Emitting: {:?}", module); - emitter.emit_module(module).unwrap(); + emitter.emit_program(program).unwrap(); } if let Some(src_map) = &mut src_map {