summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabrielGonzalez <>2018-08-31 15:22:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-08-31 15:22:00 (GMT)
commitc5e65dd8a90bcedb84857caf483c5501b4666f7d (patch)
tree866b5948a4ae1d2b9d59989da939300c3f2e00dc
parentd7d197c85391667647903f412abfc0c8264115ae (diff)
version 1.2.31.2.3
-rw-r--r--CHANGELOG.md6
-rw-r--r--dhall-json.cabal34
-rw-r--r--src/Dhall/JSON.hs2
-rw-r--r--tasty/Main.hs61
-rw-r--r--tasty/data/issue48.dhall1
-rw-r--r--tasty/data/issue48.json5
6 files changed, 99 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 663a0d4..7531fe0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+1.2.3
+
+* Correctly handle nested association lists
+* Increase upper bound on `dhall` dependency
+* Increase upper bound on `yaml` dependency
+
1.2.2
* Increase upper bound on `dhall` dependency
diff --git a/dhall-json.cabal b/dhall-json.cabal
index 7c13b83..b064db7 100644
--- a/dhall-json.cabal
+++ b/dhall-json.cabal
@@ -1,5 +1,5 @@
Name: dhall-json
-Version: 1.2.2
+Version: 1.2.3
Cabal-Version: >=1.8.0.2
Build-Type: Simple
Tested-With: GHC == 7.10.2, GHC == 8.0.1
@@ -22,7 +22,10 @@ Description:
The "Dhall.JSON" module also contains instructions for how to use this
package
Category: Compiler
-Extra-Source-Files: CHANGELOG.md
+Extra-Source-Files:
+ CHANGELOG.md
+ tasty/data/*.dhall
+ tasty/data/*.json
Source-Repository head
Type: git
Location: https://github.com/dhall-lang/dhall-json
@@ -32,7 +35,7 @@ Library
Build-Depends:
base >= 4.8.0.0 && < 5 ,
aeson >= 1.0.0.0 && < 1.5 ,
- dhall >= 1.15.0 && < 1.17,
+ dhall >= 1.15.0 && < 1.18,
insert-ordered-containers < 1.14,
optparse-applicative >= 0.14.0.0 && < 0.15,
text >= 0.11.1.0 && < 1.3 ,
@@ -58,11 +61,24 @@ Executable dhall-to-yaml
Hs-Source-Dirs: dhall-to-yaml
Main-Is: Main.hs
Build-Depends:
- base ,
- bytestring < 0.11,
- dhall ,
- dhall-json ,
- optparse-applicative ,
- yaml >= 0.5.0 && < 0.10,
+ base ,
+ bytestring < 0.11,
+ dhall ,
+ dhall-json ,
+ optparse-applicative ,
+ yaml >= 0.5.0 && < 0.11,
text
GHC-Options: -Wall
+
+Test-Suite tasty
+ Type: exitcode-stdio-1.0
+ Hs-Source-Dirs: tasty
+ Main-Is: Main.hs
+ Build-Depends:
+ base,
+ aeson ,
+ dhall ,
+ dhall-json ,
+ tasty < 1.2,
+ text ,
+ tasty-hunit >= 0.2
diff --git a/src/Dhall/JSON.hs b/src/Dhall/JSON.hs
index 12b4f48..e043a57 100644
--- a/src/Dhall/JSON.hs
+++ b/src/Dhall/JSON.hs
@@ -512,7 +512,7 @@ convertToHomogeneousMaps (Conversion {..}) e0 = loop (Dhall.Core.normalize e0)
Dhall.Core.ListLit a b ->
case transform of
- Just c -> c
+ Just c -> loop c
Nothing -> Dhall.Core.ListLit a' b'
where
elements = Data.Foldable.toList b
diff --git a/tasty/Main.hs b/tasty/Main.hs
new file mode 100644
index 0000000..3db9a07
--- /dev/null
+++ b/tasty/Main.hs
@@ -0,0 +1,61 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE RecordWildCards #-}
+
+module Main where
+
+import Dhall.JSON (Conversion(..))
+import Test.Tasty (TestTree)
+
+import qualified Control.Exception
+import qualified Data.Aeson
+import qualified Data.Text.IO
+import qualified Dhall.Import
+import qualified Dhall.JSON
+import qualified Dhall.Parser
+import qualified Test.Tasty
+import qualified Test.Tasty.HUnit
+
+main :: IO ()
+main = Test.Tasty.defaultMain testTree
+
+testTree :: TestTree
+testTree =
+ Test.Tasty.testGroup "dhall-json"
+ [ issue48
+ ]
+
+issue48 :: TestTree
+issue48 = Test.Tasty.HUnit.testCase "Issue #48" assertion
+ where
+ assertion = do
+ let file = "./tasty/data/issue48.dhall"
+
+ code <- Data.Text.IO.readFile file
+
+ parsedExpression <- case Dhall.Parser.exprFromText file code of
+ Left exception -> Control.Exception.throwIO exception
+ Right parsedExpression -> return parsedExpression
+
+ resolvedExpression <- Dhall.Import.load parsedExpression
+
+ let mapKey = "mapKey"
+ let mapValue = "mapValue"
+ let conversion = Conversion {..}
+
+ let convertedExpression =
+ Dhall.JSON.convertToHomogeneousMaps conversion resolvedExpression
+
+ actualValue <- case Dhall.JSON.dhallToJSON convertedExpression of
+ Left exception -> Control.Exception.throwIO exception
+ Right actualValue -> return actualValue
+
+ result <- Data.Aeson.eitherDecodeFileStrict "./tasty/data/issue48.json"
+
+ expectedValue <- case result of
+ Left string -> fail string
+ Right expectedValue -> return expectedValue
+
+ let message =
+ "Conversion to homogeneous maps did not generate the expected JSON output"
+
+ Test.Tasty.HUnit.assertEqual message expectedValue actualValue
diff --git a/tasty/data/issue48.dhall b/tasty/data/issue48.dhall
new file mode 100644
index 0000000..2ad9c38
--- /dev/null
+++ b/tasty/data/issue48.dhall
@@ -0,0 +1 @@
+[ { mapKey = "somekey", mapValue = [ { mapKey = "\$gt", mapValue = 100 } ] } ]
diff --git a/tasty/data/issue48.json b/tasty/data/issue48.json
new file mode 100644
index 0000000..f8ba402
--- /dev/null
+++ b/tasty/data/issue48.json
@@ -0,0 +1,5 @@
+{
+ "somekey": {
+ "$gt": 100
+ }
+}