| Safe Haskell | None |
|---|
Test.IOTasks.Random
Synopsis
- data Specification
- runSpecification :: Specification -> [String] -> (AbstractTrace, OverflowWarning)
- runSpecification' :: AddLinebreaks -> Specification -> [String] -> (AbstractTrace, OverflowWarning)
- accept :: Specification -> Trace -> Bool
- readInput :: (Typeable a, Read a, Show a) => Var a -> ValueSet a -> InputMode -> Specification
- writeOutput :: forall (k :: PatternKind). [OutputPattern k] -> Specification
- writeOptionalOutput :: forall (k :: PatternKind). [OutputPattern k] -> Specification
- anyOptionalOutput :: Specification
- branch :: Term 'Transparent Bool -> Specification -> Specification -> Specification
- tillExit :: Specification -> Specification
- exit :: Specification
- nop :: Specification
- while :: Term 'Transparent Bool -> Specification -> Specification
- whileNot :: Term 'Transparent Bool -> Specification -> Specification
- repeatUntil :: Specification -> Term 'Transparent Bool -> Specification
- doWhile :: Specification -> Term 'Transparent Bool -> Specification
- data InputMode
- data ValueSet a
- empty :: ValueSet a
- complete :: ValueSet a
- singleton :: Integer -> ValueSet Integer
- fromList :: [Integer] -> ValueSet Integer
- lessThan :: Integer -> ValueSet Integer
- greaterThan :: Integer -> ValueSet Integer
- union :: ValueSet a -> ValueSet a -> ValueSet a
- intersection :: ValueSet a -> ValueSet a -> ValueSet a
- (\\) :: ValueSet Integer -> ValueSet Integer -> ValueSet Integer
- with :: ValueSet Integer -> Integer -> ValueSet Integer
- without :: ValueSet Integer -> Integer -> ValueSet Integer
- complement :: ValueSet a -> ValueSet a
- unique :: ValueSet a -> ValueSet a
- notInVar :: ValueSet a -> Var a -> ValueSet a
- isEmpty :: Var Integer -> Map SomeVar [AST] -> ValueSet Integer -> IO Bool
- ints :: ValueSet Integer
- nats :: ValueSet Integer
- bools :: ValueSet Bool
- str :: ValueSet String
- data OutputPattern (k :: PatternKind)
- wildcard :: forall (k :: PatternKind). OutputPattern k
- text :: forall (k :: PatternKind). String -> OutputPattern k
- resultOf :: forall a (tk :: TermKind). (Typeable a, Show a) => Term tk a -> OutputPattern 'SpecificationP
- decoratedResultOf :: forall a (tk :: TermKind). (Typeable a, Show a) => Term tk a -> OutputPattern 'SpecificationP
- type Varname = String
- data Var a
- intVar :: Varname -> Var Integer
- boolVar :: Varname -> Var Bool
- stringVar :: Varname -> Var String
- pPrintSpecification :: Specification -> Doc
- class Embeddable a where
- asInteger :: a -> Integer
- asOriginal :: Integer -> a
- embeddingRange :: [Integer]
- embed :: Embeddable a => ValueSet Integer -> ValueSet (Embedded a)
- embedFromList :: Embeddable a => [a] -> ValueSet (Embedded a)
- embeddedVar :: (Typeable a, Embeddable a, Show a, Read a) => Varname -> Var (Embedded a)
- data Embedded a
- data Term (k :: TermKind) a
- data TermKind
- currentValue :: forall a e (k :: TermKind). (Typeable a, VarExp e) => e a -> Term k a
- allValues :: forall a e (k :: TermKind). (Typeable a, VarExp e) => e a -> Term k [a]
- valueBefore :: forall a e (k :: TermKind). (Typeable a, VarExp e) => Int -> e a -> Term k a
- valuesBefore :: forall a e (k :: TermKind). (Typeable a, VarExp e) => Int -> e a -> Term k [a]
- data MergedVars a
- merge :: [Var a] -> MergedVars a
- (.+.) :: forall (k :: TermKind). Term k Integer -> Term k Integer -> Term k Integer
- (.-.) :: forall (k :: TermKind). Term k Integer -> Term k Integer -> Term k Integer
- (.*.) :: forall (k :: TermKind). Term k Integer -> Term k Integer -> Term k Integer
- intLit :: forall (k :: TermKind). Integer -> Term k Integer
- (.==.) :: forall a (k :: TermKind). (Typeable a, Eq a) => Term k a -> Term k a -> Term k Bool
- (./=.) :: forall a (k :: TermKind). (Typeable a, Eq a) => Term k a -> Term k a -> Term k Bool
- (.>.) :: forall a (k :: TermKind). (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool
- (.>=.) :: forall a (k :: TermKind). (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool
- (.<.) :: forall a (k :: TermKind). (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool
- (.<=.) :: forall a (k :: TermKind). (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool
- not' :: forall (k :: TermKind). Term k Bool -> Term k Bool
- (.&&.) :: forall (k :: TermKind). Term k Bool -> Term k Bool -> Term k Bool
- (.||.) :: forall (k :: TermKind). Term k Bool -> Term k Bool -> Term k Bool
- true :: forall (k :: TermKind). Term k Bool
- false :: forall (k :: TermKind). Term k Bool
- embeddedLit :: forall a (k :: TermKind). (Embeddable a, Typeable a, Show a) => a -> Term k (Embedded a)
- sum' :: forall (k :: TermKind). Term k [Integer] -> Term k Integer
- product' :: forall (k :: TermKind). Term k [Integer] -> Term k Integer
- length' :: forall a (k :: TermKind). Typeable a => Term k [a] -> Term k Integer
- reverse' :: forall a (k :: TermKind). Typeable a => Term k [a] -> Term k [a]
- isIn :: forall a (k :: TermKind). (Typeable a, Eq a) => Term k a -> Term k [a] -> Term k Bool
- isNotIn :: forall a (k :: TermKind). (Typeable a, Eq a) => Term k a -> Term k [a] -> Term k Bool
- listLit :: forall a (k :: TermKind). (Show a, Typeable a) => [a] -> Term k [a]
- filter' :: forall (k1 :: TermKind) (k2 :: TermKind). Term k1 (Integer -> Bool) -> Term k2 [Integer] -> Term 'PartiallyOpaque [Integer]
- liftOpaqueValue :: Typeable a => (a, String) -> Term 'PartiallyOpaque a
- liftOpaque :: forall a b (k :: TermKind). (Typeable a, Typeable b) => (a -> b, String) -> Term k a -> Term 'PartiallyOpaque b
- liftOpaque2 :: forall a b c (k1 :: TermKind) (k2 :: TermKind). (Typeable a, Typeable b, Typeable c) => (a -> b -> c, String) -> Term k1 a -> Term k2 b -> Term 'PartiallyOpaque c
- class Monad m => MonadTeletype (m :: Type -> Type) where
- putChar :: Char -> m ()
- getChar :: m Char
- putStr :: String -> m ()
- putStrLn :: String -> m ()
- print :: Show a => a -> m ()
- getLine :: m String
- readLn :: Read a => m a
- hSetBuffering :: Handle -> BufferMode -> m ()
- data IOrep a
- runProgram :: IOrep () -> [Line] -> AbstractTrace
- type Line = String
- data Trace
- covers :: NTrace -> NTrace -> MatchResult
- taskCheck :: IOrep () -> Specification -> IO ()
- taskCheckWith :: Args -> IOrep () -> Specification -> IO ()
- taskCheckOutcome :: IOrep () -> Specification -> IO Outcome
- taskCheckWithOutcome :: Args -> IOrep () -> Specification -> IO Outcome
- data Args = Args {
- maxInputLength :: Maybe Int
- inputRange :: Integer
- numberOfTests :: Int
- maxNegative :: Int
- terminalOutput :: Bool
- feedbackStyle :: FeedbackStyle
- searchTimeout :: Int
- maxSearchTimeouts :: Int
- stdArgs :: Args
- data Outcome = Outcome CoreOutcome OutcomeHints
- data CoreOutcome
- data OutcomeHints
- = NoHints
- | OverflowHint Int
- isSuccess :: Outcome -> Bool
- isFailure :: Outcome -> Bool
- overflowWarnings :: Outcome -> Int
- data FeedbackStyle = FeedbackStyle {
- simplifyFeedback :: Bool
- traceStyle :: TraceStyle
- data TraceStyle
- defaultFeedback :: FeedbackStyle
- printOutcomeWith :: FeedbackStyle -> Outcome -> Doc
- genInput :: Specification -> Maybe Int -> Size -> Int -> Gen Inputs
- taskCheckOn :: [Inputs] -> IOrep () -> Specification -> Outcome
- interpret :: MonadTeletype m => Specification -> [m ()]
Specifications
data Specification Source #
Instances
runSpecification :: Specification -> [String] -> (AbstractTrace, OverflowWarning) Source #
runSpecification' :: AddLinebreaks -> Specification -> [String] -> (AbstractTrace, OverflowWarning) Source #
accept :: Specification -> Trace -> Bool Source #
readInput :: (Typeable a, Read a, Show a) => Var a -> ValueSet a -> InputMode -> Specification Source #
writeOutput :: forall (k :: PatternKind). [OutputPattern k] -> Specification Source #
writeOptionalOutput :: forall (k :: PatternKind). [OutputPattern k] -> Specification Source #
anyOptionalOutput :: Specification Source #
The anyOptionalOutput function represents a specification for writing
arbitrary optional output. The output can be anything, as indicated by the
use of the wildcard pattern in its definition:
anyOptionalOutput = writeOptionalOutput [wildcard]
branch :: Term 'Transparent Bool -> Specification -> Specification -> Specification Source #
Represents a branching structure in a specification.
- The first
Specificationargument is the "then-case". - The second
Specificationargument is the "else-case".
exit :: Specification Source #
nop :: Specification Source #
while :: Term 'Transparent Bool -> Specification -> Specification Source #
Represents a loop structure in a specification, performing the body while the condition holds.
The while function takes a condition and a body specification, and constructs a loop structure where:
- The
Term'TransparentBoolargument is the condition to be evaluated at the beginning of each iteration. The loop continues as long as the condition isTrue. - The
Specificationargument is the body of the loop, executed while the condition isTrue.
The function assumes that the body specification does not contain a top-level exit marker.
while c bdy = tillExit (branch c bdy exit)
whileNot :: Term 'Transparent Bool -> Specification -> Specification Source #
Represents a loop structure in a specification, performing the body while the condition does not hold.
The whileNot function takes a condition and a body specification, and constructs a loop structure where:
- The
Term'TransparentBoolargument is the condition to be evaluated at the beginning of each iteration. The loop continues as long as the condition isFalse. - The
Specificationargument is the body of the loop, executed while the condition isFalse.
The function assumes that the body specification does not contain a top-level exit marker.
whileNot c bdy = tillExit (branch c exit bdy)
repeatUntil :: Specification -> Term 'Transparent Bool -> Specification Source #
Represents a loop structure in a specification, performing the body at least once and then further while the condition does not hold.
The repeatUntil function takes a body specification and a condition, and constructs a loop structure where:
- The
Specificationargument is the body of the loop, executed at least once and then further times while the condition isFalse. - The
Term'TransparentBoolargument is the condition to be evaluated at the end of each iteration. The loop continues until the condition becomesTrue.
The function assumes that the body specification does not contain a top-level exit marker.
repeatUntil bdy c = tillExit (bdy <> branch c exit nop)
doWhile :: Specification -> Term 'Transparent Bool -> Specification Source #
Represents a loop structure in a specification, performing the body at least once and then further while the condition holds.
The doWhile function takes a body specification and a condition, and constructs a loop structure where:
- The
Specificationargument is the body of the loop, executed at least once and then further times while the condition isTrue. - The
Term'TransparentBoolargument is the condition to be evaluated at the end of each iteration. The loop continues until the condition becomesFalse.
The function assumes that the body specification does not contain a top-level exit marker.
doWhile bdy c = tillExit (bdy <> branch c nop exit)
Constructors
| AssumeValid | |
| UntilValid | |
| ElseAbort |
Instances
| Eq (ValueSet a) Source # | |
| Ord (ValueSet a) Source # | |
greaterThan :: Integer -> ValueSet Integer Source #
complement :: ValueSet a -> ValueSet a Source #
data OutputPattern (k :: PatternKind) Source #
Instances
wildcard :: forall (k :: PatternKind). OutputPattern k Source #
text :: forall (k :: PatternKind). String -> OutputPattern k Source #
resultOf :: forall a (tk :: TermKind). (Typeable a, Show a) => Term tk a -> OutputPattern 'SpecificationP Source #
decoratedResultOf :: forall a (tk :: TermKind). (Typeable a, Show a) => Term tk a -> OutputPattern 'SpecificationP Source #
Mandatory decoration of some term's result
Conceptually we have
writeOutput [decoratedResultOf t] = writeOutput [nonEmptyWildcard <> resultOf t <> wildcard, wildcard <> resultOf t <> nonEmptyWildcard]
but matching failure will produce a specialized message
pPrintSpecification :: Specification -> Doc Source #
Embedding non-integer values
class Embeddable a where Source #
Values embeddable into a finite set of integers
Laws:
asInteger . asOriginal = id
For types with Eq instances that induce non-trivial equivalence classes, at least the weaker
asOriginal (asInteger x) == x = True
should hold. However program coverage is weakened in such scenarios, as generated inputs will only
ever contain values from the co-domain of asOriginal.
Methods
asInteger :: a -> Integer Source #
asOriginal :: Integer -> a Source #
embeddingRange :: [Integer] Source #
embedFromList :: Embeddable a => [a] -> ValueSet (Embedded a) Source #
embeddedVar :: (Typeable a, Embeddable a, Show a, Read a) => Varname -> Var (Embedded a) Source #
Terms
Constructors
| Transparent | |
| PartiallyOpaque |
Accessors
currentValue :: forall a e (k :: TermKind). (Typeable a, VarExp e) => e a -> Term k a Source #
Defined as , providing access to the current value.currentValue = valueBefore 0
allValues :: forall a e (k :: TermKind). (Typeable a, VarExp e) => e a -> Term k [a] Source #
Defined as , providing access to all values.allValues = valuesBefore 0
valueBefore :: forall a e (k :: TermKind). (Typeable a, VarExp e) => Int -> e a -> Term k a Source #
If the variable-expression x is associated with the values [x_1,..,x_n],
provides access to x_(n-i).valueBefore i x
valuesBefore :: forall a e (k :: TermKind). (Typeable a, VarExp e) => Int -> e a -> Term k [a] Source #
If the variable-expression x is associated with the values [x_1,..,x_n],
provides access to [x_1,..,x_(n-i)].valuesBefore i x
data MergedVars a Source #
Instances
| VarExp MergedVars Source # | |
Defined in Test.IOTasks.Var Methods toVarList :: MergedVars a -> [Var a] Source # | |
| Show (MergedVars a) Source # | |
Defined in Test.IOTasks.Var Methods showsPrec :: Int -> MergedVars a -> ShowS show :: MergedVars a -> String showList :: [MergedVars a] -> ShowS | |
| Eq (MergedVars a) Source # | |
Defined in Test.IOTasks.Var | |
merge :: [Var a] -> MergedVars a Source #
Arithmetic functions
Comparison functions
(.==.) :: forall a (k :: TermKind). (Typeable a, Eq a) => Term k a -> Term k a -> Term k Bool Source #
(./=.) :: forall a (k :: TermKind). (Typeable a, Eq a) => Term k a -> Term k a -> Term k Bool Source #
(.>.) :: forall a (k :: TermKind). (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool Source #
(.>=.) :: forall a (k :: TermKind). (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool Source #
(.<.) :: forall a (k :: TermKind). (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool Source #
(.<=.) :: forall a (k :: TermKind). (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool Source #
Boolean functions
Embedded values
embeddedLit :: forall a (k :: TermKind). (Embeddable a, Typeable a, Show a) => a -> Term k (Embedded a) Source #
Simple list functions
isIn :: forall a (k :: TermKind). (Typeable a, Eq a) => Term k a -> Term k [a] -> Term k Bool Source #
isNotIn :: forall a (k :: TermKind). (Typeable a, Eq a) => Term k a -> Term k [a] -> Term k Bool Source #
Complexer list functions
filter' :: forall (k1 :: TermKind) (k2 :: TermKind). Term k1 (Integer -> Bool) -> Term k2 [Integer] -> Term 'PartiallyOpaque [Integer] Source #
Lifting of opaque functions
liftOpaqueValue :: Typeable a => (a, String) -> Term 'PartiallyOpaque a Source #
liftOpaque :: forall a b (k :: TermKind). (Typeable a, Typeable b) => (a -> b, String) -> Term k a -> Term 'PartiallyOpaque b Source #
liftOpaque2 :: forall a b c (k1 :: TermKind) (k2 :: TermKind). (Typeable a, Typeable b, Typeable c) => (a -> b -> c, String) -> Term k1 a -> Term k2 b -> Term 'PartiallyOpaque c Source #
Programs
class Monad m => MonadTeletype (m :: Type -> Type) where Source #
Methods
putChar :: Char -> m () Source #
putStr :: String -> m () Source #
putStrLn :: String -> m () Source #
print :: Show a => a -> m () Source #
readLn :: Read a => m a Source #
hSetBuffering :: Handle -> BufferMode -> m () Source #
for compatibility with regular IO programs.
Defaults to
hSetBuffering _ _ = pure ()
.
Instances
| MonadTeletype IO Source # | |
Defined in Test.IOTasks.MonadTeletype | |
| MonadTeletype IOrep Source # | |
Defined in Test.IOTasks.IOrep Methods putChar :: Char -> IOrep () Source # getChar :: IOrep Char Source # putStr :: String -> IOrep () Source # putStrLn :: String -> IOrep () Source # print :: Show a => a -> IOrep () Source # getLine :: IOrep String Source # readLn :: Read a => IOrep a Source # hSetBuffering :: Handle -> BufferMode -> IOrep () Source # | |
Instances
| Applicative IOrep Source # | |
| Functor IOrep Source # | |
| Monad IOrep Source # | |
| MonadTeletype IOrep Source # | |
Defined in Test.IOTasks.IOrep Methods putChar :: Char -> IOrep () Source # getChar :: IOrep Char Source # putStr :: String -> IOrep () Source # putStrLn :: String -> IOrep () Source # print :: Show a => a -> IOrep () Source # getLine :: IOrep String Source # readLn :: Read a => IOrep a Source # hSetBuffering :: Handle -> BufferMode -> IOrep () Source # | |
runProgram :: IOrep () -> [Line] -> AbstractTrace Source #
Testing
taskCheck :: IOrep () -> Specification -> IO () Source #
taskCheckWith :: Args -> IOrep () -> Specification -> IO () Source #
taskCheckOutcome :: IOrep () -> Specification -> IO Outcome Source #
taskCheckWithOutcome :: Args -> IOrep () -> Specification -> IO Outcome Source #
Constructors
| Args | |
Fields
| |
Constructors
| Outcome CoreOutcome OutcomeHints |
data CoreOutcome Source #
Constructors
| Success Int | |
| Failure Inputs ExpectedRun ActualRun MatchResult | |
| GaveUp |
Instances
| Monoid CoreOutcome Source # | |
Defined in Test.IOTasks.Testing | |
| Semigroup CoreOutcome Source # | |
Defined in Test.IOTasks.Testing Methods (<>) :: CoreOutcome -> CoreOutcome -> CoreOutcome sconcat :: NonEmpty CoreOutcome -> CoreOutcome stimes :: Integral b => b -> CoreOutcome -> CoreOutcome | |
| Show CoreOutcome Source # | |
Defined in Test.IOTasks.Testing Methods showsPrec :: Int -> CoreOutcome -> ShowS show :: CoreOutcome -> String showList :: [CoreOutcome] -> ShowS | |
| Eq CoreOutcome Source # | |
Defined in Test.IOTasks.Testing | |
data OutcomeHints Source #
Constructors
| NoHints | |
| OverflowHint Int |
Instances
| Monoid OutcomeHints Source # | |
Defined in Test.IOTasks.Testing Methods mappend :: OutcomeHints -> OutcomeHints -> OutcomeHints mconcat :: [OutcomeHints] -> OutcomeHints | |
| Semigroup OutcomeHints Source # | |
Defined in Test.IOTasks.Testing Methods (<>) :: OutcomeHints -> OutcomeHints -> OutcomeHints sconcat :: NonEmpty OutcomeHints -> OutcomeHints stimes :: Integral b => b -> OutcomeHints -> OutcomeHints | |
| Show OutcomeHints Source # | |
Defined in Test.IOTasks.Testing Methods showsPrec :: Int -> OutcomeHints -> ShowS show :: OutcomeHints -> String showList :: [OutcomeHints] -> ShowS | |
| Eq OutcomeHints Source # | |
Defined in Test.IOTasks.Testing | |
overflowWarnings :: Outcome -> Int Source #
data FeedbackStyle Source #
Constructors
| FeedbackStyle | |
Fields
| |
data TraceStyle Source #
Constructors
| HorizontalTrace | |
| VerticalTrace |
printOutcomeWith :: FeedbackStyle -> Outcome -> Doc Source #
Pre-computed test suites
taskCheckOn :: [Inputs] -> IOrep () -> Specification -> Outcome Source #
Interpreter
interpret :: MonadTeletype m => Specification -> [m ()] Source #
Interpret a specification as a program in Monad m.
Returns a list containing all possible ways of resolving optionality, e.g.
>>>length (interpret $ writeOptionalOutput [x,y])3