summaryrefslogtreecommitdiff
path: root/dhall/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dhall/tests/common/mod.rs16
-rw-r--r--dhall/tests/typecheck.rs137
2 files changed, 151 insertions, 2 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);
+ }
}
}
diff --git a/dhall/tests/typecheck.rs b/dhall/tests/typecheck.rs
index 0cd6ddf..367765c 100644
--- a/dhall/tests/typecheck.rs
+++ b/dhall/tests/typecheck.rs
@@ -13,6 +13,17 @@ macro_rules! tc_failure {
};
}
+macro_rules! ti_success {
+ ($name:ident, $path:expr) => {
+ make_spec_test!(TypeInferenceSuccess, $name, $path);
+ };
+}
+// macro_rules! ti_failure {
+// ($name:ident, $path:expr) => {
+// make_spec_test!(TypeInferenceFailure, $name, $path);
+// };
+// }
+
// tc_success!(spec_typecheck_success_accessEncodedType, "accessEncodedType");
// tc_success!(spec_typecheck_success_accessType, "accessType");
tc_success!(spec_typecheck_success_prelude_Bool_and_0, "prelude/Bool/and/0");
@@ -145,8 +156,8 @@ tc_success!(spec_typecheck_success_prelude_Optional_unzip_0, "prelude/Optional/u
tc_success!(spec_typecheck_success_prelude_Optional_unzip_1, "prelude/Optional/unzip/1");
tc_success!(spec_typecheck_success_prelude_Text_concat_0, "prelude/Text/concat/0");
tc_success!(spec_typecheck_success_prelude_Text_concat_1, "prelude/Text/concat/1");
-tc_success!(spec_typecheck_success_prelude_Text_concatMap_0, "prelude/Text/concatMap/0");
-tc_success!(spec_typecheck_success_prelude_Text_concatMap_1, "prelude/Text/concatMap/1");
+// tc_success!(spec_typecheck_success_prelude_Text_concatMap_0, "prelude/Text/concatMap/0");
+// tc_success!(spec_typecheck_success_prelude_Text_concatMap_1, "prelude/Text/concatMap/1");
// tc_success!(spec_typecheck_success_prelude_Text_concatMapSep_0, "prelude/Text/concatMapSep/0");
// tc_success!(spec_typecheck_success_prelude_Text_concatMapSep_1, "prelude/Text/concatMapSep/1");
// tc_success!(spec_typecheck_success_prelude_Text_concatSep_0, "prelude/Text/concatSep/0");
@@ -166,3 +177,125 @@ tc_success!(spec_typecheck_success_prelude_Text_concatMap_1, "prelude/Text/conca
// tc_failure!(spec_typecheck_failure_combineMixedRecords, "combineMixedRecords");
// tc_failure!(spec_typecheck_failure_duplicateFields, "duplicateFields");
tc_failure!(spec_typecheck_failure_hurkensParadox, "hurkensParadox");
+
+// ti_success!(spec_typeinference_success_simple_alternativesAreTypes, "simple/alternativesAreTypes");
+// ti_success!(spec_typeinference_success_simple_kindParameter, "simple/kindParameter");
+ti_success!(spec_typeinference_success_unit_Bool, "unit/Bool");
+ti_success!(spec_typeinference_success_unit_Double, "unit/Double");
+ti_success!(spec_typeinference_success_unit_DoubleLiteral, "unit/DoubleLiteral");
+// ti_success!(spec_typeinference_success_unit_DoubleShow, "unit/DoubleShow");
+ti_success!(spec_typeinference_success_unit_False, "unit/False");
+ti_success!(spec_typeinference_success_unit_Function, "unit/Function");
+ti_success!(spec_typeinference_success_unit_FunctionApplication, "unit/FunctionApplication");
+ti_success!(spec_typeinference_success_unit_FunctionNamedArg, "unit/FunctionNamedArg");
+// ti_success!(spec_typeinference_success_unit_FunctionTypeKindKind, "unit/FunctionTypeKindKind");
+// ti_success!(spec_typeinference_success_unit_FunctionTypeKindTerm, "unit/FunctionTypeKindTerm");
+// ti_success!(spec_typeinference_success_unit_FunctionTypeKindType, "unit/FunctionTypeKindType");
+ti_success!(spec_typeinference_success_unit_FunctionTypeTermTerm, "unit/FunctionTypeTermTerm");
+ti_success!(spec_typeinference_success_unit_FunctionTypeTypeTerm, "unit/FunctionTypeTypeTerm");
+ti_success!(spec_typeinference_success_unit_FunctionTypeTypeType, "unit/FunctionTypeTypeType");
+ti_success!(spec_typeinference_success_unit_FunctionTypeUsingArgument, "unit/FunctionTypeUsingArgument");
+ti_success!(spec_typeinference_success_unit_If, "unit/If");
+ti_success!(spec_typeinference_success_unit_IfNormalizeArguments, "unit/IfNormalizeArguments");
+ti_success!(spec_typeinference_success_unit_Integer, "unit/Integer");
+ti_success!(spec_typeinference_success_unit_IntegerLiteral, "unit/IntegerLiteral");
+// ti_success!(spec_typeinference_success_unit_IntegerShow, "unit/IntegerShow");
+// ti_success!(spec_typeinference_success_unit_IntegerToDouble, "unit/IntegerToDouble");
+// ti_success!(spec_typeinference_success_unit_Kind, "unit/Kind");
+ti_success!(spec_typeinference_success_unit_Let, "unit/Let");
+// ti_success!(spec_typeinference_success_unit_LetNestedTypeSynonym, "unit/LetNestedTypeSynonym");
+// ti_success!(spec_typeinference_success_unit_LetTypeSynonym, "unit/LetTypeSynonym");
+ti_success!(spec_typeinference_success_unit_LetWithAnnotation, "unit/LetWithAnnotation");
+ti_success!(spec_typeinference_success_unit_List, "unit/List");
+ti_success!(spec_typeinference_success_unit_ListBuild, "unit/ListBuild");
+ti_success!(spec_typeinference_success_unit_ListFold, "unit/ListFold");
+ti_success!(spec_typeinference_success_unit_ListHead, "unit/ListHead");
+ti_success!(spec_typeinference_success_unit_ListIndexed, "unit/ListIndexed");
+ti_success!(spec_typeinference_success_unit_ListLast, "unit/ListLast");
+ti_success!(spec_typeinference_success_unit_ListLength, "unit/ListLength");
+ti_success!(spec_typeinference_success_unit_ListLiteralEmpty, "unit/ListLiteralEmpty");
+ti_success!(spec_typeinference_success_unit_ListLiteralNormalizeArguments, "unit/ListLiteralNormalizeArguments");
+ti_success!(spec_typeinference_success_unit_ListLiteralOne, "unit/ListLiteralOne");
+ti_success!(spec_typeinference_success_unit_ListReverse, "unit/ListReverse");
+// ti_success!(spec_typeinference_success_unit_MergeEmptyUnion, "unit/MergeEmptyUnion");
+// ti_success!(spec_typeinference_success_unit_MergeOne, "unit/MergeOne");
+// ti_success!(spec_typeinference_success_unit_MergeOneWithAnnotation, "unit/MergeOneWithAnnotation");
+ti_success!(spec_typeinference_success_unit_Natural, "unit/Natural");
+ti_success!(spec_typeinference_success_unit_NaturalBuild, "unit/NaturalBuild");
+ti_success!(spec_typeinference_success_unit_NaturalEven, "unit/NaturalEven");
+ti_success!(spec_typeinference_success_unit_NaturalFold, "unit/NaturalFold");
+ti_success!(spec_typeinference_success_unit_NaturalIsZero, "unit/NaturalIsZero");
+ti_success!(spec_typeinference_success_unit_NaturalLiteral, "unit/NaturalLiteral");
+ti_success!(spec_typeinference_success_unit_NaturalOdd, "unit/NaturalOdd");
+// ti_success!(spec_typeinference_success_unit_NaturalShow, "unit/NaturalShow");
+// ti_success!(spec_typeinference_success_unit_NaturalToInteger, "unit/NaturalToInteger");
+// ti_success!(spec_typeinference_success_unit_None, "unit/None");
+ti_success!(spec_typeinference_success_unit_OldOptionalNone, "unit/OldOptionalNone");
+// ti_success!(spec_typeinference_success_unit_OldOptionalTrue, "unit/OldOptionalTrue");
+ti_success!(spec_typeinference_success_unit_OperatorAnd, "unit/OperatorAnd");
+ti_success!(spec_typeinference_success_unit_OperatorAndNormalizeArguments, "unit/OperatorAndNormalizeArguments");
+ti_success!(spec_typeinference_success_unit_OperatorEqual, "unit/OperatorEqual");
+ti_success!(spec_typeinference_success_unit_OperatorEqualNormalizeArguments, "unit/OperatorEqualNormalizeArguments");
+// ti_success!(spec_typeinference_success_unit_OperatorListConcatenate, "unit/OperatorListConcatenate");
+// ti_success!(spec_typeinference_success_unit_OperatorListConcatenateNormalizeArguments, "unit/OperatorListConcatenateNormalizeArguments");
+ti_success!(spec_typeinference_success_unit_OperatorNotEqual, "unit/OperatorNotEqual");
+ti_success!(spec_typeinference_success_unit_OperatorNotEqualNormalizeArguments, "unit/OperatorNotEqualNormalizeArguments");
+ti_success!(spec_typeinference_success_unit_OperatorOr, "unit/OperatorOr");
+ti_success!(spec_typeinference_success_unit_OperatorOrNormalizeArguments, "unit/OperatorOrNormalizeArguments");
+ti_success!(spec_typeinference_success_unit_OperatorPlus, "unit/OperatorPlus");
+ti_success!(spec_typeinference_success_unit_OperatorPlusNormalizeArguments, "unit/OperatorPlusNormalizeArguments");
+ti_success!(spec_typeinference_success_unit_OperatorTextConcatenate, "unit/OperatorTextConcatenate");
+ti_success!(spec_typeinference_success_unit_OperatorTextConcatenateNormalizeArguments, "unit/OperatorTextConcatenateNormalizeArguments");
+ti_success!(spec_typeinference_success_unit_OperatorTimes, "unit/OperatorTimes");
+ti_success!(spec_typeinference_success_unit_OperatorTimesNormalizeArguments, "unit/OperatorTimesNormalizeArguments");
+ti_success!(spec_typeinference_success_unit_Optional, "unit/Optional");
+// ti_success!(spec_typeinference_success_unit_OptionalBuild, "unit/OptionalBuild");
+ti_success!(spec_typeinference_success_unit_OptionalFold, "unit/OptionalFold");
+ti_success!(spec_typeinference_success_unit_RecordEmpty, "unit/RecordEmpty");
+// ti_success!(spec_typeinference_success_unit_RecordOneKind, "unit/RecordOneKind");
+// ti_success!(spec_typeinference_success_unit_RecordOneType, "unit/RecordOneType");
+ti_success!(spec_typeinference_success_unit_RecordOneValue, "unit/RecordOneValue");
+// ti_success!(spec_typeinference_success_unit_RecordProjectionEmpty, "unit/RecordProjectionEmpty");
+// ti_success!(spec_typeinference_success_unit_RecordProjectionKind, "unit/RecordProjectionKind");
+// ti_success!(spec_typeinference_success_unit_RecordProjectionType, "unit/RecordProjectionType");
+// ti_success!(spec_typeinference_success_unit_RecordProjectionValue, "unit/RecordProjectionValue");
+// ti_success!(spec_typeinference_success_unit_RecordSelectionKind, "unit/RecordSelectionKind");
+// ti_success!(spec_typeinference_success_unit_RecordSelectionType, "unit/RecordSelectionType");
+ti_success!(spec_typeinference_success_unit_RecordSelectionValue, "unit/RecordSelectionValue");
+ti_success!(spec_typeinference_success_unit_RecordType, "unit/RecordType");
+ti_success!(spec_typeinference_success_unit_RecordTypeEmpty, "unit/RecordTypeEmpty");
+// ti_success!(spec_typeinference_success_unit_RecordTypeKind, "unit/RecordTypeKind");
+// ti_success!(spec_typeinference_success_unit_RecordTypeType, "unit/RecordTypeType");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordMergeLhsEmpty, "unit/RecursiveRecordMergeLhsEmpty");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordMergeRecursively, "unit/RecursiveRecordMergeRecursively");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordMergeRecursivelyTypes, "unit/RecursiveRecordMergeRecursivelyTypes");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordMergeRhsEmpty, "unit/RecursiveRecordMergeRhsEmpty");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordMergeTwo, "unit/RecursiveRecordMergeTwo");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordMergeTwoKinds, "unit/RecursiveRecordMergeTwoKinds");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordMergeTwoTypes, "unit/RecursiveRecordMergeTwoTypes");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordTypeMergeRecursively, "unit/RecursiveRecordTypeMergeRecursively");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordTypeMergeRecursivelyTypes, "unit/RecursiveRecordTypeMergeRecursivelyTypes");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordTypeMergeRhsEmpty, "unit/RecursiveRecordTypeMergeRhsEmpty");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordTypeMergeTwo, "unit/RecursiveRecordTypeMergeTwo");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordTypeMergeTwoKinds, "unit/RecursiveRecordTypeMergeTwoKinds");
+// ti_success!(spec_typeinference_success_unit_RecursiveRecordTypeMergeTwoTypes, "unit/RecursiveRecordTypeMergeTwoTypes");
+// ti_success!(spec_typeinference_success_unit_RightBiasedRecordMergeRhsEmpty, "unit/RightBiasedRecordMergeRhsEmpty");
+// ti_success!(spec_typeinference_success_unit_RightBiasedRecordMergeTwo, "unit/RightBiasedRecordMergeTwo");
+// ti_success!(spec_typeinference_success_unit_RightBiasedRecordMergeTwoDifferent, "unit/RightBiasedRecordMergeTwoDifferent");
+// ti_success!(spec_typeinference_success_unit_RightBiasedRecordMergeTwoKinds, "unit/RightBiasedRecordMergeTwoKinds");
+// ti_success!(spec_typeinference_success_unit_RightBiasedRecordMergeTwoTypes, "unit/RightBiasedRecordMergeTwoTypes");
+ti_success!(spec_typeinference_success_unit_SomeTrue, "unit/SomeTrue");
+ti_success!(spec_typeinference_success_unit_Text, "unit/Text");
+ti_success!(spec_typeinference_success_unit_TextLiteral, "unit/TextLiteral");
+ti_success!(spec_typeinference_success_unit_TextLiteralNormalizeArguments, "unit/TextLiteralNormalizeArguments");
+ti_success!(spec_typeinference_success_unit_TextLiteralWithInterpolation, "unit/TextLiteralWithInterpolation");
+// ti_success!(spec_typeinference_success_unit_TextShow, "unit/TextShow");
+ti_success!(spec_typeinference_success_unit_True, "unit/True");
+ti_success!(spec_typeinference_success_unit_Type, "unit/Type");
+ti_success!(spec_typeinference_success_unit_TypeAnnotation, "unit/TypeAnnotation");
+// ti_success!(spec_typeinference_success_unit_UnionConstructorField, "unit/UnionConstructorField");
+// ti_success!(spec_typeinference_success_unit_UnionOne, "unit/UnionOne");
+// ti_success!(spec_typeinference_success_unit_UnionTypeEmpty, "unit/UnionTypeEmpty");
+// ti_success!(spec_typeinference_success_unit_UnionTypeKind, "unit/UnionTypeKind");
+// ti_success!(spec_typeinference_success_unit_UnionTypeOne, "unit/UnionTypeOne");
+// ti_success!(spec_typeinference_success_unit_UnionTypeType, "unit/UnionTypeType");