IOTasks-2.2.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.IOTasks

Synopsis

Specifications

data Specification Source #

Instances

Instances details
Arbitrary Specification Source # 
Instance details

Defined in Test.IOTasks.Internal.Specification

Monoid Specification Source # 
Instance details

Defined in Test.IOTasks.Internal.Specification

Semigroup Specification Source # 
Instance details

Defined in Test.IOTasks.Internal.Specification

Show Specification Source # 
Instance details

Defined in Test.IOTasks.Internal.SpecificationGenerator

Eq Specification Source # 
Instance details

Defined in Test.IOTasks.Internal.Specification

Ord Specification Source # 
Instance details

Defined in Test.IOTasks.Internal.Specification

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.

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 is True.
  • The Specification argument is the body of the loop, executed while the condition is True.

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 is False.
  • The Specification argument is the body of the loop, executed while the condition is False.

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 is False.
  • The Term 'Transparent Bool argument is the condition to be evaluated at the end of each iteration. The loop continues until the condition becomes True.

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 is True.
  • The Term 'Transparent Bool argument is the condition to be evaluated at the end of each iteration. The loop continues until the condition becomes False.

The function assumes that the body specification does not contain a top-level exit marker.

doWhile bdy c = tillExit (bdy <> branch c nop exit)

data ValueSet a Source #

Instances

Instances details
Eq (ValueSet a) Source # 
Instance details

Defined in Test.IOTasks.Internal.ValueSet

Methods

(==) :: ValueSet a -> ValueSet a -> Bool #

(/=) :: ValueSet a -> ValueSet a -> Bool #

Ord (ValueSet a) Source # 
Instance details

Defined in Test.IOTasks.Internal.ValueSet

Methods

compare :: ValueSet a -> ValueSet a -> Ordering #

(<) :: ValueSet a -> ValueSet a -> Bool #

(<=) :: ValueSet a -> ValueSet a -> Bool #

(>) :: ValueSet a -> ValueSet a -> Bool #

(>=) :: ValueSet a -> ValueSet a -> Bool #

max :: ValueSet a -> ValueSet a -> ValueSet a #

min :: ValueSet a -> ValueSet a -> ValueSet a #

(\\) :: ValueSet Integer -> ValueSet Integer -> ValueSet Integer Source #

The (\\) operator computes set difference. It returns a ValueSet containing all integers of the first set that are not present in the second set.

isEmpty :: Var Integer -> Map SomeVar [AST] -> ValueSet Integer -> IO Bool Source #

Check if a given ValueSet of integers is empty.

This function uses an external SMT solver to check the constraints defined by the ValueSet.

data OutputPattern (k :: PatternKind) Source #

data Var a Source #

Instances

Instances details
VarExp Var Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

toVarList :: Var a -> [Var a] Source #

GCompare Var Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

gcompare :: forall (a :: k) (b :: k). Var a -> Var b -> GOrdering a b #

GEq Var Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

geq :: forall (a :: k) (b :: k). Var a -> Var b -> Maybe (a :~: b) #

Show (Var a) Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

showsPrec :: Int -> Var a -> ShowS #

show :: Var a -> String #

showList :: [Var a] -> ShowS #

Eq (Var a) Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

(==) :: Var a -> Var a -> Bool #

(/=) :: Var a -> Var a -> Bool #

Ord (Var a) Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

compare :: Var a -> Var a -> Ordering #

(<) :: Var a -> Var a -> Bool #

(<=) :: Var a -> Var a -> Bool #

(>) :: Var a -> Var a -> Bool #

(>=) :: Var a -> Var a -> Bool #

max :: Var a -> Var a -> Var a #

min :: Var a -> Var a -> Var a #

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.

data Embedded a Source #

Instances

Instances details
(Show a, Read a, Embeddable a) => Read (Embedded a) Source # 
Instance details

Defined in Test.IOTasks.Var

Show a => Show (Embedded a) Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

showsPrec :: Int -> Embedded a -> ShowS #

show :: Embedded a -> String #

showList :: [Embedded a] -> ShowS #

Eq (Embedded a) Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

(==) :: Embedded a -> Embedded a -> Bool #

(/=) :: Embedded a -> Embedded a -> Bool #

Terms

data Term (k :: TermKind) a Source #

Instances

Instances details
EffectEval (Term k) Source # 
Instance details

Defined in Test.IOTasks.Internal.Term

Associated Types

type Env (Term k) Source #

Methods

pureEval :: (Applicative f, Typeable a) => (forall x. Typeable x => Term k x -> f x) -> Env (Term k) -> Term k a -> f a Source #

eval :: Typeable a => Env (Term k) -> Term k a -> a Source #

Typeable a => Show (Term k a) Source # 
Instance details

Defined in Test.IOTasks.Internal.Term

Methods

showsPrec :: Int -> Term k a -> ShowS #

show :: Term k a -> String #

showList :: [Term k a] -> ShowS #

Typeable a => Eq (Term k a) Source # 
Instance details

Defined in Test.IOTasks.Internal.Term

Methods

(==) :: Term k a -> Term k a -> Bool #

(/=) :: Term k a -> Term k a -> Bool #

Typeable a => Ord (Term k a) Source # 
Instance details

Defined in Test.IOTasks.Internal.Term

Methods

compare :: Term k a -> Term k a -> Ordering #

(<) :: Term k a -> Term k a -> Bool #

(<=) :: Term k a -> Term k a -> Bool #

