chore: add more details on snapshot tests

We added a macro to add more information about the code that is being
tested, so we can add lots and lots of small snapshot tests.
This commit is contained in:
Cainã Costa 2023-06-30 12:46:15 -03:00 committed by rvcas
parent eeaa1a05d2
commit 63cdb8aa09
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
2 changed files with 19 additions and 9 deletions

View File

@ -23,16 +23,25 @@ fn assert_definitions(code: &str, definitions: Vec<ast::UntypedDefinition>) {
) )
} }
fn snapshot_test(code: &str) { macro_rules! snapshot_test {
($name:ident, $code:expr) => {
#[test]
fn $name() {
let (module, _) = let (module, _) =
parser::module(code, ast::ModuleKind::Validator).expect("Failed to parse code"); parser::module($code, ast::ModuleKind::Validator).expect("Failed to parse code");
insta::with_settings!({
info => &stringify!($name),
description => $code,
omit_expression => true
}, {
insta::assert_debug_snapshot!(module); insta::assert_debug_snapshot!(module);
});
}
};
} }
#[test] snapshot_test!(snapshot_windows_newline, "use aiken/list\r\n");
fn snapshot_windows_newline() {
snapshot_test("use aiken/list\r\n")
}
#[test] #[test]
fn windows_newline() { fn windows_newline() {

View File

@ -1,6 +1,7 @@
--- ---
source: crates/aiken-lang/src/tests/parser.rs source: crates/aiken-lang/src/tests/parser.rs
expression: module description: "use aiken/list\r\n"
info: snapshot_windows_newline
--- ---
Module { Module {
name: "", name: "",