IOTasks
Safe HaskellNone

Test.IOTasks.Random

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 
Instance details

Defined in Test.IOTasks.Internal.SpecificationGenerator

Methods

showsPrec :: Int -> Specification -> ShowS

show :: Specification -> String

showList :: [Specification] -> ShowS

Eq Specification Source # 
Instance details

Defined in Test.IOTasks.Internal.Specification

Ord Specification Source # 
Instance details

Defined in Test.IOTasks.Internal.Specification

readInput :: (Typeable a, Read a, Show a) => Var a -> ValueSet a -> InputMode -> 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.

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 InputMode Source #

Instances

Instances details
Show InputMode Source # 
Instance details

Defined in Test.IOTasks.Internal.Specification

Methods

showsPrec :: Int -> InputMode -> ShowS

show :: InputMode -> String

showList :: [InputMode] -> ShowS

Eq InputMode Source # 
Instance details

Defined in Test.IOTasks.Internal.Specification

Methods

(==) :: InputMode -> InputMode -> Bool

(/=) :: InputMode -> InputMode -> Bool

Ord InputMode Source # 
Instance details

Defined in Test.IOTasks.Internal.Specification

Methods

compare :: InputMode -> InputMode -> Ordering

(<) :: InputMode -> InputMode -> Bool

(<=) :: InputMode -> InputMode -> Bool

(>) :: InputMode -> InputMode -> Bool

(>=) :: InputMode -> InputMode -> Bool

max :: InputMode -> InputMode -> InputMode

min :: InputMode -> InputMode -> InputMode

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

singleton :: Integer -> ValueSet Integer Source #

fromList :: [Integer] -> ValueSet Integer Source #

lessThan :: Integer -> ValueSet Integer Source #

greaterThan :: Integer -> ValueSet Integer Source #

(\\) :: 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.

with :: ValueSet Integer -> Integer -> ValueSet Integer Source #

without :: ValueSet Integer -> Integer -> ValueSet Integer Source #

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.

ints :: ValueSet Integer Source #

nats :: ValueSet Integer Source #

str :: ValueSet String Source #

data OutputPattern (k :: PatternKind) Source #

Instances

Instances details
Monoid (OutputPattern k) Source # 
Instance details

Defined in Test.IOTasks.Internal.OutputPattern

Semigroup (OutputPattern k) Source # 
Instance details

Defined in Test.IOTasks.Internal.OutputPattern

Methods

(<>) :: OutputPattern k -> OutputPattern k -> OutputPattern k

sconcat :: NonEmpty (OutputPattern k) -> OutputPattern k

stimes :: Integral b => b -> OutputPattern k -> OutputPattern k

Show (OutputPattern k) Source # 
Instance details

Defined in Test.IOTasks.Internal.OutputPattern

Methods

showsPrec :: Int -> OutputPattern k -> ShowS

show :: OutputPattern k -> String

showList :: [OutputPattern k] -> ShowS

Eq (OutputPattern k) Source # 
Instance details

Defined in Test.IOTasks.Internal.OutputPattern

Methods

(==) :: OutputPattern k -> OutputPattern k -> Bool

(/=) :: OutputPattern k -> OutputPattern k -> Bool

Ord (OutputPattern k) Source # 
Instance details

Defined in Test.IOTasks.Internal.OutputPattern

text :: forall (k :: PatternKind). String -> OutputPattern k Source #

resultOf :: forall a (tk :: TermKind). (Typeable a, Show a) => Term tk a -> OutputPattern 'SpecificationP Source #

type Varname = String 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 :: Var a -> Var b -> GOrdering a b

GEq Var Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

geq :: 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

intVar :: Varname -> Var Integer 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 #

embeddedVar :: (Typeable a, Embeddable a, Show a, Read a) => Varname -> Var (Embedded a) Source #

data Embedded a Source #

Instances

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

Defined in Test.IOTasks.Var

Methods

readsPrec :: Int -> ReadS (Embedded a)

readList :: ReadS [Embedded a]

readPrec :: ReadPrec (Embedded a)

readListPrec :: ReadPrec [Embedded a]

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

Methods

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

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

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

Accessors

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

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

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

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

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

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], 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

Methods

showsPrec :: Int -> MergedVars a -> ShowS

show :: MergedVars a -> String

showList :: [MergedVars a] -> ShowS

Eq (MergedVars a) Source # 
Instance details

Defined in Test.IOTasks.Var

Methods

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

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

Arithmetic functions

(.+.) :: forall (k :: TermKind). Term k Integer -> Term k Integer -> Term k Integer Source #

