-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Test interactive Haskell examples -- -- The doctest program checks examples in source code comments. It is -- modeled after doctest for Python -- (https://docs.python.org/3/library/doctest.html). -- -- Documentation is at -- https://github.com/martijnbastiaan/doctest-parallel#readme. @package doctest-parallel @version 0.2.2 module Language.Haskell.GhciWrapper data Interpreter data Config Config :: String -> Bool -> Bool -> Config [configGhci] :: Config -> String [configVerbose] :: Config -> Bool [configIgnoreDotGhci] :: Config -> Bool defaultConfig :: Config new :: Config -> [String] -> IO Interpreter close :: Interpreter -> IO () -- | Evaluate an expression eval :: Interpreter -> String -> IO String -- | Like eval, but try to preserve the it variable evalIt :: Interpreter -> String -> IO String -- | Evaluate an expression evalEcho :: Interpreter -> String -> IO String instance GHC.Show.Show Language.Haskell.GhciWrapper.Config instance GHC.Classes.Eq Language.Haskell.GhciWrapper.Config module Test.DocTest.Helpers -- | Efficient implementation of set like deletion on lists -- --
-- >>> "abcd" `rmList` "ad" -- "bc" -- -- >>> "aaabcccd" `rmList` "ad" -- "bccc" --rmList :: Ord a => [a] -> [a] -> [a] data Library Library :: [FilePath] -> [FilePath] -> [ModuleName] -> [Extension] -> Library -- | Haskell source directories [libSourceDirectories] :: Library -> [FilePath] -- | C source directories [libCSourceDirectories] :: Library -> [FilePath] -- | Exposed modules [libModules] :: Library -> [ModuleName] -- | Extensions enabled by default [libDefaultExtensions] :: Library -> [Extension] -- | Convert a Library to arguments suitable to be passed to GHCi. libraryToGhciArgs :: Library -> ([String], [String], [String]) -- | Drop a number of elements from the end of the list. -- --
-- dropEnd 3 "hello" == "he" -- dropEnd 5 "bye" == "" -- dropEnd (-1) "bye" == "bye" -- \i xs -> dropEnd i xs `isPrefixOf` xs -- \i xs -> length (dropEnd i xs) == max 0 (length xs - max 0 i) -- \i -> take 3 (dropEnd 5 [i..]) == take 3 [i..] --dropEnd :: Int -> [a] -> [a] findCabalPackage :: HasCallStack => String -> IO FilePath compatPrettyShow :: FilePath -> FilePath extractSpecificCabalLibrary :: Maybe String -> FilePath -> IO Library extractCabalLibrary :: FilePath -> IO Library instance GHC.Show.Show Test.DocTest.Helpers.Library module Test.DocTest.Internal.GhcUtil -- | Run a GHC action in Haddock mode withGhc :: [String] -> ([String] -> Ghc a) -> IO a module Test.DocTest.Internal.Interpreter data Interpreter -- | Evaluate an expression; return a Left value on exceptions. -- -- An exception may e.g. be caused on unterminated multiline expressions. safeEval :: Interpreter -> String -> IO (Either String String) safeEvalIt :: Interpreter -> String -> IO (Either String String) -- | Run an interpreter session. -- -- Example: -- --
-- >>> withInterpreter [] $ \i -> eval i "23 + 42" -- "65\n" --withInterpreter :: [String] -> (Interpreter -> IO a) -> IO a ghc :: FilePath interpreterSupported :: IO Bool ghcInfo :: IO [(String, String)] haveInterpreterKey :: String module Test.DocTest.Internal.Location -- | A thing with a location attached. data Located a Located :: Location -> a -> Located a -- | Convert a GHC located thing to a located thing. toLocated :: Located a -> Located a -- | Discard location information. unLoc :: Located a -> a -- | Add dummy location information. noLocation :: a -> Located a -- | A line number. type Line = Int -- | A combination of file name and line number. data Location UnhelpfulLocation :: String -> Location Location :: FilePath -> Line -> Location -- | Create a list from a location, by repeatedly increasing the line -- number by one. enumerate :: Location -> [Location] -- | Convert a GHC source span to a location. toLocation :: SrcSpan -> Location instance GHC.Classes.Eq Test.DocTest.Internal.Location.Location instance GHC.Base.Functor Test.DocTest.Internal.Location.Located instance GHC.Show.Show a => GHC.Show.Show (Test.DocTest.Internal.Location.Located a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.DocTest.Internal.Location.Located a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Test.DocTest.Internal.Location.Located a) instance GHC.Show.Show Test.DocTest.Internal.Location.Location instance Control.DeepSeq.NFData Test.DocTest.Internal.Location.Location module Test.DocTest.Internal.Options usage :: String version :: String ghcVersion :: String versionInfo :: String info :: String data Result a ResultStderr :: String -> Result a ResultStdout :: String -> Result a Result :: a -> Result a type Warning = String type ModuleName = String data Config Config :: Bool -> [ModuleName] -> Maybe Int -> Bool -> ModuleConfig -> Config -- | Verbose output (default: False) [cfgVerbose] :: Config -> Bool -- | Module names to test. An empty list means "test all modules". [cfgModules] :: Config -> [ModuleName] -- | Number of threads to use. Defaults to autodetection based on the -- number of cores. [cfgThreads] :: Config -> Maybe Int -- | Only print error messages, no status or progress messages (default: -- False) [cfgQuiet] :: Config -> Bool -- | Options specific to modules [cfgModuleConfig] :: Config -> ModuleConfig data ModuleConfig ModuleConfig :: Bool -> Bool -> Maybe Int -> Bool -> ModuleConfig -- | Preserve the it variable between examples (default: -- False) [cfgPreserveIt] :: ModuleConfig -> Bool -- | Randomize the order in which test cases in a module are run (default: -- False) [cfgRandomizeOrder] :: ModuleConfig -> Bool -- | Initialize random number generator used to randomize test cases when -- cfgRandomizeOrder is set. If set to Nothing, a random -- seed is picked from a system RNG source on startup. [cfgSeed] :: ModuleConfig -> Maybe Int -- | Import a module before testing it. Can be disabled to enabled to test -- non-exposed modules. [cfgImplicitModuleImport] :: ModuleConfig -> Bool defaultModuleConfig :: ModuleConfig defaultConfig :: Config parseLocatedModuleOptions :: ModuleName -> ModuleConfig -> [Located String] -> Either (Location, String) ModuleConfig parseModuleOption :: ModuleConfig -> String -> Maybe ModuleConfig parseOptions :: [String] -> Result Config -- | Parse seed argument -- --
-- >>> parseSeed "--seed=6" -- Just 6 -- -- >>> parseSeed "--seeeed=6" -- Nothing --parseSeed :: String -> Maybe Int -- | Parse number of threads argument -- --
-- >>> parseThreads "-j6" -- Just 6 -- -- >>> parseThreads "-j-2" -- Nothing -- -- >>> parseThreads "-jA" -- Nothing --parseThreads :: String -> Maybe Int -- | Parse a specific flag with a value, or return Nothing -- --
-- >>> parseSpecificFlag "--foo" "foo" -- Nothing -- -- >>> parseSpecificFlag "--foo=" "foo" -- Nothing -- -- >>> parseSpecificFlag "--foo=5" "foo" -- Just "5" -- -- >>> parseSpecificFlag "--foo=5" "bar" -- Nothing --parseSpecificFlag :: String -> String -> Maybe String -- | Parse a flag into its flag and argument component. -- -- Example: -- --
-- >>> parseFlag "--optghc=foo"
-- ("--optghc",Just "foo")
--
-- >>> parseFlag "--optghc="
-- ("--optghc",Nothing)
--
-- >>> parseFlag "--fast"
-- ("--fast",Nothing)
--
parseFlag :: String -> (String, Maybe String)
instance GHC.Base.Functor Test.DocTest.Internal.Options.Result
instance GHC.Show.Show a => GHC.Show.Show (Test.DocTest.Internal.Options.Result a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.DocTest.Internal.Options.Result a)
instance Control.DeepSeq.NFData Test.DocTest.Internal.Options.ModuleConfig
instance GHC.Generics.Generic Test.DocTest.Internal.Options.ModuleConfig
instance GHC.Classes.Eq Test.DocTest.Internal.Options.ModuleConfig
instance GHC.Show.Show Test.DocTest.Internal.Options.ModuleConfig
instance Control.DeepSeq.NFData Test.DocTest.Internal.Options.Config
instance GHC.Generics.Generic Test.DocTest.Internal.Options.Config
instance GHC.Classes.Eq Test.DocTest.Internal.Options.Config
instance GHC.Show.Show Test.DocTest.Internal.Options.Config
module Test.DocTest.Internal.Util
convertDosLineEndings :: String -> String
-- | Return the longest suffix of elements that satisfy a given predicate.
takeWhileEnd :: (a -> Bool) -> [a] -> [a]
-- | Remove trailing white space from a string.
--
-- -- >>> stripEnd "foo " -- "foo" --stripEnd :: String -> String module Test.DocTest.Internal.Extract -- | Documentation for a module grouped together with the modules name. data Module a Module :: String -> Maybe a -> [a] -> [Located String] -> Module a [moduleName] :: Module a -> String [moduleSetup] :: Module a -> Maybe a [moduleContent] :: Module a -> [a] [moduleConfig] :: Module a -> [Located String] -- | Extract all docstrings from given list of files/modules. -- -- This includes the docstrings of all local modules that are imported -- from those modules (possibly indirect). extract :: [String] -> IO [Module (Located String)] eraseConfigLocation :: Module a -> Module a instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Test.DocTest.Internal.Extract.Module a) instance GHC.Generics.Generic (Test.DocTest.Internal.Extract.Module a) instance GHC.Show.Show a => GHC.Show.Show (Test.DocTest.Internal.Extract.Module a) instance GHC.Base.Functor Test.DocTest.Internal.Extract.Module instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.DocTest.Internal.Extract.Module a) instance GHC.Show.Show Test.DocTest.Internal.Extract.ExtractError instance GHC.Exception.Type.Exception Test.DocTest.Internal.Extract.ExtractError module Test.DocTest.Internal.Parse -- | Documentation for a module grouped together with the modules name. data Module a Module :: String -> Maybe a -> [a] -> [Located String] -> Module a [moduleName] :: Module a -> String [moduleSetup] :: Module a -> Maybe a [moduleContent] :: Module a -> [a] [moduleConfig] :: Module a -> [Located String] data DocTest Example :: Expression -> ExpectedResult -> DocTest Property :: Expression -> DocTest type Interaction = (Expression, ExpectedResult) type Expression = String type ExpectedResult = [ExpectedLine] data ExpectedLine ExpectedLine :: [LineChunk] -> ExpectedLine WildCardLine :: ExpectedLine data LineChunk LineChunk :: String -> LineChunk WildCardChunk :: LineChunk -- | Extract DocTests from all given modules and all modules -- included by the given modules. getDocTests :: [String] -> IO [Module [Located DocTest]] -- | Extract all interactions from given Haddock comment. parseInteractions :: Located String -> [Located Interaction] -- | Extract all properties from given Haddock comment. parseProperties :: Located String -> [Located Expression] mkLineChunks :: String -> [LineChunk] instance GHC.Classes.Eq Test.DocTest.Internal.Parse.LineChunk instance GHC.Show.Show Test.DocTest.Internal.Parse.LineChunk instance GHC.Classes.Eq Test.DocTest.Internal.Parse.ExpectedLine instance GHC.Show.Show Test.DocTest.Internal.Parse.ExpectedLine instance GHC.Show.Show Test.DocTest.Internal.Parse.DocTest instance GHC.Classes.Eq Test.DocTest.Internal.Parse.DocTest instance Data.String.IsString Test.DocTest.Internal.Parse.ExpectedLine instance Data.String.IsString Test.DocTest.Internal.Parse.LineChunk module Test.DocTest.Internal.Runner.Example data Result Equal :: Result NotEqual :: [String] -> Result mkResult :: ExpectedResult -> [String] -> Result instance GHC.Show.Show Test.DocTest.Internal.Runner.Example.Result instance GHC.Classes.Eq Test.DocTest.Internal.Runner.Example.Result instance GHC.Show.Show a => GHC.Show.Show (Test.DocTest.Internal.Runner.Example.Match a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Test.DocTest.Internal.Runner.Example.Match a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.DocTest.Internal.Runner.Example.Match a) instance GHC.Show.Show Test.DocTest.Internal.Runner.Example.ChunksDivergence instance GHC.Show.Show Test.DocTest.Internal.Runner.Example.LinesDivergence instance GHC.Base.Functor Test.DocTest.Internal.Runner.Example.Match module Test.DocTest.Internal.Property -- | The result of evaluating an interaction. data PropertyResult Success :: PropertyResult Failure :: String -> PropertyResult Error :: String -> PropertyResult runProperty :: Interpreter -> Expression -> IO PropertyResult -- | Find all free variables in given term. -- -- GHCi is used to detect free variables. freeVariables :: Interpreter -> String -> IO [String] -- | Parse and return all variables that are not in scope from a ghc error -- message. parseNotInScope :: String -> [String] instance GHC.Show.Show Test.DocTest.Internal.Property.PropertyResult instance GHC.Classes.Eq Test.DocTest.Internal.Property.PropertyResult module Test.DocTest.Internal.Runner -- | Whether an "example" is part of setup block data FromSetup FromSetup :: FromSetup NotFromSetup :: FromSetup -- | Summary of a test run. data Summary Summary :: Int -> Int -> Int -> Int -> Summary -- | Total number of lines of examples (excluding setup) [sExamples] :: Summary -> Int -- | Executed sTried lines so far [sTried] :: Summary -> Int -- | Couldn't execute sErrors examples [sErrors] :: Summary -> Int -- | Got unexpected output for sFailures examples [sFailures] :: Summary -> Int emptySummary :: Summary -- | Run all examples from a list of modules. runModules :: ModuleConfig -> Maybe Int -> Bool -> Bool -> [String] -> Bool -> [Module [Located DocTest]] -> IO Summary -- | Count number of expressions in given module. count :: Module [Located DocTest] -> Int -- | A monad for generating test reports. type Report = StateT ReportState IO data ReportState ReportState :: Int -> Bool -> Bool -> Bool -> Summary -> ReportState -- | characters on the current line [reportStateCount] :: ReportState -> Int -- | should intermediate results be printed? [reportStateInteractive] :: ReportState -> Bool [reportStateVerbose] :: ReportState -> Bool [reportStateQuiet] :: ReportState -> Bool -- | test summary [reportStateSummary] :: ReportState -> Summary -- | Add output to the report. report :: String -> Report () -- | Add intermediate output to the report. -- -- This will be overwritten by subsequent calls to -- report/report_. Intermediate out may not contain any -- newlines. report_ :: String -> Report () -- | Add output to the report, overwrite any intermediate out. overwrite :: String -> Report () -- | Shuffle a list given a seed for an RNG shuffle :: Int -> [a] -> [a] -- | Run all examples from given module. runModule :: ModuleConfig -> Bool -> [String] -> Chan ReportUpdate -> Module [Located DocTest] -> IO () data ReportUpdate -- | Test succeeded UpdateSuccess :: FromSetup -> Location -> ReportUpdate -- | Test failed with unexpected result UpdateFailure :: FromSetup -> Location -> Expression -> [String] -> ReportUpdate -- | Test failed with an error UpdateError :: FromSetup -> Location -> Expression -> String -> ReportUpdate -- | Message to send when verbose output is activated UpdateVerbose :: String -> ReportUpdate -- | All examples tested in module UpdateModuleDone :: ReportUpdate -- | Indicate test has started executing (verbose output) UpdateStart :: Location -> Expression -> String -> ReportUpdate -- | Exception caught while executing internal code UpdateInternalError :: FromSetup -> Module [Located DocTest] -> SomeException -> ReportUpdate -- | Could not import module UpdateImportError :: ModuleName -> Either String String -> ReportUpdate -- | Unrecognized flag in module specific option UpdateOptionError :: Location -> String -> ReportUpdate makeThreadPool :: Int -> (Chan ReportUpdate -> Module [Located DocTest] -> IO ()) -> IO (Chan (Module [Located DocTest]), Chan ReportUpdate) reportStart :: Location -> Expression -> String -> Report () reportFailure :: FromSetup -> Location -> Expression -> [String] -> Report () reportError :: FromSetup -> Location -> Expression -> String -> Report () reportOptionError :: Location -> String -> Report () reportInternalError :: FromSetup -> Module a -> SomeException -> Report () reportImportError :: ModuleName -> Either String String -> Report () reportSuccess :: FromSetup -> Location -> Report () verboseReport :: String -> Report () updateSummary :: FromSetup -> Summary -> Report () reportProgress :: Report () -- | Run given test group. -- -- The interpreter state is zeroed with :reload first. This -- means that you can reuse the same Interpreter for several test -- groups. runTestGroup :: FromSetup -> Bool -> Interpreter -> IO () -> Chan ReportUpdate -> [Located DocTest] -> IO Bool -- | Execute all expressions from given example in given Interpreter -- and verify the output. runExampleGroup :: FromSetup -> Bool -> Interpreter -> Chan ReportUpdate -> [Located Interaction] -> IO Bool safeEvalWith :: Bool -> Interpreter -> String -> IO (Either String String) instance GHC.Classes.Eq Test.DocTest.Internal.Runner.Summary instance GHC.Show.Show Test.DocTest.Internal.Runner.Summary instance GHC.Base.Monoid Test.DocTest.Internal.Runner.Summary instance GHC.Base.Semigroup Test.DocTest.Internal.Runner.Summary module Test.DocTest -- | Run doctest with given list of arguments. -- -- Example: -- --
-- mainFromCabal "my-project" =<< getArgs --mainFromCabal :: String -> [String] -> IO () -- | Like mainFromCabal, but with a given library. mainFromLibrary :: Library -> [String] -> IO () -- | Run doctest given config. -- -- Example: -- --
-- mainFromCabal "my-project" defaultConfig --mainFromCabalWithConfig :: String -> Config -> IO () -- | Run doctests with given library and config. mainFromLibraryWithConfig :: Library -> Config -> IO () -- | Filter modules to be tested against a list of modules to be tested -- (specified by the user on the command line). If list is empty, test -- all modules. Throws and error if a non-existing module was specified. filterModules :: [ModuleName] -> [Module a] -> [Module a] isSuccess :: Summary -> Bool setSeed :: Bool -> ModuleConfig -> IO ModuleConfig -- | Run doctest for given library and config. Produce a summary of all -- tests. run :: Library -> Config -> IO Summary