1module Test.TypeRep.TypeRepMap
5import Prelude hiding (lookup)
7import Data.Functor.Identity (Identity (..))
8import GHC.Exts (fromList)
9import Test.Hspec (Spec, describe, it, shouldBe)
11import Data.TMap (TMap, empty, insert, lookup, one, size, union)
12import Data.TypeRepMap.Internal (WrapTypeable (..))
15-- Simple test for 'lookup', 'insert' and 'size' functions.
17typeRepMapSpec = describe "TypeRepMap" $ do
18 describe "Lookup Test" $ do
19 it "returns the inserted element" $
20 lookup (fromList [WrapTypeable $ Identity 'a']) `shouldBe` Just 'a'
21 it "returns the second inserted value of the same type" $
22 lookup (fromList [WrapTypeable (Identity 'b'), WrapTypeable (Identity 'a')]) `shouldBe` Just 'b'
24 describe "Size Test" $ do
26 size empty `shouldBe` 0
27 it "is of size 1 when 1 element inserted" $
28 size (one 'a') `shouldBe` 1
29 it "doesn't increase size when element of the same type is added" $
30 size (insert 'b' $ insert 'a' empty) `shouldBe` 1
31 it "returns 10 when 10 different types are inserted" $
32 size mapOf10 `shouldBe` 10
34 describe "Union test" $ do
35 let m = fromList [WrapTypeable $ Identity 'a', WrapTypeable $ Identity True] `union`
36 fromList [WrapTypeable $ Identity 'b']
37 it "lookup works on union as expected" $ do
38 lookup m `shouldBe` Just 'a'
39 lookup m `shouldBe` Just True
40 lookup @Int m `shouldBe` Nothing
45 $ insert [True, False]
50 $ insert @String "aaa"
53 $ insert (11 :: Int) empty
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list