summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNadrieril2019-02-27 22:48:44 +0100
committerNadrieril2019-02-27 22:48:44 +0100
commit95d034158758e743b558a4453eada48579a50d34 (patch)
treebc33653dfcae32a16ffa044858534dfb1e25c8cb /tests
parent2c00699d217e0a54d44678529fa3d87936071fec (diff)
Add all normalization tests that pass
Diffstat (limited to 'tests')
-rw-r--r--tests/macros.rs31
-rw-r--r--tests/tests.rs187
2 files changed, 194 insertions, 24 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);
+ }
+ };
+}
diff --git a/tests/tests.rs b/tests/tests.rs
index d381efc..2f59425 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1,25 +1,164 @@
-use dhall::*;
+mod macros;
-macro_rules! include_test_str {
- ($x:expr) => { include_str!(concat!("../dhall-lang/tests/", $x, ".dhall")) };
-}
-
-macro_rules! include_test_strs_ab {
- ($x:expr) => { (include_test_str!(concat!($x, "A")), include_test_str!(concat!($x, "B"))) };
-}
-
-macro_rules! test_normalization {
- ($x:expr) => {
- let (expr_str, expected_str) = include_test_strs_ab!($x);
- let expr = parser::parse_expr(&expr_str).unwrap();
- let expected = parser::parse_expr(&expected_str).unwrap();
- assert_eq!(normalize::<_, X, _>(&expr), normalize::<_, X, _>(&expected));
- };
-}
-
-
-#[test]
-fn test(){
- test_normalization!("normalization/success/simple/naturalPlus");
- test_normalization!("normalization/success/simple/naturalShow");
-}
+make_spec_test!(normalization, spec_normalization_success_haskell_tutorial_access_0, "normalization/success/haskell-tutorial/access/0");
+// make_spec_test!(normalization, spec_normalization_success_haskell_tutorial_access_1, "normalization/success/haskell-tutorial/access/1");
+// make_spec_test!(normalization, spec_normalization_success_haskell_tutorial_combineTypes_0, "normalization/success/haskell-tutorial/combineTypes/0");
+// make_spec_test!(normalization, spec_normalization_success_haskell_tutorial_combineTypes_1, "normalization/success/haskell-tutorial/combineTypes/1");
+// make_spec_test!(normalization, spec_normalization_success_haskell_tutorial_prefer_0, "normalization/success/haskell-tutorial/prefer/0");
+// make_spec_test!(normalization, spec_normalization_success_haskell_tutorial_projection_0, "normalization/success/haskell-tutorial/projection/0");
+// make_spec_test!(normalization, spec_normalization_success_multiline_escape, "normalization/success/multiline/escape");
+// make_spec_test!(normalization, spec_normalization_success_multiline_hangingIndent, "normalization/success/multiline/hangingIndent");
+// make_spec_test!(normalization, spec_normalization_success_multiline_interesting, "normalization/success/multiline/interesting");
+// make_spec_test!(normalization, spec_normalization_success_multiline_interiorIndent, "normalization/success/multiline/interiorIndent");
+// make_spec_test!(normalization, spec_normalization_success_multiline_interpolation, "normalization/success/multiline/interpolation");
+// make_spec_test!(normalization, spec_normalization_success_multiline_preserveComment, "normalization/success/multiline/preserveComment");
+// make_spec_test!(normalization, spec_normalization_success_multiline_singleLine, "normalization/success/multiline/singleLine");
+// make_spec_test!(normalization, spec_normalization_success_multiline_twoLines, "normalization/success/multiline/twoLines");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_0, "normalization/success/prelude/Bool/and/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_1, "normalization/success/prelude/Bool/and/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_build_0, "normalization/success/prelude/Bool/build/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_build_1, "normalization/success/prelude/Bool/build/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_0, "normalization/success/prelude/Bool/even/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_1, "normalization/success/prelude/Bool/even/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_2, "normalization/success/prelude/Bool/even/2");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_3, "normalization/success/prelude/Bool/even/3");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_fold_0, "normalization/success/prelude/Bool/fold/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_fold_1, "normalization/success/prelude/Bool/fold/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_not_0, "normalization/success/prelude/Bool/not/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_not_1, "normalization/success/prelude/Bool/not/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_0, "normalization/success/prelude/Bool/odd/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_1, "normalization/success/prelude/Bool/odd/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_2, "normalization/success/prelude/Bool/odd/2");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_3, "normalization/success/prelude/Bool/odd/3");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_or_0, "normalization/success/prelude/Bool/or/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_or_1, "normalization/success/prelude/Bool/or/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_show_0, "normalization/success/prelude/Bool/show/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_show_1, "normalization/success/prelude/Bool/show/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Double_show_0, "normalization/success/prelude/Double/show/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Double_show_1, "normalization/success/prelude/Double/show/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Integer_show_0, "normalization/success/prelude/Integer/show/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Integer_show_1, "normalization/success/prelude/Integer/show/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Integer_toDouble_0, "normalization/success/prelude/Integer/toDouble/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Integer_toDouble_1, "normalization/success/prelude/Integer/toDouble/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_all_0, "normalization/success/prelude/List/all/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_all_1, "normalization/success/prelude/List/all/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_any_0, "normalization/success/prelude/List/any/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_any_1, "normalization/success/prelude/List/any/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_build_0, "normalization/success/prelude/List/build/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_build_1, "normalization/success/prelude/List/build/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_concat_0, "normalization/success/prelude/List/concat/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_concat_1, "normalization/success/prelude/List/concat/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_concatMap_0, "normalization/success/prelude/List/concatMap/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_concatMap_1, "normalization/success/prelude/List/concatMap/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_filter_0, "normalization/success/prelude/List/filter/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_filter_1, "normalization/success/prelude/List/filter/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_fold_0, "normalization/success/prelude/List/fold/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_fold_1, "normalization/success/prelude/List/fold/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_fold_2, "normalization/success/prelude/List/fold/2");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_generate_0, "normalization/success/prelude/List/generate/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_generate_1, "normalization/success/prelude/List/generate/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_head_0, "normalization/success/prelude/List/head/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_head_1, "normalization/success/prelude/List/head/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_indexed_0, "normalization/success/prelude/List/indexed/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_indexed_1, "normalization/success/prelude/List/indexed/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_iterate_0, "normalization/success/prelude/List/iterate/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_iterate_1, "normalization/success/prelude/List/iterate/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_last_0, "normalization/success/prelude/List/last/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_last_1, "normalization/success/prelude/List/last/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_length_0, "normalization/success/prelude/List/length/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_length_1, "normalization/success/prelude/List/length/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_map_0, "normalization/success/prelude/List/map/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_map_1, "normalization/success/prelude/List/map/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_null_0, "normalization/success/prelude/List/null/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_null_1, "normalization/success/prelude/List/null/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_replicate_0, "normalization/success/prelude/List/replicate/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_replicate_1, "normalization/success/prelude/List/replicate/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_reverse_0, "normalization/success/prelude/List/reverse/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_reverse_1, "normalization/success/prelude/List/reverse/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_shifted_0, "normalization/success/prelude/List/shifted/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_shifted_1, "normalization/success/prelude/List/shifted/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_unzip_0, "normalization/success/prelude/List/unzip/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_List_unzip_1, "normalization/success/prelude/List/unzip/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_build_0, "normalization/success/prelude/Natural/build/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_build_1, "normalization/success/prelude/Natural/build/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_enumerate_0, "normalization/success/prelude/Natural/enumerate/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_enumerate_1, "normalization/success/prelude/Natural/enumerate/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_even_0, "normalization/success/prelude/Natural/even/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_even_1, "normalization/success/prelude/Natural/even/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_fold_0, "normalization/success/prelude/Natural/fold/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_fold_1, "normalization/success/prelude/Natural/fold/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_fold_2, "normalization/success/prelude/Natural/fold/2");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_isZero_0, "normalization/success/prelude/Natural/isZero/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_isZero_1, "normalization/success/prelude/Natural/isZero/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_odd_0, "normalization/success/prelude/Natural/odd/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_odd_1, "normalization/success/prelude/Natural/odd/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_product_0, "normalization/success/prelude/Natural/product/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_product_1, "normalization/success/prelude/Natural/product/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_show_0, "normalization/success/prelude/Natural/show/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_show_1, "normalization/success/prelude/Natural/show/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_sum_0, "normalization/success/prelude/Natural/sum/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_sum_1, "normalization/success/prelude/Natural/sum/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_toDouble_0, "normalization/success/prelude/Natural/toDouble/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_toDouble_1, "normalization/success/prelude/Natural/toDouble/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_toInteger_0, "normalization/success/prelude/Natural/toInteger/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_toInteger_1, "normalization/success/prelude/Natural/toInteger/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_all_0, "normalization/success/prelude/Optional/all/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_all_1, "normalization/success/prelude/Optional/all/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_any_0, "normalization/success/prelude/Optional/any/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_any_1, "normalization/success/prelude/Optional/any/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_build_0, "normalization/success/prelude/Optional/build/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_build_1, "normalization/success/prelude/Optional/build/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_concat_0, "normalization/success/prelude/Optional/concat/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_concat_1, "normalization/success/prelude/Optional/concat/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_concat_2, "normalization/success/prelude/Optional/concat/2");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_filter_0, "normalization/success/prelude/Optional/filter/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_filter_1, "normalization/success/prelude/Optional/filter/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_fold_0, "normalization/success/prelude/Optional/fold/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_fold_1, "normalization/success/prelude/Optional/fold/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_head_0, "normalization/success/prelude/Optional/head/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_head_1, "normalization/success/prelude/Optional/head/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_head_2, "normalization/success/prelude/Optional/head/2");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_last_0, "normalization/success/prelude/Optional/last/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_last_1, "normalization/success/prelude/Optional/last/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_last_2, "normalization/success/prelude/Optional/last/2");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_length_0, "normalization/success/prelude/Optional/length/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_length_1, "normalization/success/prelude/Optional/length/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_map_0, "normalization/success/prelude/Optional/map/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_map_1, "normalization/success/prelude/Optional/map/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_null_0, "normalization/success/prelude/Optional/null/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_null_1, "normalization/success/prelude/Optional/null/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_toList_0, "normalization/success/prelude/Optional/toList/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_toList_1, "normalization/success/prelude/Optional/toList/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_unzip_0, "normalization/success/prelude/Optional/unzip/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_unzip_1, "normalization/success/prelude/Optional/unzip/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Text_concat_0, "normalization/success/prelude/Text/concat/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Text_concat_1, "normalization/success/prelude/Text/concat/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatMap_0, "normalization/success/prelude/Text/concatMap/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatMap_1, "normalization/success/prelude/Text/concatMap/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatMapSep_0, "normalization/success/prelude/Text/concatMapSep/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatMapSep_1, "normalization/success/prelude/Text/concatMapSep/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatSep_0, "normalization/success/prelude/Text/concatSep/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatSep_1, "normalization/success/prelude/Text/concatSep/1");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Text_show_0, "normalization/success/prelude/Text/show/0");
+// make_spec_test!(normalization, spec_normalization_success_prelude_Text_show_1, "normalization/success/prelude/Text/show/1");
+// make_spec_test!(normalization, spec_normalization_success_remoteSystems, "normalization/success/remoteSystems");
+// make_spec_test!(normalization, spec_normalization_success_simple_constructorsId, "normalization/success/simple/constructorsId");
+// make_spec_test!(normalization, spec_normalization_success_simple_doubleShow, "normalization/success/simple/doubleShow");
+// make_spec_test!(normalization, spec_normalization_success_simple_integerShow, "normalization/success/simple/integerShow");
+// make_spec_test!(normalization, spec_normalization_success_simple_integerToDouble, "normalization/success/simple/integerToDouble");
+// make_spec_test!(normalization, spec_normalization_success_simple_letlet, "normalization/success/simple/letlet");
+// make_spec_test!(normalization, spec_normalization_success_simple_listBuild, "normalization/success/simple/listBuild");
+// make_spec_test!(normalization, spec_normalization_success_simple_multiLine, "normalization/success/simple/multiLine");
+// make_spec_test!(normalization, spec_normalization_success_simple_naturalBuild, "normalization/success/simple/naturalBuild");
+make_spec_test!(normalization, spec_normalization_success_simple_naturalPlus, "normalization/success/simple/naturalPlus");
+make_spec_test!(normalization, spec_normalization_success_simple_naturalShow, "normalization/success/simple/naturalShow");
+// make_spec_test!(normalization, spec_normalization_success_simple_naturalToInteger, "normalization/success/simple/naturalToInteger");
+// make_spec_test!(normalization, spec_normalization_success_simple_optionalBuild, "normalization/success/simple/optionalBuild");
+// make_spec_test!(normalization, spec_normalization_success_simple_optionalBuildFold, "normalization/success/simple/optionalBuildFold");
+// make_spec_test!(normalization, spec_normalization_success_simple_optionalFold, "normalization/success/simple/optionalFold");
+// make_spec_test!(normalization, spec_normalization_success_simple_sortOperator, "normalization/success/simple/sortOperator");
+// make_spec_test!(normalization, spec_normalization_success_simplifications_and, "normalization/success/simplifications/and");
+// make_spec_test!(normalization, spec_normalization_success_simplifications_eq, "normalization/success/simplifications/eq");
+// make_spec_test!(normalization, spec_normalization_success_simplifications_ifThenElse, "normalization/success/simplifications/ifThenElse");
+// make_spec_test!(normalization, spec_normalization_success_simplifications_ne, "normalization/success/simplifications/ne");
+// make_spec_test!(normalization, spec_normalization_success_simplifications_or, "normalization/success/simplifications/or");