summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
authorNadrieril2019-04-14 19:59:50 +0200
committerNadrieril2019-04-14 19:59:50 +0200
commit8e5c1ca7df24653ccb02050f8b167673536f2f42 (patch)
treeffe1bcb6d7c3ada0ee923c4054f818a99e5fc297 /dhall
parent1ac24d88ecd2001dc49688afcf6f93944ff60e96 (diff)
Add import tests
Closes #71
Diffstat (limited to '')
-rw-r--r--dhall/src/imports.rs28
-rw-r--r--dhall/src/tests.rs12
2 files changed, 40 insertions, 0 deletions
diff --git a/dhall/src/imports.rs b/dhall/src/imports.rs
index 3972e0e..2dce39d 100644
--- a/dhall/src/imports.rs
+++ b/dhall/src/imports.rs
@@ -120,3 +120,31 @@ impl<'a> Parsed<'a> {
crate::imports::skip_resolve_expr(self)
}
}
+
+#[cfg(test)]
+mod spec_tests {
+ #![rustfmt::skip]
+
+ macro_rules! import_success {
+ ($name:ident, $path:expr) => {
+ make_spec_test!(Import, Success, $name, $path);
+ };
+ }
+
+ // macro_rules! import_failure {
+ // ($name:ident, $path:expr) => {
+ // make_spec_test!(Import, Failure, $name, $path);
+ // };
+ // }
+
+ // import_success!(success_alternativeEnvNatural, "alternativeEnvNatural");
+ // import_success!(success_alternativeEnvSimple, "alternativeEnvSimple");
+ // import_success!(success_alternativeNatural, "alternativeNatural");
+ // import_success!(success_asText, "asText");
+ import_success!(success_fieldOrder, "fieldOrder");
+ // import_failure!(failure_alternativeEnv, "alternativeEnv");
+ // import_failure!(failure_alternativeEnvMissing, "alternativeEnvMissing");
+ // import_failure!(failure_cycle, "cycle");
+ // import_failure!(failure_missing, "missing");
+ // import_failure!(failure_referentiallyInsane, "referentiallyInsane");
+}
diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs
index 4343341..4a69050 100644
--- a/dhall/src/tests.rs
+++ b/dhall/src/tests.rs
@@ -38,6 +38,7 @@ use std::path::PathBuf;
#[derive(Copy, Clone)]
pub enum Feature {
Parser,
+ Import,
Normalization,
Typecheck,
TypeInference,
@@ -85,6 +86,7 @@ pub fn run_test(
use self::Status::*;
let feature_prefix = match feature {
Parser => "parser/",
+ Import => "import/",
Normalization => "normalization/",
Typecheck => "typecheck/",
TypeInference => "type-inference/",
@@ -126,6 +128,11 @@ pub fn run_test(
match feature {
Parser => unreachable!(),
+ Import => {
+ // Not sure whether to normalize or not
+ let expr = expr.skip_typecheck().skip_normalize();
+ assert_eq_display!(expr, expected);
+ }
Typecheck => {
expr.typecheck_with(&expected.into_type())?;
}
@@ -150,6 +157,11 @@ pub fn run_test(
e => panic!("Expected parse error, got: {:?}", e),
}
}
+ Import => {
+ parse_file_str(&file_path)?
+ .resolve()
+ .unwrap_err();
+ }
Normalization => unreachable!(),
Typecheck | TypeInference => {
parse_file_str(&file_path)?