From 24d3e235399ef421723cd597fe7a9408c3da54ec Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 3 Mar 2019 20:43:10 +0100 Subject: Use normalization tests to test the parser too --- dhall/tests/macros.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'dhall') 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 @@ -8,21 +8,32 @@ macro_rules! include_test_strs_ab { ($x:expr) => { (include_test_str!(concat!($x, "A")), include_test_str!(concat!($x, "B"))) }; } +#[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); -- cgit v1.2.3