(.-.) :: forall (k :: TermKind). Term k Integer -> Term k Integer -> Term k Integer Source #

(.*.) :: forall (k :: TermKind). Term k Integer -> Term k Integer -> Term k Integer Source #

intLit :: forall (k :: TermKind). Integer -> Term k Integer Source #

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

not' :: forall (k :: TermKind). Term k Bool -> Term k Bool Source #

(.&&.) :: forall (k :: TermKind). Term k Bool -> Term k Bool -> Term k Bool Source #

(.||.) :: forall (k :: TermKind). Term k Bool -> Term k Bool -> Term k Bool Source #

true :: forall (k :: TermKind). Term k Bool Source #

false :: forall (k :: TermKind). Term k Bool Source #

Embedded values

embeddedLit :: forall a (k :: TermKind). (Embeddable a, Typeable a, Show a) => a -> Term k (Embedded a) Source #

Simple list functions

sum' :: forall (k :: TermKind). Term k [Integer] -> Term k Integer Source #

product' :: forall (k :: TermKind). Term k [Integer] -> Term k Integer Source #

length' :: forall a (k :: TermKind). Typeable a => Term k [a] -> Term k Integer Source #

reverse' :: forall a (k :: TermKind). Typeable a => Term k [a] -> Term k [a] Source #

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 #

listLit :: forall a (k :: TermKind). (Show a, Typeable a) => [a] -> Term k [a] 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 #

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 () .

Instances

Instances details
MonadTeletype IO Source # 
Instance details

Defined in Test.IOTasks.MonadTeletype

Methods

putChar :: Char -> IO () Source #

getChar :: IO Char Source #

putStr :: String -> IO () Source #

putStrLn :: String -> IO () Source #

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

getLine :: IO String Source #

readLn :: Read a => IO a Source #

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

MonadTeletype IOrep Source # 
Instance details

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 #

data IOrep a Source #

Instances

Instances details
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

MonadTeletype IOrep Source # 
Instance details

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 #

type Line = String Source #

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

Methods

pPrintPrec :: PrettyLevel -> Rational -> Trace -> Doc

pPrint :: Trace -> Doc

pPrintList :: PrettyLevel -> [Trace] -> Doc

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

Methods

(<>) :: Outcome -> Outcome -> Outcome

sconcat :: NonEmpty Outcome -> Outcome

stimes :: Integral b => b -> Outcome -> Outcome

Show Outcome Source # 
Instance details

Defined in Test.IOTasks.Testing

Methods

showsPrec :: Int -> Outcome -> ShowS

show :: Outcome -> String

showList :: [Outcome] -> ShowS

Eq Outcome Source # 
Instance details

Defined in Test.IOTasks.Testing

Methods

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

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

data CoreOutcome Source #

Instances

Instances details
Monoid CoreOutcome Source # 
Instance details

Defined in Test.IOTasks.Testing

Semigroup CoreOutcome Source # 
Instance details

Defined in Test.IOTasks.Testing

Methods

(<>) :: CoreOutcome -> CoreOutcome -> CoreOutcome

sconcat :: NonEmpty CoreOutcome -> CoreOutcome

stimes :: Integral b => b -> CoreOutcome -> CoreOutcome

Show CoreOutcome Source # 
Instance details

Defined in Test.IOTasks.Testing

Methods

showsPrec :: Int -> CoreOutcome -> ShowS

show :: CoreOutcome -> String

showList :: [CoreOutcome] -> ShowS

Eq CoreOutcome Source # 
Instance details

Defined in Test.IOTasks.Testing

Methods

(==) :: CoreOutcome -> CoreOutcome -> Bool

(/=) :: CoreOutcome -> CoreOutcome -> Bool

data OutcomeHints Source #

Constructors

NoHints 
OverflowHint Int 

Instances

Instances details
Monoid OutcomeHints Source # 
Instance details

Defined in Test.IOTasks.Testing

Semigroup OutcomeHints Source # 
Instance details

Defined in Test.IOTasks.Testing

Show OutcomeHints Source # 
Instance details

Defined in Test.IOTasks.Testing

Methods

showsPrec :: Int -> OutcomeHints -> ShowS

show :: OutcomeHints -> String

showList :: [OutcomeHints] -> ShowS

Eq OutcomeHints Source # 
Instance details

Defined in Test.IOTasks.Testing

Methods

(==) :: OutcomeHints -> OutcomeHints -> Bool

(/=) :: OutcomeHints -> OutcomeHints -> Bool

data FeedbackStyle Source #

Constructors

FeedbackStyle 

Fields

Pre-computed test suites

genInput :: Specification -> Maybe Int -> Size -> Int -> Gen Inputs 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