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

/*
	GAST: A Generic Automatic Software Test-system
	
6
	Gast.Testable: the test algorithm for logical properties
Bas Lijnse's avatar
Bas Lijnse committed
7 8 9 10 11 12 13

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

14 15 16
import Gast.GenLibTest
from Gast.StdProperty import ::Property // for instance of testable
import Gast.Gen
Bas Lijnse's avatar
Bas Lijnse committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

//--- basics --//

:: Admin = {labels::![String], args::![String], name::![String], res::Result}
:: Result = Undef | Rej | Pass | OK | CE
:: RandomStream :== [Int]

derive gLess Result
instance == Result

:: Property = Prop (RandomStream Admin -> [Admin])

prop :: a -> Property | Testable a

class TestArg a | genShow{|*|}, ggen{|*|} a
class Testable a where evaluate :: a RandomStream !Admin -> [Admin]

instance Testable Bool
instance Testable Result
instance Testable Property
instance Testable (a->b) | Testable b & TestArg a  
instance Testable [a] | Testable a  

//derive bimap [], (,), (,,), (,,,), (,,,,), (,,,,,)

MaxExists	:== 500
NrOfTest	:== 1000

//--- for generating lists of elements ---//

aStream :: RandomStream

//--- for implementation of properties ---//

diagonal :: [[a]] -> [a]
forAll :: !(a->b) ![a] RandomStream !Admin -> [Admin] | Testable b & TestArg a
split :: !RandomStream -> (RandomStream,RandomStream)
generateAll :: !RandomStream -> [a] | ggen{|*|} a

//--- testing --//

verbose  ::      !RandomStream !p -> [String] | Testable p
verbosen :: !Int !RandomStream !p -> [String] | Testable p
concise  ::      !RandomStream !p -> [String] | Testable p
concisen :: !Int !RandomStream !p -> [String] | Testable p
quiet    ::      !RandomStream !p -> [String] | Testable p
quietn   :: !Int !RandomStream !p -> [String] | Testable p
quietnm  :: !Int !Int !RandomStream !p -> [String] | Testable p

test :: !p -> [String] | Testable p              // test p NrOfTest times
testn :: !Int !p -> [String] | Testable p        // maxnumber of tests
ttestn :: !Int !p -> [String] | Testable p       // maxnumber of tests, trace all arguments
testnm :: !Int !Int !p -> [String] | Testable p  // maxnumber of tests, max number of errors
ttestnm :: !Int !Int !p -> [String] | Testable p // maxnumber of tests, max number of errors