Testable.dcl 3.01 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
	testable: the test algorithm for logical properties
Bas Lijnse's avatar
Bas Lijnse committed
7

8
	Pieter Koopman, 2002-2012
Bas Lijnse's avatar
Bas Lijnse committed
9 10 11 12 13
	Radboud Universty, Nijmegen
	The Netherlands
	pieter@cs.ru.nl
*/

14
import Gast.GenLibTest 
15 16
from Gast.StdProperty import ::Property // for instance of testable
import Gast.Gen
Bas Lijnse's avatar
Bas Lijnse committed
17 18 19

//--- basics --//

20
:: Admin = {labels::![String], args::![String], name::![String], res::!Result, mes::![String]}
Bas Lijnse's avatar
Bas Lijnse committed
21
:: Result = Undef | Rej | Pass | OK | CE
22
newAdmin :: Admin
Bas Lijnse's avatar
Bas Lijnse committed
23 24 25 26

derive gLess Result
instance == Result

27
:: Property = Prop (GenState Admin -> [Admin])
Bas Lijnse's avatar
Bas Lijnse committed
28 29 30

prop :: a -> Property | Testable a

31 32
class TestArg a | genShow{|*|} a & ggen{|*|} a
class Testable a where evaluate :: a GenState !Admin -> [Admin]
Bas Lijnse's avatar
Bas Lijnse committed
33 34 35 36

instance Testable Bool
instance Testable Result
instance Testable Property
37 38
///instance Testable (a->b) | Testable b & genShow{|*|} a & ggen{|*|} a //TestArg a  
instance Testable (a->b) | Testable b & genShow{|*|} a & ggen{|*|} a & TestArg a  
Bas Lijnse's avatar
Bas Lijnse committed
39 40 41 42
instance Testable [a] | Testable a  

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

43
MaxExists	:== 1000
Bas Lijnse's avatar
Bas Lijnse committed
44 45 46 47
NrOfTest	:== 1000

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

48 49
//aStream :: RandomStream
//split :: !RandomStream -> (RandomStream,RandomStream)
Bas Lijnse's avatar
Bas Lijnse committed
50 51 52

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

53 54 55 56 57
diagonal :: [[a]] -> [a]
forAll :: !(a->b) ![a] GenState !Admin -> [Admin] | Testable b & TestArg a
//split :: !RandomStream -> (RandomStream,RandomStream)
//generateAll :: !RandomStream -> [a] | ggen{|*|} a
generateAll :: !GenState -> [a] | ggen{|*|} a //& genType{|*|} a
Bas Lijnse's avatar
Bas Lijnse committed
58 59 60

//--- testing --//

61 62 63 64 65 66 67 68 69 70 71 72
:: Testoption
	= Tests 		Int
	| Fails 		Int
	| Args  		Int
	| RandomSeed	Int
	| RandomList	[Int]
	| Skew			Int
	| MaxDepth		Int
	| Verbose
	| Trace
	| Concise
	| Quiet
73
	| OutputTestEvents //* output test results as event specified in clean-platform {{Testing.TestEvents}}
74 75 76 77 78
	| ArgTypes		[GenType]

Test     :: [Testoption] !p   -> [String] | Testable p
TestList :: [Testoption] ![p] -> [String] | Testable p

79 80 81 82 83 84 85 86 87
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
testEvents  ::      !RandomStream !p -> [String] | Testable p
testEventsn :: !Int !RandomStream !p -> [String] | Testable p
Bas Lijnse's avatar
Bas Lijnse committed
88 89 90 91 92 93

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