diff options
-rw-r--r-- | dhall/tests/macros.rs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/dhall/tests/macros.rs b/dhall/tests/macros.rs index 14e5a89..a9bc770 100644 --- a/dhall/tests/macros.rs +++ b/dhall/tests/macros.rs @@ -9,20 +9,31 @@ macro_rules! include_test_strs_ab { } #[macro_export] +macro_rules! parse_str { + ($str:expr) => { + { + let pest_expr = parser::parse_expr_pest(&$str).map_err(|e| println!("{}", e)).unwrap(); + // Check with old parser + match parser::parse_expr_lalrpop(&$str) { + Ok(larlpop_expr) => assert_eq!(pest_expr, larlpop_expr), + Err(_) => {}, + }; + pest_expr + } + }; +} + +#[macro_export] macro_rules! run_spec_test { (normalization, $path:expr) => { - // let (expr_str, expected_str) = include_test_strs_ab!($path); - // let expr = parser::parse_expr(&expr_str).unwrap(); - // let expected = parser::parse_expr(&expected_str).unwrap(); + let (expr_str, expected_str) = include_test_strs_ab!($path); + let expr = parse_str!(expr_str); + let expected = parse_str!(expected_str); // assert_eq!(normalize::<_, X, _>(&expr), normalize::<_, X, _>(&expected)); }; (parser, $path:expr) => { let expr_str = include_test_str!(concat!($path, "A")); - let pest_expr = parser::parse_expr_pest(&expr_str).map_err(|e| println!("{}", e)).unwrap(); - match parser::parse_expr_lalrpop(&expr_str) { - Ok(larlpop_expr) => assert_eq!(pest_expr, larlpop_expr), - Err(_) => {}, - }; + parse_str!(expr_str); }; (parser_failure, $path:expr) => { let expr_str = include_test_str!($path); |