@@ -7,19 +7,19 @@ import Data.Either (Either(..))
77import Data.Foldable (traverse_)
88import Data.List as List
99import Data.List.Lazy as LazyList
10+import Data.Map as Map
1011import Data.Maybe (Maybe(..))
1112import Data.Newtype (class Newtype, un)
1213import Data.Nullable as Nullable
1314import Data.Tuple (Tuple(..))
1415import Data.Tuple.Nested ((/\))
1516import Data.Variant (Variant, inj)
16−import Debug (spy)
1717import Foreign.Object as Object
18−import Test.Spec (Spec, describe, it, itOnly)
18+import Test.Spec (Spec, describe, it)
1919import Test.Spec.Assertions (shouldEqual)
2020import Test.Util (roundtrips)
2121import Type.Proxy (Proxy(..))
22−import Yoga.JSON (class ReadForeign, class WriteForeign, readJSON, readJSON_, writeJSON)
22+import Yoga.JSON (class ReadForeign, class WriteForeign, readJSON, writeJSON)
2323import Yoga.JSON.Variant (TaggedVariant(..), UntaggedVariant(..))
2424
2525spec :: Spec Unit
@@ -45,6 +45,12 @@ spec = describe "En- and decoding" $ do
4545 it "roundtrips List" $ traverse_ roundtrips (List.fromFoldable [["A", "B"],[]])
4646 it "roundtrips NonEmptyArray" $ roundtrips (NEA.cons' "A" ["B"])
4747 it "roundtrips Object" $ roundtrips (Object.fromHomogeneous { a: 12, b: 54 })
48+ it "roundtrips String Map" $ roundtrips (Map.fromFoldable [("A" /\ 8),("C" /\ 7)])
49+ it "roundtrips Int Map" $ roundtrips (Map.fromFoldable [(4 /\ "B"),(8 /\ "D")])
50+ it "roundtrips Map with String newtype keys"
51+ $ roundtrips (Map.fromFoldable [(Stringy "A" /\ "B"),(Stringy "C" /\ "D")])
52+ it "roundtrips Map with Int newtype keys"
53+ $ roundtrips (Map.fromFoldable [(Inty 4 /\ "B"),(Inty 8 /\ "D")])
4854
4955 describe "works on record types" do
5056 it "roundtrips" do
@@ -86,6 +92,8 @@ spec = describe "En- and decoding" $ do
8692
8793type ExampleVariant = ("erwin" :: String, "jackie" :: Int)
8894type ExampleTaggedVariant t v = TaggedVariant t v ExampleVariant
95+
96+erwin ∷ ∀ a r. a → Variant ( erwin ∷ a | r )
8997erwin = inj (Proxy :: Proxy "erwin")
9098type Erwin r = (erwin :: String | r)
9199
@@ -93,5 +101,14 @@ newtype Stringy = Stringy String
93101derive instance Newtype Stringy _
94102derive newtype instance Show Stringy
95103derive newtype instance Eq Stringy
104+derive newtype instance Ord Stringy
96105derive newtype instance WriteForeign Stringy
97−derive newtype instance ReadForeign Stringy
106+derive newtype instance ReadForeign Stringy
107+
108+newtype Inty = Inty Int
109+derive instance Newtype Inty _
110+derive newtype instance Show Inty
111+derive newtype instance Eq Inty
112+derive newtype instance Ord Inty
113+derive newtype instance WriteForeign Inty
114+derive newtype instance ReadForeign Inty