on master help sign in
Add union tests, noting what doesn't work
747dfb5Sridhar Ratnakumar
src/JRec.hs+5
@@ -39,6 +39,11 @@ unField _ (_ R.:= value) = value
39-- Other operations
39-- Other operations
40----------------------------------------------------------------------------
40----------------------------------------------------------------------------
41
41
42+-- Append records
43+--
44+-- Left-biased. Does not sort.
45+--
46+-- FIXME: This doesn't remove duplicates?
42union ::
47union ::
43 forall lhs rhs res.
48 forall lhs rhs res.
44 ( KnownNat (R.RecSize lhs),
49 ( KnownNat (R.RecSize lhs),
test/JRecSpec.hs+10
@@ -39,3 +39,13 @@ spec = do
39 `shouldBe` (Rec (#u := True, #a := 8))
39 `shouldBe` (Rec (#u := True, #a := 8))
40 setA2 (Rec (#u := True, #a := 5, #b := 6))
40 setA2 (Rec (#u := True, #a := 5, #b := 6))
41 `shouldBe` (Rec (#u := True, #a := 8, #b := 6))
41 `shouldBe` (Rec (#u := True, #a := 8, #b := 6))
42+ describe "union" $ do
43+ it "simple union" $ do
44+ Rec (#a := 1) `union` Rec (#b := 2)
45+ `shouldBe` Rec (#a := 1, #b := 2)
46+ it "union with duplicates (not implemented)" $ do
47+ -- TODO: Actually remove duplicates
48+ let r1 = Rec (#b := 5, #a := 6)
49+ r2 = Rec (#c := 7, #a := 8)
50+ r1 `union` r2
51+ `shouldBe` Rec (#b := 5, #a := 8, #c := 7, #a := 8)