@@ -1,8 +1,10 @@
1+{-# OPTIONS_GHC -fdefer-type-errors #-}
12module JRecSpec (spec) where
23
34import Control.Lens ((&), (.~), (^.))
45import JRec
56import Test.Hspec
7+import Test.ShouldNotTypecheck
68
79spec :: Spec
810spec = do
@@ -50,7 +52,7 @@ spec = do
5052 Rec (#a := 1) `append` Rec (#b := 2)
5153 `shouldBe` Rec (#a := 1, #b := 2)
5254 it "append with duplicates" $ do
53− -- `append` will not deal with duplicates; based on current
55+ -- TODO: `append` will not deal with duplicates; based on current
5456 -- implementation, the last value (here, 8) will overwrite all duplicate
5557 -- fields. See `union` if you want to deal with duplicates sensibly.
5658 pendingWith "append should just append?"
@@ -71,12 +73,8 @@ spec = do
7173 it "simple insert" $ do
7274 (#a := 1) `insert` Rec (#b := 2, #c := 3)
7375 `shouldBe` Rec (#a := 1, #b := 2, #c := 3)
74− -- TODO: type check should fail
75− -- it "insert of already existing field should fail" $ do
76− -- (#a := 1) `insert` Rec (#b := 2, #a := 0, #c := 3)
77− -- `shouldBe` Rec (#a := 1, #b := 2, #a := 0, #c := 3)
78− it "duplicate insert should be disallowed" $ do
79− pendingWith "TODO"
76+ it "type-check fails if field already exists" $ do
77+ shouldNotTypecheck ((#a := '1') `insert` Rec (#b := '2', #a := '0'))
8078 describe "insertOrSet" $ do
8179 it "distinct" $ do
8280 insertOrSet (#a := 1) (Rec (#b := 2, #c := 3))