-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A Testing Framework for Haskell -- -- This package exposes internal types and functions that can be used to -- extend Hspec's functionality. @package hspec-core @version 2.2.2 module Test.Hspec.Core.Util -- | pluralize count singular pluralizes the given -- singular word unless given count is 1. -- -- Examples: -- --
-- >>> pluralize 0 "example" -- "0 examples" ---- --
-- >>> pluralize 1 "example" -- "1 example" ---- --
-- >>> pluralize 2 "example" -- "2 examples" --pluralize :: Int -> String -> String -- | Strip leading and trailing whitespace strip :: String -> String -- | ensure that lines are not longer then given n, insert line -- breaks at word boundaries lineBreaksAt :: Int -> String -> [String] -- | A Path represents the location of an example within the spec -- tree. -- -- It consists of a list of group descriptions and a requirement -- description. type Path = ([String], String) -- | Try to create a proper English sentence from a path by applying some -- heuristics. formatRequirement :: Path -> String -- | A predicate that can be used to filter a spec tree. filterPredicate :: String -> Path -> Bool -- | safeTry evaluates given action and returns its result. If an -- exception occurs, the exception is returned instead. Unlike try -- it is agnostic to asynchronous exceptions. safeTry :: IO a -> IO (Either SomeException a) -- | The function formatException converts an exception to a string. -- -- This is different from show. The type of the exception is -- included, e.g.: -- --
-- >>> formatException (toException DivideByZero) -- "ArithException (divide by zero)" ---- -- For IOExceptions the IOErrorType is included, as well. formatException :: SomeException -> String -- | This module provides access to Hspec's internals. It is less stable -- than other parts of the API. For most users Test.Hspec is -- more suitable! module Test.Hspec.Core.Spec -- | The describe function combines a list of specs into a larger -- spec. describe :: String -> SpecWith a -> SpecWith a -- | The it function creates a spec item. -- -- A spec item consists of: -- --
-- describe "absolute" $ do -- it "returns a positive number when given a negative number" $ -- absolute (-1) == 1 --it :: (?loc :: CallStack, Example a) => String -> a -> SpecWith (Arg a) -- | pending can be used to indicate that an example is -- pending. -- -- If you want to textually specify a behavior but do not have an example -- yet, use this: -- --
-- describe "fancyFormatter" $ do -- it "can format text in a way that everyone likes" $ -- pending --pending :: Expectation -- | pendingWith is similar to pending, but it takes an -- additional string argument that can be used to specify the reason for -- why it's pending. pendingWith :: String -> Expectation -- | parallel marks all spec items of the given spec to be safe for -- parallel evaluation. parallel :: SpecWith a -> SpecWith a type Spec = SpecWith () type SpecWith a = SpecM a () -- | A writer monad for SpecTree forests newtype SpecM a r SpecM :: (WriterT [SpecTree a] IO r) -> SpecM a r -- | Convert a Spec to a forest of SpecTrees. runSpecM :: SpecWith a -> IO [SpecTree a] -- | Create a Spec from a forest of SpecTrees. fromSpecList :: [SpecTree a] -> SpecWith a -- | Run an IO action while constructing the spec tree. -- -- SpecM is a monad to construct a spec tree, without executing -- any spec items. runIO allows you to run IO actions during -- this construction phase. The IO action is always run when the spec -- tree is constructed (e.g. even when --dry-run is specified). -- If you do not need the result of the IO action to construct the spec -- tree, beforeAll may be more suitable for your use case. runIO :: IO r -> SpecM a r mapSpecTree :: (SpecTree a -> SpecTree b) -> SpecWith a -> SpecWith b mapSpecItem :: (ActionWith a -> ActionWith b) -> (Item a -> Item b) -> SpecWith a -> SpecWith b mapSpecItem_ :: (Item a -> Item a) -> SpecWith a -> SpecWith a modifyParams :: (Params -> Params) -> SpecWith a -> SpecWith a -- | A type class for examples class Example e where type family Arg e Arg e = () evaluateExample :: Example e => e -> Params -> (ActionWith (Arg e) -> IO ()) -> ProgressCallback -> IO Result data Params Params :: Args -> Int -> Params [paramsQuickCheckArgs] :: Params -> Args [paramsSmallCheckDepth] :: Params -> Int defaultParams :: Params -- | An IO action that expects an argument of type a type ActionWith a = a -> IO () type Progress = (Int, Int) type ProgressCallback = Progress -> IO () -- | The result of running an example data Result Success :: Result Pending :: (Maybe String) -> Result Fail :: (Maybe Location) -> String -> Result -- | Location is used to represent source locations. data Location Location :: FilePath -> Int -> Int -> LocationAccuracy -> Location [locationFile] :: Location -> FilePath [locationLine] :: Location -> Int [locationColumn] :: Location -> Int [locationAccuracy] :: Location -> LocationAccuracy -- | A marker for source locations data LocationAccuracy -- | The source location is accurate ExactLocation :: LocationAccuracy -- | The source location was determined on a best-effort basis and my be -- wrong or inaccurate BestEffort :: LocationAccuracy -- | A tree is used to represent a spec internally. The tree is parametrize -- over the type of cleanup actions and the type of the actual spec -- items. type SpecTree a = Tree (ActionWith a) (Item a) -- | Internal tree data structure data Tree c a Node :: String -> [Tree c a] -> Tree c a NodeWithCleanup :: c -> [Tree c a] -> Tree c a Leaf :: a -> Tree c a -- | Item is used to represent spec items internally. A spec item -- consists of: -- --
-- >>> formatException (toException DivideByZero) -- "ArithException (divide by zero)" ---- -- For IOExceptions the IOErrorType is included, as well. formatException :: SomeException -> String module Test.Hspec.Core.Runner -- | Run given spec and write a report to stdout. Exit with -- exitFailure if at least one spec item fails. hspec :: Spec -> IO () -- | Run given spec with custom options. This is similar to hspec, -- but more flexible. hspecWith :: Config -> Spec -> IO () -- | Run given spec and returns a summary of the test run. -- -- Note: hspecResult does not exit with exitFailure -- on failing spec items. If you need this, you have to check the -- Summary yourself and act accordingly. hspecResult :: Spec -> IO Summary -- | Run given spec with custom options and returns a summary of the test -- run. -- -- Note: hspecWithResult does not exit with -- exitFailure on failing spec items. If you need this, you have -- to check the Summary yourself and act accordingly. hspecWithResult :: Config -> Spec -> IO Summary -- | Summary of a test run. data Summary Summary :: Int -> Int -> Summary [summaryExamples] :: Summary -> Int [summaryFailures] :: Summary -> Int data Config Config :: Bool -> Bool -> Bool -> Bool -> Maybe (Path -> Bool) -> Maybe (Path -> Bool) -> Maybe Integer -> Maybe Int -> Maybe Int -> Maybe Int -> Int -> ColorMode -> Maybe Formatter -> Bool -> Either Handle FilePath -> Maybe Int -> Config [configDryRun] :: Config -> Bool [configPrintCpuTime] :: Config -> Bool [configFastFail] :: Config -> Bool -- | A predicate that is used to filter the spec before it is run. Only -- examples that satisfy the predicate are run. [configRerun] :: Config -> Bool [configFilterPredicate] :: Config -> Maybe (Path -> Bool) [configSkipPredicate] :: Config -> Maybe (Path -> Bool) [configQuickCheckSeed] :: Config -> Maybe Integer [configQuickCheckMaxSuccess] :: Config -> Maybe Int [configQuickCheckMaxDiscardRatio] :: Config -> Maybe Int [configQuickCheckMaxSize] :: Config -> Maybe Int [configSmallCheckDepth] :: Config -> Int [configColorMode] :: Config -> ColorMode [configFormatter] :: Config -> Maybe Formatter [configHtmlOutput] :: Config -> Bool [configOutputFile] :: Config -> Either Handle FilePath [configConcurrentJobs] :: Config -> Maybe Int data ColorMode ColorAuto :: ColorMode ColorNever :: ColorMode ColorAlways :: ColorMode -- | A Path represents the location of an example within the spec -- tree. -- -- It consists of a list of group descriptions and a requirement -- description. type Path = ([String], String) defaultConfig :: Config -- | Add a filter predicate to config. If there is already a filter -- predicate, then combine them with ||. configAddFilter :: (Path -> Bool) -> Config -> Config instance GHC.Show.Show Test.Hspec.Core.Runner.Summary instance GHC.Classes.Eq Test.Hspec.Core.Runner.Summary instance GHC.Base.Monoid Test.Hspec.Core.Runner.Summary module Test.Hspec.Core.QuickCheck -- | Use a modified maxSuccess for given spec. modifyMaxSuccess :: (Int -> Int) -> SpecWith a -> SpecWith a -- | Use a modified maxDiscardRatio for given spec. modifyMaxDiscardRatio :: (Int -> Int) -> SpecWith a -> SpecWith a -- | Use a modified maxSize for given spec. modifyMaxSize :: (Int -> Int) -> SpecWith a -> SpecWith a