1module Test.TypeRep.CMap
5import Prelude hiding (lookup)
7import Data.Functor.Identity (Identity (..))
8import Test.Hspec (Spec, describe, it, shouldBe)
10import Data.TypeRep.CMap (TypeRepMap, empty, insert, lookup, size)
13-- | Simple test for 'lookup', 'insert' and 'size' functions.
15cMapSpec = describe "Containers Map TypeRep" $ do
16 describe "Lookup Test" $ do
17 it "returns the inserted element" $
18 lookup (insert (Identity 'a') empty) `shouldBe` Just (Identity 'a')
19 it "returns the second inserted value of the same type" $
20 lookup (insert (Identity 'b') $ insert (Identity 'a') empty) `shouldBe` Just (Identity 'b')
22 describe "Size Test" $ do
24 size empty `shouldBe` 0
25 it "is of size 1 when 1 element inserted" $
26 size (insert (Identity 'a') empty) `shouldBe` 1
27 it "doesn't increase size when element of the same type is added" $
28 size (insert (Identity 'b') $ insert (Identity 'a') empty) `shouldBe` 1
29 it "returns 10 when 10 different types are inserted" $
30 size mapOf10 `shouldBe` 10
33mapOf10 :: TypeRepMap Identity
34mapOf10 = insert (Identity True)
35 $ insert (Identity [True, False])
36 $ insert (Identity $ Just True)
37 $ insert (Identity $ Just ())
38 $ insert (Identity [()])
39 $ insert (Identity ())
40 $ insert (Identity @String "aaa")
41 $ insert (Identity $ Just 'a')
42 $ insert (Identity 'a')
43 $ insert (Identity (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