summaryrefslogtreecommitdiff
path: root/dhall/tests/common
diff options
context:
space:
mode:
authorNadrieril2019-04-06 12:52:37 +0200
committerNadrieril2019-04-06 12:52:37 +0200
commit0cf63216e96331d56e58ba92a35f95ced2fa23ab (patch)
treeb1bc51cd6415fa76c670fc424ee563a035db17e2 /dhall/tests/common
parente0d16abfbd4ecc080dab960b531b749bd72c68e6 (diff)
Add type-inference tests
Closes #49
Diffstat (limited to 'dhall/tests/common')
-rw-r--r--dhall/tests/common/mod.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/dhall/tests/common/mod.rs b/dhall/tests/common/mod.rs
index 325b80f..397a8ee 100644
--- a/dhall/tests/common/mod.rs
+++ b/dhall/tests/common/mod.rs
@@ -40,6 +40,8 @@ pub enum Feature {
Normalization,
TypecheckSuccess,
TypecheckFailure,
+ TypeInferenceSuccess,
+ TypeInferenceFailure,
}
pub fn read_dhall_file<'i>(file_path: &str) -> Result<Expr<X, X>, DhallError> {
@@ -60,6 +62,8 @@ pub fn run_test(base_path: &str, feature: Feature) {
Normalization => "normalization/success/",
TypecheckSuccess => "typecheck/success/",
TypecheckFailure => "typecheck/failure/",
+ TypeInferenceSuccess => "type-inference/success/",
+ TypeInferenceFailure => "type-inference/failure/",
};
let base_path =
"../dhall-lang/tests/".to_owned() + base_path_prefix + base_path;
@@ -113,5 +117,17 @@ pub fn run_test(base_path: &str, feature: Feature) {
let expected = rc(read_dhall_file(&expected_file_path).unwrap());
typecheck::type_of(rc(ExprF::Annot(expr, expected))).unwrap();
}
+ TypeInferenceFailure => {
+ let file_path = base_path + ".dhall";
+ let expr = rc(read_dhall_file(&file_path).unwrap());
+ typecheck::type_of(expr).unwrap_err();
+ }
+ TypeInferenceSuccess => {
+ let expr_file_path = base_path.clone() + "A.dhall";
+ let expected_file_path = base_path + "B.dhall";
+ let expr = rc(read_dhall_file(&expr_file_path).unwrap());
+ let expected = rc(read_dhall_file(&expected_file_path).unwrap());
+ assert_eq_display!(typecheck::type_of(expr).unwrap(), expected);
+ }
}
}