mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 13:44:15 +00:00
Test Expr::fmt
This commit is contained in:
parent
eb48aecf84
commit
592c76cc29
1 changed files with 23 additions and 0 deletions
23
src/ast.rs
23
src/ast.rs
|
@ -312,3 +312,26 @@ impl fmt::Display for DateToken {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::Expr::{self, *};
|
||||
|
||||
fn check<T: ::std::fmt::Display>(e: T, expected: &str) {
|
||||
assert_eq!(format!("{}", e), expected);
|
||||
}
|
||||
|
||||
impl From<i64> for Expr {
|
||||
fn from(x: i64) -> Self {
|
||||
Const(x.into())
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_display_call() {
|
||||
check(Call("f".into(), vec![]), "f()");
|
||||
check(Call("f".into(), vec![1.into()]), "f(1)");
|
||||
check(Call("f".into(), vec![1.into(), 2.into()]), "f(1, 2)");
|
||||
check(Call("f".into(), vec![1.into(), 2.into(), 3.into()]), "f(1, 2, 3)");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue