tcp enabled gast version added
[tt2015.git] / a3 / code / Gast / testable.dcl
1 definition module testable
2
3 /*
4 GAST: A Generic Automatic Software Test-system
5
6 testable: the test algorithm for logical properties
7
8 Pieter Koopman, 2002-2010
9 Radboud Universty, Nijmegen
10 The Netherlands
11 pieter@cs.ru.nl
12 */
13
14 import genLibTest
15 from stdProperty import ::Property // for instance of testable
16 import gen
17
18 //--- basics --//
19
20 :: Admin = {labels::![String], args::![String], name::![String], res::Result}
21 :: Result = Undef | Rej | Pass | OK | CE
22 :: RandomStream :== [Int]
23
24 derive gLess Result
25 instance == Result
26
27 :: Property = Prop (RandomStream Admin -> [Admin])
28
29 prop :: a -> Property | Testable a
30
31 class TestArg a | genShow{|*|}, ggen{|*|} a
32 class Testable a where evaluate :: a RandomStream !Admin -> [Admin]
33
34 instance Testable Bool
35 instance Testable Result
36 instance Testable Property
37 instance Testable (a->b) | Testable b & TestArg a
38 instance Testable [a] | Testable a
39
40 //derive bimap [], (,), (,,), (,,,), (,,,,), (,,,,,)
41
42 MaxExists :== 1000
43 NrOfTest :== 1000
44
45 //--- for generating lists of elements ---//
46
47 aStream :: RandomStream
48
49 //--- for implementation of properties ---//
50
51 diagonal :: [[a]] -> [a]
52 forAll :: !(a->b) ![a] RandomStream !Admin -> [Admin] | Testable b & TestArg a
53 split :: !RandomStream -> (RandomStream,RandomStream)
54 generateAll :: !RandomStream -> [a] | ggen{|*|} a
55
56 //--- testing --//
57
58 :: Testoption
59 = Tests Int
60 | Fails Int
61 | Args Int
62 | RandomSeed Int
63 | RandomList [Int]
64 | Verbose
65 | Concise
66 | Quiet
67
68 Test :: [Testoption] !p -> [String] | Testable p
69 TestList :: [Testoption] ![p] -> [String] | Testable p
70
71 verbose :: !RandomStream !p -> [String] | Testable p
72 verbosen :: !Int !RandomStream !p -> [String] | Testable p
73 concise :: !RandomStream !p -> [String] | Testable p
74 concisen :: !Int !RandomStream !p -> [String] | Testable p
75 quiet :: !RandomStream !p -> [String] | Testable p
76 quietn :: !Int !RandomStream !p -> [String] | Testable p
77 quietnm :: !Int !Int !RandomStream !p -> [String] | Testable p
78
79 test :: !p -> [String] | Testable p // test p NrOfTest times
80 testn :: !Int !p -> [String] | Testable p // maxnumber of tests
81 ttestn :: !Int !p -> [String] | Testable p // maxnumber of tests, trace all arguments
82 testnm :: !Int !Int !p -> [String] | Testable p // maxnumber of tests, max number of errors
83 ttestnm :: !Int !Int !p -> [String] | Testable p // maxnumber of tests, max number of errors