From 2551e6f91110bfe385fa65dd63e576df637c26fa Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 5 Aug 2019 18:18:45 +0200 Subject: Add some tests --- dhall-lang | 2 +- dhall/build.rs | 20 ++++++++++++++++++-- dhall/src/phase/normalize.rs | 10 ++++++++++ tests_buffer | 3 +++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/dhall-lang b/dhall-lang index dbf4ebc..e01c734 160000 --- a/dhall-lang +++ b/dhall-lang @@ -1 +1 @@ -Subproject commit dbf4ebcfabf499e87c27e75bec108d91929ccc31 +Subproject commit e01c734e612daac327b06845e45c34552d65d9e1 diff --git a/dhall/build.rs b/dhall/build.rs index 5a99def..7e320c5 100644 --- a/dhall/build.rs +++ b/dhall/build.rs @@ -90,6 +90,10 @@ fn main() -> std::io::Result<()> { // TODO: Inline headers are not implemented || path == "success/unit/import/parenthesizeUsing" || path == "success/unit/import/inlineUsing" + // TODO: projection by expression + || path == "success/recordProjectionByExpression" + || path == "success/unit/recordProjectionByExpression" + || path == "success/unit/recordProjectionByExpressionEmpty" }, )?; @@ -105,6 +109,10 @@ fn main() -> std::io::Result<()> { || path == "success/largeExpression" // TODO: Inline headers are not implemented || path == "success/unit/import/inlineUsing" + // TODO: projection by expression + || path == "success/recordProjectionByExpression" + || path == "success/unit/recordProjectionByExpression" + || path == "success/unit/recordProjectionByExpressionEmpty" }, )?; @@ -124,8 +132,11 @@ fn main() -> std::io::Result<()> { // See https://github.com/pyfisch/cbor/issues/109 || path == "success/double" // TODO: Inline headers are not implemented - || path == "success/unit/import/parenthesizeUsing" || path == "success/unit/import/inlineUsing" + // TODO: projection by expression + || path == "success/recordProjectionByExpression" + || path == "success/unit/recordProjectionByExpression" + || path == "success/unit/recordProjectionByExpressionEmpty" }, )?; @@ -139,9 +150,14 @@ fn main() -> std::io::Result<()> { path == "success/simple/integerToDouble" // Too slow || path == "success/remoteSystems" - // TODO: selection by expression + // TODO: projection by expression || path == "success/unit/RecordProjectionTypeEmpty" || path == "success/unit/RecordProjectionTypeNonEmpty" + || path == "success/unit/RecordProjectionTypeNormalizeProjection" + // TODO: fix Double/show + || path == "success/prelude/JSON/number/1" + // the test is wrong + || path == "success/prelude/JSON/Type/0" }, )?; diff --git a/dhall/src/phase/normalize.rs b/dhall/src/phase/normalize.rs index f3684d1..d5bdc9e 100644 --- a/dhall/src/phase/normalize.rs +++ b/dhall/src/phase/normalize.rs @@ -72,6 +72,16 @@ pub fn apply_builtin(b: Builtin, args: Vec) -> Value { (TextShow, [v, r..]) => match &*v.as_value() { TextLit(elts) => { match elts.as_slice() { + // Empty string literal. + [] => { + // Printing InterpolatedText takes care of all the escaping + let txt: InterpolatedText = std::iter::empty().collect(); + let s = txt.to_string(); + Ok(( + r, + TextLit(vec![InterpolatedTextContents::Text(s)]), + )) + } // If there are no interpolations (invariants ensure that when there are no // interpolations, there is a single Text item) in the literal. [InterpolatedTextContents::Text(s)] => { diff --git a/tests_buffer b/tests_buffer index deb245d..5234562 100644 --- a/tests_buffer +++ b/tests_buffer @@ -98,6 +98,8 @@ failure/ normalization: variables across import boundaries +Text/show "" +Double/show -1.5e-10 TextLitNested1 "${""}${x}" TextLitNested2 "${"${x}"}" TextLitNested3 "${"${""}"}${x}" @@ -106,6 +108,7 @@ variables across import boundaries typecheck: something that involves destructuring a recordtype after merge +add some of the more complicated Prelude tests back, like List/enumerate failure on old-style optional literal success/ MergeEmptyAlternative merge { x = 1 } < x >.x -- cgit v1.2.3