Blame test/Test/Hspec/Expectations/MatcherSpec.hs

Packit 6375e3
module Test.Hspec.Expectations.MatcherSpec (main, spec) where
Packit 6375e3
Packit 6375e3
import           Test.Hspec
Packit 6375e3
Packit 6375e3
import           Test.Hspec.Expectations.Matcher
Packit 6375e3
Packit 6375e3
main :: IO ()
Packit 6375e3
main = hspec spec
Packit 6375e3
Packit 6375e3
spec :: Spec
Packit 6375e3
spec = do
Packit 6375e3
  describe "matchList" $ do
Packit 6375e3
    it "succeeds if arguments are empty lists" $ do
Packit 6375e3
      matchList [] ([] :: [Int]) `shouldBe` Nothing
Packit 6375e3
Packit 6375e3
    it "succeeds if arguments are equal up to permutation" $ do
Packit 6375e3
      matchList [1, 2, 2, 3] [3, 2, 1, 2 :: Int] `shouldBe` Nothing
Packit 6375e3
Packit 6375e3
    context "when arguments are not equal up to permutation" $ do
Packit 6375e3
      it "shows extra elements" $ do
Packit 6375e3
        [1, 2, 2, 3] `matchList` [1, 2, 3 :: Int] `shouldBe` (Just . unlines) [
Packit 6375e3
            "Actual list is not a permutation of expected list!"
Packit 6375e3
          , "  expected list contains:   [1, 2, 3]"
Packit 6375e3
          , "  actual list contains:     [1, 2, 2, 3]"
Packit 6375e3
          , "  the extra elements are:   [2]"
Packit 6375e3
          ]
Packit 6375e3
Packit 6375e3
      it "shows missing elements" $ do
Packit 6375e3
        [1, 2, 3] `matchList` [1, 2, 2, 3 :: Int] `shouldBe` (Just . unlines) [
Packit 6375e3
            "Actual list is not a permutation of expected list!"
Packit 6375e3
          , "  expected list contains:   [1, 2, 2, 3]"
Packit 6375e3
          , "  actual list contains:     [1, 2, 3]"
Packit 6375e3
          , "  the missing elements are: [2]"
Packit 6375e3
          ]