reactivate unit tests for arithmetic_ast

This commit is contained in:
Geoffroy Couprie 2017-09-07 18:16:56 +02:00
parent 08a8a67df0
commit 8ed37f75a3

View File

@ -108,34 +108,34 @@ named!(expr< Expr >, do_parse!(
(fold_exprs(initial, remainder))
));
/*
#[test]
fn factor_test() {
assert_eq!(factor(&b" 3 "[..]).map(|x| format!("{:?}", x)),
assert_eq!(factor(&b" 3 "[..]).map(|(i,x)| (i,format!("{:?}", x))),
Ok((&b""[..], String::from("3"))));
}
#[test]
fn term_test() {
assert_eq!(term(&b" 3 * 5 "[..]).map(|x| format!("{:?}", x)),
assert_eq!(term(&b" 3 * 5 "[..]).map(|(i,x)| (i,format!("{:?}", x))),
Ok( (&b""[..], String::from("(3 * 5)")) ));
}
#[test]
fn expr_test() {
assert_eq!(expr(&b" 1 + 2 * 3 "[..]).map(|x| format!("{:?}", x)),
assert_eq!(expr(&b" 1 + 2 * 3 "[..]).map(|(i,x)| (i,format!("{:?}", x))),
Ok( (&b""[..], String::from("(1 + (2 * 3))")) ));
assert_eq!(expr(&b" 1 + 2 * 3 / 4 - 5 "[..]).map(|x| format!("{:?}", x)),
assert_eq!(expr(&b" 1 + 2 * 3 / 4 - 5 "[..]).map(|(i,x)| (i,format!("{:?}", x))),
Ok( (&b""[..], String::from("((1 + ((2 * 3) / 4)) - 5)")) ));
assert_eq!(expr(&b" 72 / 2 / 3 "[..]).map(|x| format!("{:?}", x)),
Ok( (&b""[..], String::from("((72 / 2)) / 3)")) ));
assert_eq!(expr(&b" 72 / 2 / 3 "[..]).map(|(i,x)| (i,format!("{:?}", x))),
Ok( (&b""[..], String::from("((72 / 2) / 3)")) ));
}
#[test]
fn parens_test() {
assert_eq!(
expr(&b" ( 1 + 2 ) * 3 "[..]).map(|x| format!("{:?}", x)),
expr(&b" ( 1 + 2 ) * 3 "[..]).map(|(i,x)| (i,format!("{:?}", x))),
Ok( (&b""[..], String::from("([(1 + 2)] * 3)")) )
);
}
*/