Safe Haskell | None |
---|
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
- 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 (k :: TermKind). (Integer -> Bool) -> Term k [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 (k :: TermKind). (Typeable a, Typeable b, Typeable c) => (a -> b -> c, String) -> Term k a -> Term k 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] -> NTrace
- 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
- valueSize :: 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
Specification
argument is the "then-case". - The second
Specification
argument 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
'
Transparent
Bool
argument is the condition to be evaluated at the beginning of each iteration. The loop continues as long as the condition isTrue
. - The
Specification
argument 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
'
Transparent
Bool
argument is the condition to be evaluated at the beginning of each iteration. The loop continues as long as the condition isFalse
. - The
Specification
argument 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
Specification
argument is the body of the loop, executed at least once and then further times while the condition isFalse
. - The
Term
'
Transparent
Bool
argument 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
Specification
argument is the body of the loop, executed at least once and then further times while the condition isTrue
. - The
Term
'
Transparent
Bool
argument 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)
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 #
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
.
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
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 toVarList :: MergedVars a -> [Var a] Source # | |
Show (MergedVars a) Source # | |
Defined in Test.IOTasks.Var showsPrec :: Int -> MergedVars a -> ShowS show :: MergedVars a -> String showList :: [MergedVars a] -> ShowS | |
Eq (MergedVars a) Source # | |
Defined in Test.IOTasks.Var (==) :: MergedVars a -> MergedVars a -> Bool (/=) :: MergedVars a -> MergedVars a -> Bool |
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 (k :: TermKind). (Integer -> Bool) -> Term k [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 (k :: TermKind). (Typeable a, Typeable b, Typeable c) => (a -> b -> c, String) -> Term k a -> Term k b -> Term 'PartiallyOpaque c Source #
Programs
class Monad m => MonadTeletype (m :: Type -> Type) where Source #
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 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 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 # |
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 #
Args | |
|
data CoreOutcome Source #
Instances
Monoid CoreOutcome Source # | |
Defined in Test.IOTasks.Testing mappend :: CoreOutcome -> CoreOutcome -> CoreOutcome mconcat :: [CoreOutcome] -> CoreOutcome | |
Semigroup CoreOutcome Source # | |
Defined in Test.IOTasks.Testing (<>) :: CoreOutcome -> CoreOutcome -> CoreOutcome sconcat :: NonEmpty CoreOutcome -> CoreOutcome stimes :: Integral b => b -> CoreOutcome -> CoreOutcome | |
Show CoreOutcome Source # | |
Defined in Test.IOTasks.Testing showsPrec :: Int -> CoreOutcome -> ShowS show :: CoreOutcome -> String showList :: [CoreOutcome] -> ShowS | |
Eq CoreOutcome Source # | |
Defined in Test.IOTasks.Testing (==) :: CoreOutcome -> CoreOutcome -> Bool (/=) :: CoreOutcome -> CoreOutcome -> Bool |
data OutcomeHints Source #
NoHints | |
OverflowHint Int |
Instances
Monoid OutcomeHints Source # | |
Defined in Test.IOTasks.Testing mappend :: OutcomeHints -> OutcomeHints -> OutcomeHints mconcat :: [OutcomeHints] -> OutcomeHints | |
Semigroup OutcomeHints Source # | |
Defined in Test.IOTasks.Testing (<>) :: OutcomeHints -> OutcomeHints -> OutcomeHints sconcat :: NonEmpty OutcomeHints -> OutcomeHints stimes :: Integral b => b -> OutcomeHints -> OutcomeHints | |
Show OutcomeHints Source # | |
Defined in Test.IOTasks.Testing showsPrec :: Int -> OutcomeHints -> ShowS show :: OutcomeHints -> String showList :: [OutcomeHints] -> ShowS | |
Eq OutcomeHints Source # | |
Defined in Test.IOTasks.Testing (==) :: OutcomeHints -> OutcomeHints -> Bool (/=) :: OutcomeHints -> OutcomeHints -> Bool |
overflowWarnings :: Outcome -> Int Source #
data FeedbackStyle Source #
FeedbackStyle | |
|
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