test: add empty list test
This commit is contained in:
@@ -27,3 +27,16 @@ pub fn parser(
|
||||
tail,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use chumsky::Parser;
|
||||
|
||||
use crate::assert_expr;
|
||||
|
||||
#[test]
|
||||
fn empty_list() {
|
||||
assert_expr!("[]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/parser/expr/list.rs
|
||||
description: "Code:\n\n[]"
|
||||
---
|
||||
List {
|
||||
location: 0..2,
|
||||
elements: [],
|
||||
tail: None,
|
||||
}
|
||||
@@ -93,3 +93,26 @@ pub fn type_name_with_args() -> impl Parser<Token, (String, Option<Vec<String>>)
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
mod macros {
|
||||
#[macro_export]
|
||||
macro_rules! assert_expr {
|
||||
($code:expr) => {
|
||||
let $crate::parser::lexer::LexInfo { tokens, .. } = $crate::parser::lexer::run($code).unwrap();
|
||||
|
||||
let stream = chumsky::Stream::from_iter($crate::ast::Span::create(tokens.len()), tokens.into_iter());
|
||||
|
||||
let result = $crate::parser::expr::sequence().parse(stream).unwrap();
|
||||
|
||||
insta::with_settings!({
|
||||
description => concat!("Code:\n\n", $code),
|
||||
prepend_module_to_snapshot => false,
|
||||
omit_expression => true
|
||||
}, {
|
||||
insta::assert_debug_snapshot!(result);
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user