File: TypesSpec.hs

package info (click to toggle)
haskell-hspec-smallcheck 0.5.3-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80 kB
  • sloc: haskell: 198; makefile: 3
file content (41 lines) | stat: -rw-r--r-- 1,229 bytes parent folder | download | duplicates (5)
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
30
31
32
33
34
35
36
37
38
39
40
41
module Test.Hspec.SmallCheck.TypesSpec (spec) where

import           Test.Hspec

import           Test.Hspec.SmallCheck.Types

spec :: Spec
spec = do
  describe "parseResult" $ do
    let r = Failure Nothing (ExpectedActual "" "23" "42")
    it "parses result" $ do
      parseResult (show r) `shouldBe` ("", Just r)

    context "with prefix" $ do
      it "includes prefix" $ do
        let
          prefix = "some prefix"
          input = prefix ++ show r
        parseResult input `shouldBe` (prefix, Just r)

    context "on parse error" $ do
      it "returns input verbatim" $ do
        let input = init (show r)
        parseResult input `shouldBe` (input, Nothing)

  describe "concatPrefix" $ do
    context "when given two empty strings" $ do
      it "returns Nothing" $ do
        concatPrefix "" "" `shouldBe` Nothing

    context "with first string empty" $ do
      it "returns second" $ do
        concatPrefix "foo" "" `shouldBe` Just "foo"

    context "with second string empty" $ do
      it "returns first" $ do
        concatPrefix "" "foo" `shouldBe` Just "foo"

    context "with two strings" $ do
      it "concatenates with newline" $ do
        concatPrefix "foo" "bar" `shouldBe` Just "foo\nbar"