on master help sign in
Add eq test
fc0c447Sridhar Ratnakumar
test/JRecSpec.hs+10
@@ -9,6 +9,12 @@ spec = do
9 it "polymorphic" $ do
9 it "polymorphic" $ do
10 (Rec (#u := True, #a := 5, #b := 6, #a := 2 ) & #u .~ 5)
10 (Rec (#u := True, #a := 5, #b := 6, #a := 2 ) & #u .~ 5)
11 `shouldBe` Rec (#u := 5, #a := 5, #b := 6, #a := 2)
11 `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)
12 it "show" $ do
18 it "show" $ do
13 show (Rec ()) `shouldBe` "{}"
19 show (Rec ()) `shouldBe` "{}"
14 show (Rec (#foo := True)) `shouldBe` "{foo = True}"
20 show (Rec (#foo := True)) `shouldBe` "{foo = True}"
@@ -62,6 +68,10 @@ spec = do
62 it "simple insert" $ do
68 it "simple insert" $ do
63 (#a := 1) `insert` Rec (#b := 2, #c := 3)
69 (#a := 1) `insert` Rec (#b := 2, #c := 3)
64 `shouldBe` Rec (#a := 1, #b := 2, #c := 3)
70 `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)
65 it "duplicate insert should be disallowed" $ do
75 it "duplicate insert should be disallowed" $ do
66 pendingWith "TODO"
76 pendingWith "TODO"
67-- describe "insertOrSet" $ do
77-- describe "insertOrSet" $ do