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

/*
	GAST: A Generic Automatic Software Test-system
	
6
	gen: generic generation of values of a type
Bas Lijnse's avatar
Bas Lijnse committed
7

Steffen Michels's avatar
Steffen Michels committed
8
	Pieter Koopman, 2004, 2017
Bas Lijnse's avatar
Bas Lijnse committed
9 10 11 12 13 14
	Radboud Universty, Nijmegen
	The Netherlands
	pieter@cs.ru.nl
*/

import StdGeneric
15 16
from Data.Set import :: Set
from Data.Map import :: Map
Bas Lijnse's avatar
Bas Lijnse committed
17

18 19 20
:: RandomStream :== [Int]
aStream :: RandomStream
splitRandomStream :: !RandomStream -> (RandomStream,RandomStream)
21
randomize :: ![a] [Int] Int ([Int] -> [a]) -> [a]
Bas Lijnse's avatar
Bas Lijnse committed
22

23 24
generic ggen a :: !GenState -> [a]

Camil Staps's avatar
Camil Staps committed
25 26 27 28
:: GenState =
	{ depth                 :: !Int //* depth
	, maxDepth              :: !Int
	, path                  :: ![ConsPos] //* path to nonrecursive constructor
29
	, mode                  :: !Mode
Camil Staps's avatar
Camil Staps committed
30 31 32
	, recInfo               :: !Map TypeName (Set TypeName)
	, pairTree              :: !PairTree
	, recFieldValueNrLimits :: !Map (TypeName, RecFieldName) Int //* Restricts the number of values generated for record fields
33 34
	}

35 36 37 38 39 40
:: Mode = SkewGeneration !SkewParameters | BentGeneration

:: SkewParameters = { skewl :: !Int
                    , skewr :: !Int
                    }

41 42 43
:: TypeName	    :== String
:: RecFieldName :== String
:: PairTree       = PTLeaf | PTNode PairTree Bool Bool PairTree
44 45 46

genState :: GenState

47 48 49 50 51
derive ggen Int, Bool, Real, Char, String
derive ggen UNIT, PAIR, EITHER, CONS of gcd, OBJECT of gtd, FIELD of d, RECORD of grd
derive ggen (,), (,,), (,,,), (,,,,), (,,,,,), (,,,,,,), (,,,,,,,)
derive ggen [], [!], [ !], [!!]
derive ggen {}, {!}
52 53 54 55

maxint	:: Int
minint	:: Int
StrLen	:== 80