File: AnnotationsSpec.hs

package info (click to toggle)
haskell-hspec-core 2.11.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 700 kB
  • sloc: haskell: 9,452; makefile: 3
file content (29 lines) | stat: -rw-r--r-- 901 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Test.Hspec.Core.AnnotationsSpec (spec) where

import           Prelude ()
import           Helper

import           Test.Hspec.Core.Annotations

newtype A = A Int
  deriving (Eq, Show)

newtype B = B Int
  deriving (Eq, Show)

spec :: Spec
spec = do
  describe "Annotations" $ do
    it "can store a value" $ do
      let annotations = setValue (A 23) mempty
      getValue annotations `shouldBe` Just (A 23)

    it "can store multiple values of different types" $ do
      let annotations = setValue (B 42) $ setValue (A 23) mempty
      getValue annotations `shouldBe` Just (A 23)
      getValue annotations `shouldBe` Just (B 42)

    context "when a value of the same type is added multiple times" $ do
      it "gives precedence to the value that was added last" $ do
        let annotations = setValue (A 42) $  setValue (A 23) mempty
        getValue annotations `shouldBe` Just (A 42)