summaryrefslogtreecommitdiff
path: root/dhall/tests/macros.rs
diff options
context:
space:
mode:
authorNadrieril2019-03-09 22:32:45 +0100
committerNadrieril2019-03-09 22:32:45 +0100
commite71443e8dbc8875ddc35e341383d03b750dd0ff6 (patch)
treeef05d543964b4f905256f99ede1a0e2e02133e00 /dhall/tests/macros.rs
parentb44cbca3a3996b3c47ec0f883bd1dc087971f2d1 (diff)
Add typecheck tests
Closes #4
Diffstat (limited to '')
-rw-r--r--dhall/tests/macros.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/dhall/tests/macros.rs b/dhall/tests/macros.rs
index 9ed48e0..60e70c2 100644
--- a/dhall/tests/macros.rs
+++ b/dhall/tests/macros.rs
@@ -30,6 +30,14 @@ macro_rules! run_spec_test {
let base_path = concat!("../dhall-lang/tests/", $path);
run_test(base_path, Feature::Parser, ExpectedResult::Failure);
};
+ (typecheck_success, $path:expr) => {
+ let base_path = concat!("../dhall-lang/tests/", $path);
+ run_test(base_path, Feature::Typecheck, ExpectedResult::Success);
+ };
+ (typecheck_failure, $path:expr) => {
+ let base_path = concat!("../dhall-lang/tests/", $path);
+ run_test(base_path, Feature::Typecheck, ExpectedResult::Failure);
+ };
}
#[macro_export]
@@ -66,6 +74,7 @@ use std::path::PathBuf;
pub enum Feature {
Parser,
Normalization,
+ Typecheck,
}
pub enum ExpectedResult {
@@ -106,6 +115,18 @@ pub fn run_test(base_path: &str, feature: Feature, expected: ExpectedResult) {
normalize::<_, X, _>(&expected)
);
}
+ (Feature::Typecheck, ExpectedResult::Failure) => {
+ let file_path = base_path.to_owned() + ".dhall";
+ let expr = read_dhall_file(&file_path).unwrap();
+ typecheck::type_of(&expr).unwrap_err();
+ }
+ (Feature::Typecheck, ExpectedResult::Success) => {
+ let expr_file_path = base_path.to_owned() + "A.dhall";
+ let expected_file_path = base_path.to_owned() + "B.dhall";
+ let expr = read_dhall_file(&expr_file_path).unwrap();
+ let expected = read_dhall_file(&expected_file_path).unwrap();
+ typecheck::type_of(&Expr::Annot(bx(expr), bx(expected))).unwrap();
+ }
_ => unimplemented!(),
}
}