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/build.rs | 20 ++++++++++++++++++-- dhall/src/phase/normalize.rs | 10 ++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'dhall') 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)] => { -- cgit v1.2.3