summaryrefslogtreecommitdiff
path: root/tests/macros.rs
diff options
context:
space:
mode:
authorNadrieril2019-02-27 22:48:44 +0100
committerNadrieril2019-02-27 22:48:44 +0100
commit95d034158758e743b558a4453eada48579a50d34 (patch)
treebc33653dfcae32a16ffa044858534dfb1e25c8cb /tests/macros.rs
parent2c00699d217e0a54d44678529fa3d87936071fec (diff)
Add all normalization tests that pass
Diffstat (limited to 'tests/macros.rs')
-rw-r--r--tests/macros.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/macros.rs b/tests/macros.rs
new file mode 100644
index 0000000..3e8f111
--- /dev/null
+++ b/tests/macros.rs
@@ -0,0 +1,31 @@
+#[macro_export]
+macro_rules! include_test_str {
+ ($x:expr) => { include_str!(concat!("../dhall-lang/tests/", $x, ".dhall")) };
+}
+
+#[macro_export]
+macro_rules! include_test_strs_ab {
+ ($x:expr) => { (include_test_str!(concat!($x, "A")), include_test_str!(concat!($x, "B"))) };
+}
+
+#[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();
+ assert_eq!(normalize::<_, X, _>(&expr), normalize::<_, X, _>(&expected));
+ };
+}
+
+#[macro_export]
+macro_rules! make_spec_test {
+ ($type:ident, $name:ident, $path:expr) => {
+ #[test]
+ #[allow(non_snake_case)]
+ fn $name(){
+ use dhall::*;
+ run_spec_test!($type, $path);
+ }
+ };
+}