From 0cf63216e96331d56e58ba92a35f95ced2fa23ab Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 6 Apr 2019 12:52:37 +0200 Subject: Add type-inference tests Closes #49 --- dhall/tests/common/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'dhall/tests/common/mod.rs') 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, 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); + } } } -- cgit v1.2.3