StdProperty.dcl 2.69 KB
Newer Older
1
definition module Gast.StdProperty
Bas Lijnse's avatar
Bas Lijnse committed
2 3 4 5

/*
	GAST: A Generic Automatic Software Test-system
	
6
	stdProperty: opertors on logical properties
Bas Lijnse's avatar
Bas Lijnse committed
7 8 9 10 11 12 13

	Pieter Koopman, 2004
	Radboud Universty, Nijmegen
	The Netherlands
	pieter@cs.ru.nl
*/

14
import Gast.GenLibTest
15
import Gast.Testable
Camil Staps's avatar
Camil Staps committed
16
from Testing.TestEvents import :: TestLocation, :: Relation
Bas Lijnse's avatar
Bas Lijnse committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30

class (\/) infixr 2 a b	:: !a b -> Property	//	Conditional or  of arg1 and arg2
class (/\) infixr 3	a b :: !a b -> Property	//	Conditional and of arg1 and arg2

instance /\ Bool     Bool
instance /\ Property Bool
instance /\ Bool     Property
instance /\ Property Property

instance \/ Bool     Bool
instance \/ Property Bool
instance \/ Bool     Property
instance \/ Property Property

31 32 33 34 35 36
(=.=) infix 4 :: !a !a -> Property | Eq, genShow{|*|}, gPrint{|*|} a // shows values x and y if x == y yields False
(<.)  infix 4 :: !a !a -> Property | Ord, genShow{|*|}, gPrint{|*|} a // shows values x and y if x <  y yields False
(<=.) infix 4 :: !a !a -> Property | Ord, genShow{|*|}, gPrint{|*|} a // shows values x and y if x <= y yields False
(>.)  infix 4 :: !a !a -> Property | Ord, genShow{|*|}, gPrint{|*|} a // shows values x and y if x >  y yields False
(>=.) infix 4 :: !a !a -> Property | Ord, genShow{|*|}, gPrint{|*|} a // shows values x and y if x >= y yields False
check :: !(a b -> Bool) !a !b -> Property | genShow{|*|}, gPrint{|*|} a & genShow{|*|}, gPrint{|*|} b
37

38
class (==>) infixr 1 b :: !b p -> Property | Testable p
Bas Lijnse's avatar
Bas Lijnse committed
39 40 41 42

instance ==> Bool
instance ==> Property

43
(<==>) infix 1 :: !a !b -> Property	| Testable a & Testable b		//	True if properties are equivalent
Bas Lijnse's avatar
Bas Lijnse committed
44 45 46 47 48 49 50 51 52 53 54

ExistsIn :: (x->p) [x] -> Property | Testable p & TestArg x 		// type is too restricive
Exists :: (x->p) -> Property | Testable p & TestArg x
ForAll :: !(x->p) -> Property | Testable p & TestArg x

ForEach :: ![x] !(x->p) -> Property | Testable p & TestArg x
(For) infixl 0 :: !(x->p) ![x] -> Property | Testable p & TestArg x
(ForAndGen) infixl 0 :: !(x->p) ![x] -> Property | Testable p & TestArg x

classify :: !Bool l !p -> Property | Testable p & genShow{|*|} l
label ::  !l !p -> Property | Testable p & genShow{|*|} l
55

56
name :: !n !p -> Property | Testable p & toString n
Camil Staps's avatar
Camil Staps committed
57
location_and_name :: !TestLocation !n !p -> Property | Testable p & toString n
58 59 60 61 62

/**
* Assigns a name to a testable property.
*
* @param The name
Steffen Michels's avatar
Steffen Michels committed
63
* @param The testable property
64 65 66
* @return The named property
* @type n p -> Property | Testable p & toString n
*/
Steffen Michels's avatar
Steffen Michels committed
67 68
(as) infix 0 
(as) p n :== name n p
69

70
limitNrOfRecFieldValues :: !(Map (TypeName, RecFieldName) Int) !p -> Property | Testable p
Bas Lijnse's avatar
Bas Lijnse committed
71 72 73

instance ~ Bool
instance ~ Property
Steffen Michels's avatar
Steffen Michels committed
74

75
approxEqual :: !a !a !a -> Property | abs, Ord, -, genShow{|*|}, gPrint{|*|} a