2015-12-15 01:42:57 +03:00
|
|
|
module OrderedMapSpec where
|
|
|
|
|
2015-12-15 01:57:24 +03:00
|
|
|
import OrderedMap as Map
|
2015-12-15 01:44:42 +03:00
|
|
|
import Test.Hspec
|
2015-12-15 01:42:57 +03:00
|
|
|
|
2015-12-15 01:48:59 +03:00
|
|
|
spec :: Spec
|
|
|
|
spec = do
|
2015-12-15 01:47:42 +03:00
|
|
|
describe "difference" $ do
|
|
|
|
it "should return those elements of a not in b" $
|
2015-12-15 01:51:15 +03:00
|
|
|
Map.difference a b `shouldBe` (Map.fromList [ ("a", 1) ])
|
|
|
|
|
2015-12-15 02:11:42 +03:00
|
|
|
it "is asymmetrical" $ do
|
|
|
|
Map.difference a b `shouldNotBe` Map.difference b a
|
|
|
|
|
2015-12-15 01:53:05 +03:00
|
|
|
describe "union" $ do
|
|
|
|
it "should return those elements in either a or b" $
|
|
|
|
Map.union a b `shouldBe` (Map.fromList $ ("a", 1) : Map.toList b)
|
|
|
|
|
2015-12-15 01:54:22 +03:00
|
|
|
describe "intersectionWith" $ do
|
|
|
|
it "should return those elements in both a and b, combined with a function" $
|
|
|
|
Map.intersectionWith (+) a b `shouldBe` (Map.fromList [ ("b", 4), ("c", 6) ])
|
|
|
|
|
2015-12-15 02:10:20 +03:00
|
|
|
describe "keys" $ do
|
|
|
|
it "should return all the keys in a map" $
|
|
|
|
Map.keys a `shouldBe` [ "a", "b", "c" ]
|
|
|
|
|
2015-12-15 01:51:15 +03:00
|
|
|
where a = Map.fromList [ ("a", 1), ("b", 2), ("c", 3) ]
|
|
|
|
b = Map.fromList [ ("b", 2), ("c", 3), ("d", 4) ]
|