@@ -1,8 +1,10 @@
1+{-# OPTIONS_GHC -fdefer-type-errors #-}
1module JRecSpec (spec) where
2module JRecSpec (spec) where
3import Control.Lens ((&), (.~), (^.))
4import Control.Lens ((&), (.~), (^.))
5import Test.Hspec
6import Test.Hspec
7+import Test.ShouldNotTypecheck
7spec :: Spec
9spec :: Spec
@@ -50,7 +52,7 @@ spec = do
50 Rec (#a := 1) `append` Rec (#b := 2)
52 Rec (#a := 1) `append` Rec (#b := 2)
51 `shouldBe` Rec (#a := 1, #b := 2)
53 `shouldBe` Rec (#a := 1, #b := 2)
52 it "append with duplicates" $ do
54 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
54 -- implementation, the last value (here, 8) will overwrite all duplicate
56 -- implementation, the last value (here, 8) will overwrite all duplicate
55 -- fields. See `union` if you want to deal with duplicates sensibly.
57 -- fields. See `union` if you want to deal with duplicates sensibly.
56 pendingWith "append should just append?"
58 pendingWith "append should just append?"
@@ -71,12 +73,8 @@ spec = do
71 it "simple insert" $ do
73 it "simple insert" $ do
72 (#a := 1) `insert` Rec (#b := 2, #c := 3)
74 (#a := 1) `insert` Rec (#b := 2, #c := 3)
73 `shouldBe` Rec (#a := 1, #b := 2, #c := 3)
75 `shouldBe` Rec (#a := 1, #b := 2, #c := 3)
74− -- TODO: type check should fail
76+ it "type-check fails if field already exists" $ do
75− -- it "insert of already existing field should fail" $ do
77+ shouldNotTypecheck ((#a := '1') `insert` Rec (#b := '2', #a := '0'))
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
80 describe "insertOrSet" $ do
78 describe "insertOrSet" $ do
81 it "distinct" $ do
79 it "distinct" $ do
82 insertOrSet (#a := 1) (Rec (#b := 2, #c := 3))
80 insertOrSet (#a := 1) (Rec (#b := 2, #c := 3))