chore: refactor formatting tests

This changes the tests from normal assertions into snapshot tests, as
well as standardizing test names.
This commit is contained in:
Cainã Costa
2023-07-03 18:11:54 -03:00
committed by Lucas
parent 01be548752
commit c27ef8ad93
34 changed files with 612 additions and 481 deletions

View File

@@ -97,3 +97,24 @@ macro_rules! assert_definition {
});
};
}
#[macro_export]
macro_rules! assert_format {
($code:expr) => {
let src = indoc::indoc! { $code };
let (module, extra) =
$crate::parser::module(src, $crate::ast::ModuleKind::Lib).expect("Failed to parse code");
let mut out = String::new();
$crate::format::pretty(&mut out, module, extra, &src);
insta::with_settings!({
description => concat!("Code:\n\n", indoc::indoc! { $code }),
prepend_module_to_snapshot => false,
omit_expression => true
}, {
insta::assert_snapshot!(out);
});
};
}