1module Test.TypeRep.CacheMap where
3import Prelude hiding (lookup)
5import Data.Functor.Identity (Identity (..))
6import Test.Tasty.Hspec (Spec, describe, it, shouldBe)
8import Data.TypeRep.CacheMap (TF (..), TypeRepMap, empty, fromList, insert, lookup, size)
10-- Simple test for 'lookup', 'insert' and 'size' functions.
11spec_insertLookup :: Spec
13 describe "Lookup Test" $ do
14 it "returns the inserted element" $
15 lookup (fromList [TF $ Identity 'a']) `shouldBe` Just (Identity 'a')
16 it "returns the second inserted value of the same type" $
17 lookup (fromList [TF (Identity 'b'), TF (Identity 'a')]) `shouldBe` Just (Identity 'b')
19 describe "Size Test" $ do
21 size empty `shouldBe` 0
22 it "is of size 1 when 1 element inserted" $
23 size (insert (Identity 'a') empty) `shouldBe` 1
24 it "doesn't increase size when element of the same type is added" $
25 size (insert (Identity 'b') $ insert (Identity 'a') empty) `shouldBe` 1
26 it "returns 10 when 10 different types are inserted" $
27 size mapOf10 `shouldBe` 10
30mapOf10 :: TypeRepMap Identity
31mapOf10 = insert (Identity True)
32 $ insert (Identity [True, False])
33 $ insert (Identity $ Just True)
34 $ insert (Identity $ Just ())
35 $ insert (Identity [()])
36 $ insert (Identity ())
37 $ insert (Identity "aaa")
38 $ insert (Identity $ Just 'a')
39 $ insert (Identity 'a')
40 $ 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