Copyright | (c) 2017 Rudy Matela |
---|---|
License | 3-Clause BSD (see the file LICENSE) |
Maintainer | Rudy Matela <rudy@matela.com.br> |
Safe Haskell | None |
Language | Haskell2010 |
This module is part of Extrapolate, a library for generalization of counter-examples.
This is the core of extrapolate.
- module Test.LeanCheck
- module Test.LeanCheck.Utils.TypeBinding
- module Test.Extrapolate.Exprs
- class (Listable a, Typeable a, Show a) => Generalizable a where
- this :: Generalizable a => a -> (Instances -> Instances) -> Instances -> Instances
- backgroundWith :: Typeable a => [Expr] -> a -> Instances
- (+++) :: Ord a => [a] -> [a] -> [a]
- backgroundOf :: Generalizable a => a -> [Expr]
- bgEq :: (Eq a, Generalizable a) => a -> [Expr]
- bgOrd :: (Ord a, Generalizable a) => a -> [Expr]
- bgEqWith1 :: (Generalizable a, Generalizable b) => ((b -> b -> Bool) -> a -> a -> Bool) -> [Expr]
- bgEqWith2 :: (Generalizable a, Generalizable b, Generalizable c) => ((b -> b -> Bool) -> (c -> c -> Bool) -> a -> a -> Bool) -> [Expr]
- data Option
- = MaxTests Int
- | ExtraInstances Instances
- | MaxConditionSize Int
- data WithOption a = With {}
- maxTests :: Testable a => a -> Int
- extraInstances :: Testable a => a -> Instances
- maxConditionSize :: Testable a => a -> Int
- hasEq :: Generalizable a => a -> Bool
- (*==*) :: Generalizable a => a -> a -> Bool
- (*/=*) :: Generalizable a => a -> a -> Bool
- (*<=*) :: Generalizable a => a -> a -> Bool
- (*<*) :: Generalizable a => a -> a -> Bool
- counterExamples :: Testable a => Int -> a -> [[Expr]]
- counterExampleGen :: Testable a => Int -> a -> Maybe ([Expr], Maybe [Expr])
- counterExampleGens :: Testable a => Int -> a -> Maybe ([Expr], [[Expr]])
- generalizations :: Instances -> [Expr] -> [[Expr]]
- generalizationsCE :: Testable a => Int -> a -> [Expr] -> [[Expr]]
- generalizationsCEC :: Testable a => Int -> a -> [Expr] -> [(Expr, [Expr])]
- generalizationsCounts :: Testable a => Int -> a -> [Expr] -> [([Expr], Int)]
- weakestCondition :: Testable a => Int -> a -> [Expr] -> Expr
- candidateConditions :: Testable a => a -> [Expr] -> [Expr]
- conditionalGeneralization :: Testable a => Int -> a -> [Expr] -> [Expr] -> Maybe ([Expr], [Expr])
- matchList :: [Expr] -> [Expr] -> Maybe Binds
- newMatches :: [Expr] -> [Expr] -> Maybe Binds
- class Testable a where
- results :: Testable a => a -> [([Expr], Bool)]
- areInstancesOf :: [Expr] -> [Expr] -> Bool
- expressionsT :: [Expr] -> [[Expr]]
Documentation
module Test.LeanCheck
module Test.Extrapolate.Exprs
class (Listable a, Typeable a, Show a) => Generalizable a where Source #
Extrapolate can generalize counter-examples of any types that are
Generalizable
.
The core (and only required functions) of the generalizable typeclass are
the expr
and instances
functions.
The following example shows a datatype and its instance:
data Stack a = Stack a (Stack a) | Empty
instance Generalizable a => Generalizable (Stack a) where name _ = "s" expr s@(Stack x y) = constant "Stack" (Stack ->>: s) :$ expr x :$ expr y expr s@Empty = constant "Empty" (Empty -: s) instances s = this s $ instances (argTy1of1 s)
To declare instances
and expr
it may be useful to use:
- LeanCheck's Test.LeanCheck.Utils.TypeBinding operators:
-:
,->:
,->>:
, ...; - Extrapolate's Test.Extrapolate.TypeBinding operators:
argTy1of1
,argTy1of2
,argTy2of2
, ....
Common name for a variable, defaults to "x"
.
background :: a -> [Expr] Source #
List of symbols allowed to appear in side-conditions.
Defaults to []
. See constant
.
instances :: a -> Instances -> Instances Source #
Computes a list of reified instances. See this
.
Generalizable Bool Source # | |
Generalizable Char Source # | |
Generalizable Int Source # | |
Generalizable Integer Source # | |
Generalizable Ordering Source # | |
Generalizable () Source # | |
Generalizable a => Generalizable [a] Source # | |
Generalizable a => Generalizable (Maybe a) Source # | |
(Generalizable a, Generalizable b) => Generalizable (Either a b) Source # | |
(Generalizable a, Generalizable b) => Generalizable (a, b) Source # | |
(Generalizable a, Generalizable b, Generalizable c) => Generalizable (a, b, c) Source # | |
(Generalizable a, Generalizable b, Generalizable c, Generalizable d) => Generalizable (a, b, c, d) Source # | |
this :: Generalizable a => a -> (Instances -> Instances) -> Instances -> Instances Source #
backgroundWith :: Typeable a => [Expr] -> a -> Instances Source #
backgroundOf :: Generalizable a => a -> [Expr] Source #
bgEqWith1 :: (Generalizable a, Generalizable b) => ((b -> b -> Bool) -> a -> a -> Bool) -> [Expr] Source #
bgEqWith2 :: (Generalizable a, Generalizable b, Generalizable c) => ((b -> b -> Bool) -> (c -> c -> Bool) -> a -> a -> Bool) -> [Expr] Source #
data WithOption a Source #
Testable a => Testable (WithOption a) Source # | |
extraInstances :: Testable a => a -> Instances Source #
maxConditionSize :: Testable a => a -> Int Source #
hasEq :: Generalizable a => a -> Bool Source #
(*==*) :: Generalizable a => a -> a -> Bool Source #
(*/=*) :: Generalizable a => a -> a -> Bool Source #
(*<=*) :: Generalizable a => a -> a -> Bool Source #
(*<*) :: Generalizable a => a -> a -> Bool Source #
generalizations :: Instances -> [Expr] -> [[Expr]] Source #
conditionalGeneralization :: Testable a => Int -> a -> [Expr] -> [Expr] -> Maybe ([Expr], [Expr]) Source #
matchList :: [Expr] -> [Expr] -> Maybe Binds Source #
List matches of lists of expressions if possible
[0,1] `matchList` [x,y] = Just [x=0, y=1] [0,1+2] `matchList` [x,y+y] = Nothing
expressionsT :: [Expr] -> [[Expr]] Source #