hspec-core 2.11.12 → 2.11.13
raw patch · 12 files changed
+256/−240 lines, 12 filesdep ~hspec-meta
Dependency ranges changed: hspec-meta
Files
- hspec-core.cabal +4/−4
- src/Test/Hspec/Core/Formatters/Diff.hs +82/−31
- src/Test/Hspec/Core/Formatters/Internal.hs +7/−2
- src/Test/Hspec/Core/Formatters/Pretty.hs +25/−10
- src/Test/Hspec/Core/Formatters/V1/Internal.hs +1/−3
- src/Test/Hspec/Core/Formatters/V2.hs +44/−76
- test/Test/Hspec/Core/Formatters/DiffSpec.hs +39/−33
- test/Test/Hspec/Core/Formatters/Pretty/ParserSpec.hs +19/−3
- test/Test/Hspec/Core/Formatters/PrettySpec.hs +27/−11
- test/Test/Hspec/Core/Formatters/V2Spec.hs +0/−61
- test/Test/Hspec/Core/RunnerSpec.hs +7/−5
- version.yaml +1/−1
hspec-core.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.38.0.+-- This file has been generated from package.yaml by hpack version 0.38.1. -- -- see: https://github.com/sol/hpack name: hspec-core-version: 2.11.12+version: 2.11.13 license: MIT license-file: LICENSE copyright: (c) 2011-2025 Simon Hengel,@@ -36,7 +36,7 @@ ghc-options: -Wall -fno-warn-incomplete-uni-patterns build-depends: HUnit ==1.6.*- , QuickCheck >=2.13.1 && <2.16+ , QuickCheck >=2.13.1 && <2.17 , ansi-terminal >=0.6.2 , array , base >=4.9.0.0 && <5@@ -140,7 +140,7 @@ , filepath , haskell-lexer , hspec-expectations ==0.8.4.*- , hspec-meta ==2.11.12+ , hspec-meta ==2.11.13 , process , quickcheck-io >=0.2.0 , random
src/Test/Hspec/Core/Formatters/Diff.hs view
@@ -1,8 +1,15 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE LambdaCase #-} {-# LANGUAGE ViewPatterns #-} module Test.Hspec.Core.Formatters.Diff ( Diff (..) , diff++, LineDiff(..)+, lineDiff++, splitLines+ #ifdef TEST , partition , breakList@@ -15,73 +22,117 @@ import Data.Char import qualified Data.Algorithm.Diff as Diff -data Diff = First String | Second String | Both String | Omitted Int+data Diff = First String | Second String | Both String deriving (Eq, Show) --- |--- Split a string at line boundaries.------ >>> splitLines "foo\nbar\nbaz"--- ["foo\n","bar\n","baz"]------ prop> concat (splitLines xs) == xs+data LineDiff =+ LinesFirst [String]+ | LinesSecond [String]+ | LinesBoth [String]+ | SingleLineDiff [Diff]+ | LinesOmitted Int+ deriving (Eq, Show)++lineDiff :: Maybe Int -> String -> String -> [LineDiff]+lineDiff context expected actual = maybe id applyContext context $ singleLineDiffs diffs+ where+ diffs :: [LineDiff]+ diffs = Diff.getGroupedDiff expectedLines actualLines <&> \ case+ Diff.First xs -> LinesFirst xs+ Diff.Second xs -> LinesSecond xs+ Diff.Both xs _ -> LinesBoth xs++ expectedLines :: [String]+ expectedLines = splitLines expected++ actualLines :: [String]+ actualLines = splitLines actual++singleLineDiffs :: [LineDiff] -> [LineDiff]+singleLineDiffs = go+ where+ go = \ case+ [] -> []+ LinesFirst [first_] : LinesSecond [second_] : xs -> SingleLineDiff (diff first_ second_) : go xs+ x : xs -> x : go xs+ splitLines :: String -> [String] splitLines = go where+ go :: String -> [String] go xs = case break (== '\n') xs of- (ys, '\n' : zs) -> (ys ++ ['\n']) : go zs- ("", "") -> []+ (ys, '\n' : zs) -> ys : go zs _ -> [xs] -data TrimMode = FirstChunck | Chunck | LastChunck+data TrimMode = FirstChunk | Chunk | LastChunk -trim :: Int -> [Diff] -> [Diff]-trim context = \ chunks -> case chunks of+applyContext :: Int -> [LineDiff] -> [LineDiff]+applyContext context = \ diffs -> case diffs of [] -> []- x : xs -> trimChunk FirstChunck x (go xs)+ x : xs -> trimChunk FirstChunk x (go xs) where+ omitThreshold :: Int omitThreshold = 3 - go chunks = case chunks of+ go :: [LineDiff] -> [LineDiff]+ go diffs = case diffs of [] -> []- [x] -> trimChunk LastChunck x []- x : xs -> trimChunk Chunck x (go xs)+ [x] -> trimChunk LastChunk x []+ x : xs -> trimChunk Chunk x (go xs) + trimChunk :: TrimMode -> LineDiff -> [LineDiff] -> [LineDiff] trimChunk mode chunk = case chunk of- Both xs | omitted >= omitThreshold -> keep start . (Omitted omitted :) . keep end+ LinesBoth allLines | meetsThreshold -> keep start . (LinesOmitted omitted :) . keep end where+ meetsThreshold :: Bool+ meetsThreshold = omitThreshold <= omitted++ lastLineHasNL = case (mode, reverse allLines) of+ (LastChunk, "" : _) -> True+ _ -> False+ omitted :: Int omitted = n - keepStart - keepEnd keepStart :: Int keepStart = case mode of- FirstChunck -> 0- _ -> succ context+ FirstChunk -> 0+ _ -> context keepEnd :: Int keepEnd = case mode of- LastChunck -> 0- _ -> if xs `endsWith` "\n" then context else succ context+ LastChunk -> 0+ _ -> context n :: Int- n = length allLines-- allLines :: [String]- allLines = splitLines xs+ n = length allLines - case lastLineHasNL of+ False -> 0+ True -> 1 start :: [String] start = take keepStart allLines end :: [String] end = drop (keepStart + omitted) allLines+ _ -> (chunk :) - keep xs- | null xs = id- | otherwise = (Both (concat xs) :)+keep :: [String] -> [LineDiff] -> [LineDiff]+keep xs+ | null xs = id+ | otherwise = (LinesBoth xs :) -diff :: Maybe Int -> String -> String -> [Diff]-diff context expected actual = maybe id trim context $ map (toDiff . fmap concat) $ Diff.getGroupedDiff (partition expected) (partition actual)+diff :: String -> String -> [Diff]+diff expected actual = diffs+ where+ diffs :: [Diff]+ diffs = map (toDiff . fmap concat) $ Diff.getGroupedDiff expectedChunks actualChunks++ expectedChunks :: [String]+ expectedChunks = partition expected++ actualChunks :: [String]+ actualChunks = partition actual toDiff :: Diff.Diff String -> Diff toDiff d = case d of
src/Test/Hspec/Core/Formatters/Internal.hs view
@@ -371,9 +371,14 @@ missing = diffColorize Green "hspec-success" diffColorize :: Color -> String -> String-> FormatM ()-diffColorize color cls s = withColor (SetColor layer Dull color) cls $ do- write s+diffColorize color cls s = withColor (SetColor layer Dull color) cls $ case s of+ "" -> write eraseInLine+ _ -> write s where+ eraseInLine :: String+ eraseInLine = "\ESC[K"++ layer :: ConsoleLayer layer | all isSpace s = Background | otherwise = Foreground
src/Test/Hspec/Core/Formatters/Pretty.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} module Test.Hspec.Core.Formatters.Pretty ( pretty2@@ -90,18 +91,32 @@ fromString = Builder . showString renderValue :: Bool -> Value -> String-renderValue unicode = runBuilder . render+renderValue unicode = runBuilder . render 0 where- render :: Value -> Builder- render value = case value of+ render :: Int -> Value -> Builder+ render indentation = \ case Char c -> shows c String str -> if unicode then Builder $ ushows str else shows str- Rational n d -> render n <> " % " <> render d+ Rational n d -> render indentation n <> " % " <> render indentation d Number n -> fromString n- Record name fields -> fromString name <> " {\n " <> (intercalate ",\n " $ map renderField fields) <> "\n}"- Constructor name values -> intercalate " " (fromString name : map render values)- Tuple [e@Record{}] -> render e- Tuple xs -> "(" <> intercalate ", " (map render xs) <> ")"- List xs -> "[" <> intercalate ", " (map render xs) <> "]"+ Record name fields -> fromString name <> renderFields fields+ Constructor name values -> intercalate " " (fromString name : map (render indentation) values)+ Tuple [e@Record{}] -> render indentation e+ Tuple xs -> "(" <> intercalate ", " (map (render indentation) xs) <> ")"+ List xs -> "[" <> intercalate ", " (map (render indentation) xs) <> "]"+ where+ spaces :: Builder+ spaces = indentBy (succ indentation) - renderField (name, value) = fromString name <> " = " <> render value+ renderFields :: [(String, Value)] -> Builder+ renderFields fields = mconcat [+ " {\n" <> spaces+ , intercalate (",\n" <> spaces) $ map renderField fields+ , "\n" <> indentBy indentation <> "}"+ ]++ renderField :: (String, Value) -> Builder+ renderField (name, value) = fromString name <> " = " <> render (succ indentation) value++ indentBy :: Int -> Builder+ indentBy n = fromString $ replicate (2 * n) ' '
src/Test/Hspec/Core/Formatters/V1/Internal.hs view
@@ -296,7 +296,7 @@ let threshold = 2 :: Seconds mchunks <- liftIO $ if b- then timeout threshold (evaluate $ diff Nothing expected actual)+ then timeout threshold (evaluate $ diff expected actual) else return Nothing case mchunks of@@ -315,7 +315,6 @@ Both a -> indented write a First a -> indented extra a Second _ -> pass- Omitted _ -> pass writeLine "" withFailColor $ write (indentation ++ " but got: ")@@ -323,7 +322,6 @@ Both a -> indented write a First _ -> pass Second a -> indented missing a- Omitted _ -> pass writeLine "" Error _ e -> withFailColor . indent $ (("uncaught exception: " ++) . formatException) e
src/Test/Hspec/Core/Formatters/V2.hs view
@@ -86,7 +86,6 @@ #ifdef TEST , Chunk(..) , ColorChunk(..)-, indentChunks #endif ) where @@ -94,7 +93,6 @@ import Test.Hspec.Core.Compat hiding (First) import System.IO (hFlush, stdout) -import Data.Char import Test.Hspec.Core.Util hiding (formatException) import qualified Test.Hspec.Core.Util as Util import Test.Hspec.Core.Clock@@ -323,15 +321,16 @@ Nothing -> do context <- diffContext mchunks <- liftIO $ if b- then timeout threshold (evaluate $ diff context expected actual)+ then timeout threshold (evaluate $ lineDiff context expected actual) else return Nothing case mchunks of Just chunks -> do writeDiff chunks extraChunk missingChunk Nothing -> do- writeDiff [First expected, Second actual] write write+ writeDiff [LinesFirst (splitLines expected), LinesSecond (splitLines actual)] write write where+ writeDiff :: [LineDiff] -> (String -> FormatM ()) -> (String -> FormatM ()) -> FormatM () writeDiff chunks extra missing = do writeChunks "expected: " (expectedChunks chunks) extra writeChunks " but got: " (actualChunks chunks) missing@@ -339,14 +338,26 @@ writeChunks :: String -> [Chunk] -> (String -> FormatM ()) -> FormatM () writeChunks pre chunks colorize = do withFailColor $ write (indentation ++ pre)- forM_ (indentChunks indentation_ chunks) $ \ case- PlainChunk a -> write a- ColorChunk a -> colorize a- Informational a -> withInfoColor $ write a- writeLine ""+ go pass chunks where+ indentation_ :: [Char] indentation_ = indentation ++ replicate (length pre) ' ' + go :: FormatM () -> [Chunk] -> FormatM ()+ go indent_ = \ case+ [] -> pass+ c : cs -> do+ indent_+ case c of+ Original a -> write a+ Modified a -> colorize a+ Info text -> withInfoColor $ write text+ ModifiedChunks xs -> for_ xs $ \ case+ PlainChunk a -> write a+ ColorChunk a -> colorize a+ write "\n"+ go (write indentation_) cs+ Error info e -> do mapM_ indent info formatException <- getConfigValue formatConfigFormatException@@ -367,79 +378,36 @@ forM_ (lines message) $ \ line -> do writeLine (indentation ++ line) -data Chunk = Original String | Modified String | OmittedLines Int+data Chunk = Original String | Modified String | Info String | ModifiedChunks [ColorChunk] deriving (Eq, Show) -expectedChunks :: [Diff] -> [Chunk]-expectedChunks = mapMaybe $ \ case- Both a -> Just $ Original a- First a -> Just $ Modified a- Second _ -> Nothing- Omitted n -> Just $ OmittedLines n+expectedChunks :: [LineDiff] -> [Chunk]+expectedChunks = concatMap $ \ case+ LinesBoth a -> map Original a+ LinesFirst a -> map Modified a+ LinesSecond _ -> []+ LinesOmitted n -> [Info $ formatOmittedLines n]+ SingleLineDiff diffs -> return . ModifiedChunks . flip mapMaybe diffs $ \ case+ First a -> Just $ ColorChunk a+ Second _ -> Nothing+ Both a -> Just $ PlainChunk a -actualChunks :: [Diff] -> [Chunk]-actualChunks = mapMaybe $ \ case- Both a -> Just $ Original a- First _ -> Nothing- Second a -> Just $ Modified a- Omitted n -> Just $ OmittedLines n+actualChunks :: [LineDiff] -> [Chunk]+actualChunks = concatMap $ \ case+ LinesBoth a -> map Original a+ LinesFirst _ -> []+ LinesSecond a -> map Modified a+ LinesOmitted n -> [Info $ formatOmittedLines n]+ SingleLineDiff diffs -> return . ModifiedChunks . flip mapMaybe diffs $ \ case+ First _ -> Nothing+ Second a -> Just $ ColorChunk a+ Both a -> Just $ PlainChunk a -data ColorChunk = PlainChunk String | ColorChunk String | Informational String+data ColorChunk = PlainChunk String | ColorChunk String deriving (Eq, Show) -data StartsWith = StartsWithNewline | StartsWithNonNewline- deriving Eq--indentChunks :: String -> [Chunk] -> [ColorChunk]-indentChunks indentation = go- where- go :: [Chunk] -> [ColorChunk]- go = \ case- Original x : xs -> indentOriginal indentation x : go xs- Modified x : xs -> indentModified (startsWith xs) indentation x ++ go xs- OmittedLines n : xs -> Informational (formatOmittedLines n) : go xs- [] -> []-- startsWith :: [Chunk] -> StartsWith- startsWith xs- | all isSpace (takeWhile (/= '\n') $ unChunks xs) = StartsWithNewline- | otherwise = StartsWithNonNewline-- unChunks :: [Chunk] -> String- unChunks = \ case- Original x : xs -> x ++ unChunks xs- Modified x : xs -> x ++ unChunks xs- OmittedLines {} : _ -> ""- [] -> ""-- formatOmittedLines :: Int -> String- formatOmittedLines n = "@@ " <> show n <> " lines omitted @@\n" <> indentation--indentOriginal :: String -> String -> ColorChunk-indentOriginal indentation = PlainChunk . go- where- go text = case break (== '\n') text of- (xs, _ : ys) -> xs ++ "\n" ++ indentation ++ go ys- (xs, "") -> xs--indentModified :: StartsWith -> String -> String -> [ColorChunk]-indentModified nextChunk indentation = go- where- go :: String -> [ColorChunk]- go = \ case- "" -> []- "\n" -> [PlainChunk "\n", ColorChunk indentation]- '\n' : ys@('\n' : _) -> PlainChunk "\n" : ColorChunk indentation : go ys- '\n' : xs -> PlainChunk ('\n' : indentation) : go xs- text -> case break (== '\n') text of- (xs, "") | nextChunk == StartsWithNonNewline -> [ColorChunk xs]- (xs, ys) -> segment xs ++ go ys-- segment :: String -> [ColorChunk]- segment xs = case span isSpace $ reverse xs of- ("", _) -> [ColorChunk xs]- (_, "") -> [ColorChunk xs]- (ys, zs) -> [ColorChunk (reverse zs), ColorChunk (reverse ys)]+formatOmittedLines :: Int -> String+formatOmittedLines n = "@@ " <> show n <> " lines omitted @@" defaultFooter :: FormatM () defaultFooter = do
test/Test/Hspec/Core/Formatters/DiffSpec.hs view
@@ -12,10 +12,10 @@ spec :: Spec spec = do- describe "diff" $ do+ describe "lineDiff" $ do let enumerate name n = map ((name ++) . show) [1 .. n :: Int]- diff_ expected actual = diff (Just 2) (unlines expected) (unlines actual)+ diff_ expected actual = lineDiff (Just 2) (unlines expected) (unlines actual) it "suppresses excessive diff output" $ do let@@ -23,19 +23,18 @@ actual = replace "foo50" "bar50" expected diff_ expected actual `shouldBe` [- Omitted 47- , Both $ unlines [+ LinesOmitted 47+ , LinesBoth [ "foo48" , "foo49" ]- , First "foo50"- , Second "bar50"- , Both $ unlines [- ""- , "foo51"+ , SingleLineDiff [First "foo50", Second "bar50"]+ , LinesBoth [+ "foo51" , "foo52" ]- , Omitted 47+ , LinesOmitted 47+ , LinesBoth [""] ] it "ensures that omitted sections are at least three lines in size" $ do@@ -43,7 +42,7 @@ let expected = enumerate "" size forAll (elements expected) $ \ i -> do let actual = replace i "bar" expected- [n | Omitted n <- diff_ expected actual] `shouldSatisfy` all (>= 3)+ [n | LinesOmitted n <- diff_ expected actual] `shouldSatisfy` all (>= 3) context "with modifications within a line" $ do it "suppresses excessive diff output" $ do@@ -52,20 +51,18 @@ actual = replace "foo 42" "foo 23" expected diff_ expected actual `shouldBe` [- Omitted 39- , Both $ concat [- "foo 40\n"- , "foo 41\n"- , "foo "+ LinesOmitted 39+ , LinesBoth [+ "foo 40"+ , "foo 41" ]- , First "42"- , Second "23"- , Both $ concat [- "\n"- , "foo 43\n"- , "foo 44\n"+ , SingleLineDiff [Both "foo ", First "42", Second "23"]+ , LinesBoth [+ "foo 43"+ , "foo 44" ]- , Omitted 55+ , LinesOmitted 55+ , LinesBoth [""] ] context "with modifications at start / end" $ do@@ -75,22 +72,31 @@ actual = replace "foo9" "bar9" $ replace "foo1" "bar1" expected diff_ expected actual `shouldBe` [- First "foo1"- , Second "bar1"- , Both $ unlines [- ""- , "foo2"+ SingleLineDiff [First "foo1", Second "bar1"]+ , LinesBoth [+ "foo2" , "foo3" ]- , Omitted 3- , Both $ unlines [+ , LinesOmitted 3+ , LinesBoth [ "foo7" , "foo8" ]- , First "foo9"- , Second "bar9"- , Both "\n"+ , SingleLineDiff [First "foo9", Second "bar9"]+ , LinesBoth [""] ]++ describe "splitLines" $ do+ it "splits on newline characters" $ do+ splitLines "foo\nbar\nbaz" `shouldBe` ["foo", "bar", "baz"]++ describe "with a newline characters at the start" $ do+ it "splits on newline characters" $ do+ splitLines "\nfoo\nbar\nbaz" `shouldBe` ["", "foo", "bar", "baz"]++ describe "with a newline characters at the end" $ do+ it "splits on newline characters" $ do+ splitLines "foo\nbar\nbaz\n" `shouldBe` ["foo", "bar", "baz", ""] describe "partition" $ do context "with a single shown Char" $ do
test/Test/Hspec/Core/Formatters/Pretty/ParserSpec.hs view
@@ -1,6 +1,11 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ConstraintKinds #-}-module Test.Hspec.Core.Formatters.Pretty.ParserSpec (spec, Person(..)) where+module Test.Hspec.Core.Formatters.Pretty.ParserSpec (+ spec+, Person(..)+, Address(..)+, person+) where import Prelude () import Helper@@ -10,8 +15,17 @@ data Person = Person { personName :: String , personAge :: Int+, personAddress :: Maybe Address } deriving (Eq, Show) +data Address = Address {+ addressStreet :: String+, addressPostalCode :: Int+} deriving (Eq, Show)++person :: Person+person = Person "Joe" 23 (Just $ Address "Main Street" 50000)+ infix 1 `shouldParseAs` shouldParseAs :: HasCallStack => String -> Value -> Expectation@@ -69,9 +83,11 @@ show (Just $ Just "foo") `shouldParseAs` Constructor "Just" [parentheses (Constructor "Just" [String "foo"])] it "parses records" $ do- let person = Person "Joe" 23- show person `shouldParseAs` Record "Person" [ ("personName", String "Joe") , ("personAge", Number "23")+ , ("personAddress", Constructor "Just" [Tuple [Record "Address" [+ ("addressStreet", String "Main Street")+ , ("addressPostalCode", Number "50000")+ ]]]) ]
test/Test/Hspec/Core/Formatters/PrettySpec.hs view
@@ -3,7 +3,7 @@ import Prelude () import Helper -import Test.Hspec.Core.Formatters.Pretty.ParserSpec (Person(..))+import Test.Hspec.Core.Formatters.Pretty.ParserSpec hiding (spec) import Test.Hspec.Core.Formatters.Pretty @@ -68,13 +68,15 @@ recoverMultiLineString False (show "foo\n\955\nbaz\n") `shouldBe` Nothing describe "pretty" $ do- let person = Person "Joe" 23- it "pretty-prints records" $ do pretty True (show person) `shouldBe` just [ "Person {" , " personName = \"Joe\","- , " personAge = 23"+ , " personAge = 23,"+ , " personAddress = Just Address {"+ , " addressStreet = \"Main Street\","+ , " addressPostalCode = 50000"+ , " }" , "}" ] @@ -82,7 +84,11 @@ pretty True (show $ Just person) `shouldBe` just [ "Just Person {" , " personName = \"Joe\","- , " personAge = 23"+ , " personAge = 23,"+ , " personAddress = Just Address {"+ , " addressStreet = \"Main Street\","+ , " addressPostalCode = 50000"+ , " }" , "}" ] @@ -90,7 +96,11 @@ pretty True (show (person, -0.5 :: Rational)) `shouldBe` just [ "(Person {" , " personName = \"Joe\","- , " personAge = 23"+ , " personAge = 23,"+ , " personAddress = Just Address {"+ , " addressStreet = \"Main Street\","+ , " addressPostalCode = 50000"+ , " }" , "}, (-1) % 2)" ] @@ -98,16 +108,21 @@ pretty True (show [Just person, Nothing]) `shouldBe` just [ "[Just Person {" , " personName = \"Joe\","- , " personAge = 23"+ , " personAge = 23,"+ , " personAddress = Just Address {"+ , " addressStreet = \"Main Street\","+ , " addressPostalCode = 50000"+ , " }" , "}, Nothing]" ] context "with --unicode" $ do it "retains unicode characters in record fields" $ do- pretty True (show $ Person "λ-Joe" 23) `shouldBe` just [+ pretty True (show $ Person "λ-Joe" 23 Nothing) `shouldBe` just [ "Person {" , " personName = \"λ-Joe\","- , " personAge = 23"+ , " personAge = 23,"+ , " personAddress = Nothing" , "}" ] @@ -116,10 +131,11 @@ context "with --no-unicode" $ do it "does not retain unicode characters in record fields" $ do- pretty False (show $ Person "λ-Joe" 23) `shouldBe` just [+ pretty False (show $ Person "λ-Joe" 23 Nothing) `shouldBe` just [ "Person {" , " personName = \"\\955-Joe\","- , " personAge = 23"+ , " personAge = 23,"+ , " personAddress = Nothing" , "}" ]
test/Test/Hspec/Core/Formatters/V2Spec.hs view
@@ -36,67 +36,6 @@ spec :: Spec spec = do- describe "indentChunks" $ do- context "with Original" $ do- it "does not indent single-line input" $ do- indentChunks " " [Original "foo"] `shouldBe` [PlainChunk "foo"]-- it "indents multi-line input" $ do- indentChunks " " [Original "foo\nbar\nbaz\n"] `shouldBe` [PlainChunk "foo\n bar\n baz\n "]-- context "with Modified" $ do- it "returns the empty list on empty input" $ do- indentChunks " " [Modified ""] `shouldBe` []-- it "does not indent single-line input" $ do- indentChunks " " [Modified "foo"] `shouldBe` [ColorChunk "foo"]-- it "indents multi-line input" $ do- indentChunks " " [Modified "foo\nbar\nbaz\n"] `shouldBe` [ColorChunk "foo", PlainChunk "\n ", ColorChunk "bar", PlainChunk "\n ", ColorChunk "baz", PlainChunk "\n", ColorChunk " "]-- it "colorizes whitespace-only input" $ do- indentChunks " " [Modified " "] `shouldBe` [ColorChunk " "]-- it "colorizes whitespace-only lines" $ do- indentChunks " " [Modified "foo\n \n"] `shouldBe` [ColorChunk "foo", PlainChunk "\n ", ColorChunk " ", PlainChunk "\n", ColorChunk " "]-- it "colorizes whitespace at the end of the input" $ do- indentChunks " " [Modified "foo\n "] `shouldBe` [ColorChunk "foo", PlainChunk "\n ", ColorChunk " "]-- it "splits off whitespace-only segments at the end of a line so that they get colorized" $ do- indentChunks " " [Modified "foo \n"] `shouldBe` [ColorChunk "foo", ColorChunk " ", PlainChunk "\n", ColorChunk " "]-- it "splits off whitespace-only segments at the end of the input so that they get colorized" $ do- indentChunks " " [Modified "23 "] `shouldBe` [ColorChunk "23", ColorChunk " "]-- context "when next chunk starts with a newline" $ do- it "splits off whitespace-only segments at the end of a chunk so that they get colorized" $ do- indentChunks " " [Modified "23 ", Original "\nbar"] `shouldBe` [ColorChunk "23", ColorChunk " ", PlainChunk "\n bar"]-- context "when next chunk starts with spaces followed by a newline" $ do- it "splits off whitespace-only segments at the end of a chunk so that they get colorized" $ do- indentChunks " " [Modified "23 ", Original " \nbar"] `shouldBe` [ColorChunk "23", ColorChunk " ", PlainChunk " \n bar"]-- context "when all following chunks only consist of whitespace characters" $ do- it "splits off whitespace-only segments at the end of a chunk so that they get colorized" $ do- indentChunks " " [Modified "23 ", Original " ", Original " "] `shouldBe` [ColorChunk "23", ColorChunk " ", PlainChunk " ", PlainChunk " "]-- context "when all following chunks only consist of whitespace characters until the next newline is encountered" $ do- it "splits off whitespace-only segments at the end of a chunk so that they get colorized" $ do- indentChunks " " [Modified "23 ", Original " ", Modified " ", Original "\n"] `shouldBe` [ColorChunk "23", ColorChunk " ", PlainChunk " ", ColorChunk " ", PlainChunk "\n "]-- context "when next chunk starts with a non-whitespace character" $ do- it "does not split off whitespace-only segments at the end of a chunk" $ do- indentChunks " " [Modified "23 ", Original "bar"] `shouldBe` [ColorChunk "23 ", PlainChunk "bar"]-- context "when all following chunks only consist of non-newline characters until the next non-whitespace character is encountered" $ do- it "does not split off whitespace-only segments at the end of a chunk" $ do- indentChunks " " [Modified "23 ", Original " ", Original " bar"] `shouldBe` [ColorChunk "23 ", PlainChunk " ", PlainChunk " bar"]-- context "with empty lines" $ do- it "colorizes indentation" $ do- indentChunks " " [Original "foo", Modified "\n\n", Original "bar"] `shouldBe` [PlainChunk "foo", PlainChunk "\n", ColorChunk " ", PlainChunk "\n", ColorChunk " ", PlainChunk "bar"]- describe "progress" $ do let item = ItemDone ([], "") . Item Nothing 0 "" describe "formatterItemDone" $ do
test/Test/Hspec/Core/RunnerSpec.hs view
@@ -37,7 +37,7 @@ property (/= (23 :: Int)) person :: Int -> Person-person = Person "Joe"+person age = Person "Joe" age Nothing data MyException = MyException deriving (Eq, Show)@@ -529,11 +529,13 @@ , " 1) foo" , " expected: Person {" , " personName = \"Joe\","- , " personAge = 42"+ , " personAge = 42,"+ , " personAddress = Nothing" , " }" , " but got: Person {" , " personName = \"Joe\","- , " personAge = 23"+ , " personAge = 23,"+ , " personAddress = Nothing" , " }" , "" , " To rerun use: --match \"/foo/\" --seed 0"@@ -563,8 +565,8 @@ H.it "foo" $ do person 23 `H.shouldBe` person 42 r `shouldContain` unlines [- " expected: Person {personName = \"Joe\", personAge = 42}"- , " but got: Person {personName = \"Joe\", personAge = 23}"+ " expected: Person {personName = \"Joe\", personAge = 42, personAddress = Nothing}"+ , " but got: Person {personName = \"Joe\", personAge = 23, personAddress = Nothing}" ] context "when formatting exceptions" $ do
version.yaml view
@@ -1,4 +1,4 @@-version: &version 2.11.12+version: &version 2.11.13 synopsis: A Testing Framework for Haskell author: Simon Hengel <sol@typeful.net> maintainer: Simon Hengel <sol@typeful.net>