hspec-core-2.11.0.1: A Testing Framework for Haskell
Stabilityunstable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Hspec.Core.Util

Description

 
Synopsis

String functions

pluralize :: Int -> String -> String Source #

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"

Since: 2.0.0

strip :: String -> String Source #

Strip leading and trailing whitespace

Since: 2.0.0

lineBreaksAt :: Int -> String -> [String] Source #

Ensure that lines are not longer than given n, insert line breaks at word boundaries

Since: 2.0.0

stripAnsi :: String -> String Source #

Remove ANSI color escape sequences.

Since: 2.11.0

Working with paths

type Path = ([String], String) Source #

A Path describes the location of a spec item within a spec tree.

It consists of a list of group descriptions and a requirement description.

Since: 2.0.0

joinPath :: Path -> String Source #

Join a Path with slashes. The result will have a leading and a trailing slash.

Since: 2.5.4

formatRequirement :: Path -> String Source #

Try to create a proper English sentence from a path by applying some heuristics.

Since: 2.0.0

filterPredicate :: String -> Path -> Bool Source #

A predicate that can be used to filter a spec tree.

Since: 2.0.0

Working with exceptions

safeTry :: IO a -> IO (Either SomeException a) Source #

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.

Since: 2.0.0

formatException :: SomeException -> String Source #

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\ndivide by zero"

For IOExceptions the IOErrorType is included, as well.

Since: 2.0.0