on master help sign in
Add eq test
commitfc0c447b46e85ba1cb52699b0c27044b4cb0eee2 authorSridhar Ratnakumar <srid@srid.ca> dateFri 28 Aug 2020, 16:14 (6 years ago) parentc1cf9b7
1 file changed+10
test/JRecSpec.hs+10
test/JRecSpec.hs+10
@@ -9,6 +9,12 @@ spec = do
99 it "polymorphic" $ do
1010 (Rec (#u := True, #a := 5, #b := 6, #a := 2 ) & #u .~ 5)
1111 `shouldBe` Rec (#u := 5, #a := 5, #b := 6, #a := 2)
12+ describe "eq" $ do
13+ -- eq can compare only the first matching field, discarding the rest.
14+ it "fails if first matching field doesn't compare" $ do
15+ Rec (#a := 1, #a := 2) `shouldNotBe` Rec (#a := 0, #a := 2)
16+ it "succeeds if first matching field compares" $ do
17+ Rec (#a := 1, #a := 2) `shouldBe` Rec (#a := 1, #a := 0)
1218 it "show" $ do
1319 show (Rec ()) `shouldBe` "{}"
1420 show (Rec (#foo := True)) `shouldBe` "{foo = True}"
@@ -62,6 +68,10 @@ spec = do
6268 it "simple insert" $ do
6369 (#a := 1) `insert` Rec (#b := 2, #c := 3)
6470 `shouldBe` Rec (#a := 1, #b := 2, #c := 3)
71+ -- TODO: type check should fail
72+ -- it "insert of already existing field should fail" $ do
73+ -- (#a := 1) `insert` Rec (#b := 2, #a := 0, #c := 3)
74+ -- `shouldBe` Rec (#a := 1, #b := 2, #a := 0, #c := 3)
6575 it "duplicate insert should be disallowed" $ do
6676 pendingWith "TODO"
6777-- describe "insertOrSet" $ do