test: add empty list test
This commit is contained in:
parent
291dedf4e8
commit
8a7df7f66b
|
@ -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);
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ fn qualify_type_name(module: &String, typ_name: &str) -> Document<'static> {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use std::cell::RefCell;
|
||||
|
||||
use pretty_assertions::assert_eq;
|
||||
|
|
|
@ -140,7 +140,7 @@ impl From<&Config> for Preamble {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use aiken_lang::builtins;
|
||||
use schema::{Data, Declaration, Items, Schema};
|
||||
|
|
|
@ -1033,7 +1033,7 @@ Here's the types I followed and that led me to this problem:
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use proptest::prelude::*;
|
||||
use serde_json::{self, json, Value};
|
||||
|
|
|
@ -177,7 +177,7 @@ impl Validator {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use assert_json_diff::assert_json_eq;
|
||||
|
||||
use serde_json::{self, json};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use flat_rs::filler::Filler;
|
||||
use flat_rs::{decode, encode};
|
||||
use proptest::prelude::*;
|
||||
|
@ -123,4 +121,3 @@ mod test {
|
|||
|
||||
assert_eq!(bytes, vec![0b0000001, 0b00000001]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use flat_rs::zigzag::{to_isize, to_usize};
|
||||
use proptest::prelude::*;
|
||||
|
||||
|
@ -18,4 +16,3 @@ mod test {
|
|||
assert_eq!(converted_u, u);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -808,7 +808,7 @@ pub fn decode_constant_tag(d: &mut Decoder) -> Result<u8, de::Error> {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use super::{Constant, Program, Term};
|
||||
use crate::{
|
||||
ast::{DeBruijn, Name, Type},
|
||||
|
|
|
@ -3213,7 +3213,7 @@ impl TryFrom<u8> for StepKind {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
|
|
|
@ -503,7 +503,7 @@ fn replace_identity_usage(term: &Term<Name>, original: Rc<Name>) -> Term<Name> {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
|
||||
use pallas_primitives::babbage::{BigInt, PlutusData};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
|
|
@ -282,7 +282,7 @@ peg::parser! {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod tests {
|
||||
use num_bigint::BigInt;
|
||||
|
||||
use crate::ast::{Constant, Name, Program, Term, Type, Unique};
|
||||
|
|
Loading…
Reference in New Issue