diff options
author | Nadrieril | 2019-03-03 20:43:10 +0100 |
---|---|---|
committer | Nadrieril | 2019-03-03 20:43:31 +0100 |
commit | 24d3e235399ef421723cd597fe7a9408c3da54ec (patch) | |
tree | 09ddb47ac6246148d3de43f2d78f126b78fcce91 | |
parent | af01dd2d05bbc2ae44ad38cc7b44057e4c793c89 (diff) |
Use normalization tests to test the parser too
Diffstat (limited to '')
-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); |