summaryrefslogtreecommitdiff
path: root/dhall/src/tests.rs
diff options
context:
space:
mode:
authorNadrieril2020-01-29 18:48:19 +0000
committerNadrieril2020-01-29 19:11:48 +0000
commit1e466a20533d936f44430b1bc18508cd00e5ccd2 (patch)
tree20c025af6ed539a600ec8db9e1339c9c4e7c9112 /dhall/src/tests.rs
parentf88880004c7dcf5e67c4d5e2330e6e879523f27b (diff)
Use TyExpr in Typed
Diffstat (limited to '')
-rw-r--r--dhall/src/tests.rs85
1 files changed, 14 insertions, 71 deletions
diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs
index 1c687f6..08feadf 100644
--- a/dhall/src/tests.rs
+++ b/dhall/src/tests.rs
@@ -158,65 +158,24 @@ pub fn run_test(test: Test<'_>) -> Result<()> {
parse_file_str(&file_path)?.resolve().unwrap_err();
}
TypeInferenceSuccess(expr_file_path, expected_file_path) => {
- // let expr =
- // parse_file_str(&expr_file_path)?.resolve()?.typecheck()?;
- // let ty = expr.get_type()?.to_expr();
- // let expr = parse_file_str(&expr_file_path)?.resolve()?.to_expr();
- // let tyexpr = crate::semantics::nze::nzexpr::typecheck(expr)?;
- // let ty = tyexpr.get_type()?.to_expr();
- //
- let expr = parse_file_str(&expr_file_path)?.resolve()?.to_expr();
- let ty = crate::semantics::tck::typecheck::typecheck(&expr)?
- .get_type()?
- .to_expr(crate::semantics::phase::ToExprOptions {
- alpha: false,
- normalize: true,
- });
+ let expr =
+ parse_file_str(&expr_file_path)?.resolve()?.typecheck()?;
+ let ty = expr.get_type()?.to_expr();
let expected = parse_file_str(&expected_file_path)?.to_expr();
assert_eq_display!(ty, expected);
- //
- // let expr = parse_file_str(&expr_file_path)?.resolve()?.to_expr();
- // let ty = crate::semantics::tck::typecheck::typecheck(&expr)?
- // .get_type()?;
- // let expected = parse_file_str(&expected_file_path)?.to_expr();
- // let expected = crate::semantics::tck::typecheck::typecheck(&expected)?
- // .normalize_whnf_noenv();
- // // if ty != expected {
- // // assert_eq_display!(ty.to_expr(crate::semantics::phase::ToExprOptions {
- // // alpha: false,
- // // normalize: true,
- // // }), expected.to_expr(crate::semantics::phase::ToExprOptions {
- // // alpha: false,
- // // normalize: true,
- // // }))
- // // }
- // assert_eq_pretty!(ty, expected);
}
TypeInferenceFailure(file_path) => {
- // let mut res =
- // parse_file_str(&file_path)?.skip_resolve()?.typecheck();
- // if let Ok(e) = &res {
- // // If e did typecheck, check that get_type fails
- // res = e.get_type();
- // }
- // res.unwrap_err();
-
- let res = crate::semantics::tck::typecheck::typecheck(
- &parse_file_str(&file_path)?.skip_resolve()?.to_expr(),
- );
+ let res = parse_file_str(&file_path)?.skip_resolve()?.typecheck();
if let Ok(e) = &res {
// If e did typecheck, check that get_type fails
e.get_type().unwrap_err();
- } else {
- res.unwrap_err();
}
}
// Checks the output of the type error against a text file. If the text file doesn't exist,
// we instead write to it the output we got. This makes it easy to update those files: just
// `rm -r dhall/tests/type-errors` and run the tests again.
TypeError(file_path) => {
- let mut res =
- parse_file_str(&file_path)?.skip_resolve()?.typecheck();
+ let res = parse_file_str(&file_path)?.skip_resolve()?.typecheck();
let file_path = PathBuf::from(file_path);
let error_file_path = file_path
.strip_prefix("../dhall-lang/tests/type-inference/failure/")
@@ -224,11 +183,13 @@ pub fn run_test(test: Test<'_>) -> Result<()> {
let error_file_path =
PathBuf::from("tests/type-errors/").join(error_file_path);
let error_file_path = error_file_path.with_extension("txt");
- if let Ok(e) = &res {
- // If e did typecheck, check that get_type fails
- res = e.get_type();
- }
- let err: Error = res.unwrap_err().into();
+ let err: Error = match res {
+ Ok(e) => {
+ // If e did typecheck, check that get_type fails
+ e.get_type().unwrap_err().into()
+ }
+ Err(e) => e.into(),
+ };
if error_file_path.is_file() {
let expected_msg = std::fs::read_to_string(error_file_path)?;
@@ -241,28 +202,10 @@ pub fn run_test(test: Test<'_>) -> Result<()> {
}
}
Normalization(expr_file_path, expected_file_path) => {
- // let expr = parse_file_str(&expr_file_path)?
- // .resolve()?
- // .typecheck()?
- // .normalize()
- // .to_expr();
- // let expr = parse_file_str(&expr_file_path)?.resolve()?.to_expr();
- // let expr = crate::semantics::nze::nzexpr::typecheck(expr)?
- // .normalize()
- // .to_expr();
- // let expr = parse_file_str(&expr_file_path)?
- // .resolve()?
- // .typecheck()?
- // .to_value()
- // .to_tyexpr_noenv()
- // .normalize_whnf_noenv()
- // .to_expr(crate::semantics::phase::ToExprOptions {
- // alpha: false,
- // normalize: true,
- // });
let expr = parse_file_str(&expr_file_path)?
.resolve()?
- .tck_and_normalize_new_flow()?
+ .typecheck()?
+ .normalize()
.to_expr();
let expected = parse_file_str(&expected_file_path)?.to_expr();