diff --git a/tests/hspec/MapSpec.hs b/tests/hspec/MapSpec.hs index b1cabbe..ca13c94 100644 --- a/tests/hspec/MapSpec.hs +++ b/tests/hspec/MapSpec.hs @@ -15,9 +15,19 @@ myMap2 = ext (Var :: (Var "w")) (2::Int) $ ext (Var :: (Var "z")) (4::Int) empty spec :: Spec spec = do - describe "Map tests" $ - it "Map tests" $ do + describe "Map tests" $ do + it "foo map lookups" $ do (lookp (Var @"x") Example.foo) `shouldBe` (2 :: Int) (lookp (Var @"w") Example.foo) `shouldBe` (5 :: Int) (lookp (Var @"z") Example.foo) `shouldBe` True (mapLength Example.foo) `shouldBe` 3 + it "bar map lookups" $ do + (lookp (Var @"y") Example.bar) `shouldBe` (3 :: Int) + (lookp (Var @"w") Example.bar) `shouldBe` (1 :: Int) + (mapLength Example.bar) `shouldBe` 2 + it "foobar union combines values correctly" $ do + (lookp (Var @"w") Example.foobar) `shouldBe` (6 :: Int) -- 5 + 1 combined + (lookp (Var @"x") Example.foobar) `shouldBe` (2 :: Int) + (lookp (Var @"y") Example.foobar) `shouldBe` (3 :: Int) + (lookp (Var @"z") Example.foobar) `shouldBe` True + (mapLength Example.foobar) `shouldBe` 4 diff --git a/tests/hspec/SetSpec.hs b/tests/hspec/SetSpec.hs index fbf1626..f43b935 100644 --- a/tests/hspec/SetSpec.hs +++ b/tests/hspec/SetSpec.hs @@ -7,6 +7,7 @@ module SetSpec where import Test.Hspec import Data.Type.Set +import qualified ExampleSet import ExampleSet2 spec :: Spec @@ -20,3 +21,9 @@ spec = do barHasNat1 `shouldBe` False it "Union of large sets should run in reasonable time" $ do (r0_9 `union` r10_19) `shouldBe` (r0_9 `append` r10_19) + describe "Natural set example from README" $ do + it "foo, bar, and foobar unions compile successfully" $ do + -- These are mainly type-level tests - if they compile, they work + show ExampleSet.foo `shouldSatisfy` (not . null) + show ExampleSet.bar `shouldSatisfy` (not . null) + show ExampleSet.foobar `shouldSatisfy` (not . null)