summaryrefslogtreecommitdiff
path: root/dhall/src/tests.rs
diff options
context:
space:
mode:
authorNadrieril2020-04-06 11:48:28 +0100
committerGitHub2020-04-06 11:48:28 +0100
commitd35cb130d80d628807a4247ddf84a8d0230c87ab (patch)
treeb99dadebeab8094c129cc5d872cfd561f9aa78f3 /dhall/src/tests.rs
parent4290615769fc26c5e4b70843e7fbfddf6359af41 (diff)
parent12b81d55e1343fc30138d1a13cd48fa2e05744df (diff)
Merge pull request #158 from Nadrieril/hash
Implement semantic hashing (but no caching yet)
Diffstat (limited to 'dhall/src/tests.rs')
-rw-r--r--dhall/src/tests.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs
index 2cd354f..5bcdb1c 100644
--- a/dhall/src/tests.rs
+++ b/dhall/src/tests.rs
@@ -63,6 +63,7 @@ enum Test {
BinaryDecodingFailure(TestFile, TestFile),
ImportSuccess(TestFile, TestFile),
ImportFailure(TestFile, TestFile),
+ SemanticHash(TestFile, TestFile),
TypeInferenceSuccess(TestFile, TestFile),
TypeInferenceFailure(TestFile, TestFile),
Normalization(TestFile, TestFile),
@@ -132,7 +133,7 @@ impl TestFile {
fn write_ui(&self, x: impl Display) -> Result<()> {
match self {
TestFile::UI(_) => {}
- _ => panic!("Can't write an error to a non-UI file"),
+ _ => panic!("Can't write a ui string to a dhall file"),
}
let path = self.path();
create_dir_all(path.parent().unwrap())?;
@@ -302,6 +303,11 @@ fn run_test(test: Test) -> Result<()> {
let err = expr.resolve().unwrap_err();
expected.compare_ui(err)?;
}
+ SemanticHash(expr, expected) => {
+ let expr = expr.normalize()?.to_expr_alpha();
+ let hash = hex::encode(expr.hash()?);
+ expected.compare_ui(format!("sha256:{}", hash))?;
+ }
TypeInferenceSuccess(expr, expected) => {
let ty = expr.typecheck()?.get_type()?;
expected.compare(ty)?;