(>) :: Term k a -> Term k a -> Bool #

(>=) :: Term k a -> Term k a -> Bool #

max :: Term k a -> Term k a -> Term k a #

min :: Term k a -> Term k a -> Term k a #

type Env (Term k) Source # 
Instance details

Defined in Test.IOTasks.Internal.Term

type Env (Term k) = ValueMap

Accessors

currentValue :: (Typeable a, VarExp e) => e a -> Term k a Source #

Defined as currentValue = valueBefore 0, providing access to the current value.

allValues :: (Typeable a, VarExp e) => e a -> Term k [a] Source #

Defined as allValues = valuesBefore 0, providing access to all values.

valueBefore :: (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], valueBefore i x provides access to x_(n-i).

valuesBefore :: (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], valuesBefore i x provides access to [x_1,..,x_(n-i)].

data MergedVars a Source #

Instances

Instances details
VarExp MergedVars Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

toVarList :: MergedVars a -> [Var a] Source #

Show (MergedVars a) Source # 
Instance details

Defined in Test.IOTasks.Var

Eq (MergedVars a) Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

(==) :: MergedVars a -> MergedVars a -> Bool #

(/=) :: MergedVars a -> MergedVars a -> Bool #

Arithmetic functions

Comparison functions

(.==.) :: (Typeable a, Eq a) => Term k a -> Term k a -> Term k Bool Source #

(./=.) :: (Typeable a, Eq a) => Term k a -> Term k a -> Term k Bool Source #

(.>.) :: (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool Source #

(.>=.) :: (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool Source #

(.<.) :: (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool Source #

(.<=.) :: (Typeable a, Ord a) => Term k a -> Term k a -> Term k Bool Source #

Boolean functions

Embedded values

Simple list functions

length' :: Typeable a => Term k [a] -> Term k Integer Source #

reverse' :: Typeable a => Term k [a] -> Term k [a] Source #

isIn :: (Typeable a, Eq a) => Term k a -> Term k [a] -> Term k Bool Source #

isNotIn :: (Typeable a, Eq a) => Term k a -> Term k [a] -> Term k Bool Source #

listLit :: (Show a, Typeable a) => [a] -> Term k [a] Source #

Complexer list functions

Lifting of opaque functions

liftOpaque :: (Typeable a, Typeable b) => (a -> b, String) -> Term k a -> Term 'PartiallyOpaque b Source #

liftOpaque2 :: (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 where Source #

Minimal complete definition

putChar, getChar

Methods

putChar :: Char -> m () Source #

getChar :: m Char Source #

putStr :: String -> m () Source #

putStrLn :: String -> m () Source #

print :: Show a => a -> m () Source #

getLine :: m String Source #

readLn :: Read a => m a Source #

hSetBuffering :: Handle -> BufferMode -> m () Source #

for compatibility with regular IO programs.

Defaults to hSetBuffering _ _ = pure () .

data IOrep a Source #

Instances

Instances details
MonadTeletype IOrep Source # 
Instance details

Defined in Test.IOTasks.IOrep

Applicative IOrep Source # 
Instance details

Defined in Test.IOTasks.IOrep

Methods

pure :: a -> IOrep a #

(<*>) :: IOrep (a -> b) -> IOrep a -> IOrep b #

liftA2 :: (a -> b -> c) -> IOrep a -> IOrep b -> IOrep c #

(*>) :: IOrep a -> IOrep b -> IOrep b #

(<*) :: IOrep a -> IOrep b -> IOrep a #

Functor IOrep Source # 
Instance details

Defined in Test.IOTasks.IOrep

Methods

fmap :: (a -> b) -> IOrep a -> IOrep b #

(<$) :: a -> IOrep b -> IOrep a #

Monad IOrep Source # 
Instance details

Defined in Test.IOTasks.IOrep

Methods

(>>=) :: IOrep a -> (a -> IOrep b) -> IOrep b #

(>>) :: IOrep a -> IOrep b -> IOrep b #

return :: a -> IOrep a #

data Trace Source #

Instances

Instances details
Semigroup Trace Source # 
Instance details

Defined in Test.IOTasks.Trace

Methods

(<>) :: Trace -> Trace -> Trace #

sconcat :: NonEmpty Trace -> Trace #

stimes :: Integral b => b -> Trace -> Trace #

Show Trace Source # 
Instance details

Defined in Test.IOTasks.Trace

Methods

showsPrec :: Int -> Trace -> ShowS #

show :: Trace -> String #

showList :: [Trace] -> ShowS #

Eq Trace Source # 
Instance details

Defined in Test.IOTasks.Trace

Methods

(==) :: Trace -> Trace -> Bool #

(/=) :: Trace -> Trace -> Bool #

Pretty Trace Source # 
Instance details

Defined in Test.IOTasks.Trace

Testing

data Args Source #

Constructors

Args 

Fields

data Outcome Source #

Instances

Instances details
Monoid Outcome Source # 
Instance details

Defined in Test.IOTasks.Testing

Semigroup Outcome Source # 
Instance details

Defined in Test.IOTasks.Testing

Show Outcome Source # 
Instance details

Defined in Test.IOTasks.Testing

Eq Outcome Source # 
Instance details

Defined in Test.IOTasks.Testing

Methods

(==) :: Outcome -> Outcome -> Bool #

(/=) :: Outcome -> Outcome -> Bool #

data FeedbackStyle Source #

Constructors

FeedbackStyle 

Fields

Pre-computed test suites

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