summaryrefslogtreecommitdiff
path: root/dhall/tests/spec.rs
diff options
context:
space:
mode:
authorNadrieril2020-12-07 14:15:43 +0000
committerNadrieril2020-12-07 19:34:39 +0000
commit8c5b3ff15f2125e9d731fc199e194e1993c36b37 (patch)
treea88ac770aa3e7605feed8381877f290a2b64cd43 /dhall/tests/spec.rs
parent3c522217b7445c6df9e170d830f485086ad7e062 (diff)
Thread cx everywhere else imports are read
Diffstat (limited to '')
-rw-r--r--dhall/tests/spec.rs27
1 files changed, 12 insertions, 15 deletions
diff --git a/dhall/tests/spec.rs b/dhall/tests/spec.rs
index ab1dc2f..a0fe583 100644
--- a/dhall/tests/spec.rs
+++ b/dhall/tests/spec.rs
@@ -160,8 +160,7 @@ impl TestFile {
}
/// Check that the provided expression matches the file contents.
- pub fn compare(&self, expr: impl Into<Expr>) -> Result<()> {
- let expr = expr.into();
+ pub fn compare(&self, expr: Expr) -> Result<()> {
if !self.path().is_file() {
return self.write_expr(expr);
}
@@ -177,8 +176,7 @@ impl TestFile {
Ok(())
}
/// Check that the provided expression matches the file contents.
- pub fn compare_debug(&self, expr: impl Into<Expr>) -> Result<()> {
- let expr = expr.into();
+ pub fn compare_debug(&self, expr: Expr) -> Result<()> {
if !self.path().is_file() {
return self.write_expr(expr);
}
@@ -194,8 +192,7 @@ impl TestFile {
Ok(())
}
/// Check that the provided expression matches the file contents.
- pub fn compare_binary(&self, expr: impl Into<Expr>) -> Result<()> {
- let expr = expr.into();
+ pub fn compare_binary(&self, expr: Expr) -> Result<()> {
match self {
TestFile::Binary(_) => {}
_ => Err(TestError(format!("This is not a binary file")))?,
@@ -591,7 +588,7 @@ fn run_test(test: &SpecTest) -> Result<()> {
ParserSuccess => {
let expr = expr.parse()?;
// This exercices both parsing and binary decoding
- expected.compare_debug(expr)?;
+ expected.compare_debug(expr.to_expr())?;
}
ParserFailure => {
use std::io;
@@ -612,11 +609,11 @@ fn run_test(test: &SpecTest) -> Result<()> {
}
BinaryEncoding => {
let expr = expr.parse()?;
- expected.compare_binary(expr)?;
+ expected.compare_binary(expr.to_expr())?;
}
BinaryDecodingSuccess => {
let expr = expr.parse()?;
- expected.compare_debug(expr)?;
+ expected.compare_debug(expr.to_expr())?;
}
BinaryDecodingFailure => {
let err = unwrap_err(expr.parse())?;
@@ -627,24 +624,24 @@ fn run_test(test: &SpecTest) -> Result<()> {
// Round-trip pretty-printer
let reparsed = Parsed::parse_str(&parsed.to_string())?;
assert_eq!(reparsed, parsed);
- expected.compare_ui(parsed)?;
+ expected.compare_ui(parsed.to_expr())?;
}
ImportSuccess => {
let expr = expr.normalize(cx)?;
- expected.compare(expr)?;
+ expected.compare(expr.to_expr(cx))?;
}
ImportFailure => {
let err = unwrap_err(expr.resolve(cx))?;
expected.compare_ui(err)?;
}
SemanticHash => {
- let expr = expr.normalize(cx)?.to_expr_alpha();
+ let expr = expr.normalize(cx)?.to_expr_alpha(cx);
let hash = hex::encode(expr.sha256_hash()?);
expected.compare_ui(format!("sha256:{}", hash))?;
}
TypeInferenceSuccess => {
let ty = expr.typecheck(cx)?.get_type()?;
- expected.compare(ty)?;
+ expected.compare(ty.to_expr(cx))?;
}
TypeInferenceFailure => {
let err = unwrap_err(expr.typecheck(cx))?;
@@ -652,10 +649,10 @@ fn run_test(test: &SpecTest) -> Result<()> {
}
Normalization => {
let expr = expr.normalize(cx)?;
- expected.compare(expr)?;
+ expected.compare(expr.to_expr(cx))?;
}
AlphaNormalization => {
- let expr = expr.normalize(cx)?.to_expr_alpha();
+ let expr = expr.normalize(cx)?.to_expr_alpha(cx);
expected.compare(expr)?;
}
}