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:
parent
eeaa1a05d2
commit
63cdb8aa09
|
@ -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, _) =
|
||||
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);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snapshot_windows_newline() {
|
||||
snapshot_test("use aiken/list\r\n")
|
||||
}
|
||||
snapshot_test!(snapshot_windows_newline, "use aiken/list\r\n");
|
||||
|
||||
#[test]
|
||||
fn windows_newline() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/parser.rs
|
||||
expression: module
|
||||
description: "use aiken/list\r\n"
|
||||
info: snapshot_windows_newline
|
||||
---
|
||||
Module {
|
||||
name: "",
|
Loading…
Reference in New Issue