use casual::{CExpr, CNumber}; #[test] fn basics() { assert_eq!( CExpr::from_str("(+ 1 2 3)").unwrap(), CExpr::Number(CNumber::Integer(6)), ); } #[test] fn canonicalization() { let cases = vec![ ("(+ (+ a 2) (+ b 2))", "(+ 4 a b)"), ("(+ (+ a 2) (+ b 2))", "(+ 4 a b)"), ("(+ 1 2 b)", "(+ 3 b)"), ("(+ 1 2 3)", "6"), ("(* (/ 2 3) (/ 3 2))", "1"), ]; for (input, output) in cases.iter() { assert_eq!(CExpr::from_str(input).unwrap().to_string(), *output); } } // TODO: helper to read an examples file, as pairs of rows