Copyright | (c) 2013-2016 Galois Inc. |
---|---|
License | BSD3 |
Maintainer | cryptol@galois.com |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
This module generates random values for Cryptol types.
Synopsis
- type Gen g b w i = Integer -> g -> (GenValue b w i, g)
- runOneTest :: RandomGen g => EvalOpts -> Value -> [Gen g Bool BV Integer] -> Integer -> g -> IO (TestResult, g)
- returnOneTest :: RandomGen g => EvalOpts -> Value -> [Gen g Bool BV Integer] -> Integer -> g -> IO ([Value], Value, g)
- returnTests :: RandomGen g => g -> EvalOpts -> Type -> Value -> Int -> IO [([Value], Value)]
- testableType :: RandomGen g => Type -> Maybe [Gen g Bool BV Integer]
- randomValue :: (BitWord b w i, RandomGen g) => Type -> Maybe (Gen g b w i)
- randomBit :: (BitWord b w i, RandomGen g) => Gen g b w i
- randomSize :: RandomGen g => Int -> Int -> g -> (Int, g)
- randomInteger :: (BitWord b w i, RandomGen g) => Gen g b w i
- randomIntMod :: (BitWord b w i, RandomGen g) => Integer -> Gen g b w i
- randomWord :: (BitWord b w i, RandomGen g) => Integer -> Gen g b w i
- randomStream :: RandomGen g => Gen g b w i -> Gen g b w i
- randomSequence :: RandomGen g => Integer -> Gen g b w i -> Gen g b w i
- randomTuple :: RandomGen g => [Gen g b w i] -> Gen g b w i
- randomRecord :: RandomGen g => [(Ident, Gen g b w i)] -> Gen g b w i
Documentation
:: RandomGen g | |
=> g | The random generator state |
-> EvalOpts | How to evaluate things |
-> Type | The type of the function for which tests are to be generated |
-> Value | The function itself |
-> Int | How many tests? |
-> IO [([Value], Value)] | A list of pairs of random arguments and computed outputs |
Return a collection of random tests.
testableType :: RandomGen g => Type -> Maybe [Gen g Bool BV Integer] Source #
Given a (function) type, compute generators for the function's arguments. Currently we do not support polymorphic functions. In principle, we could apply these to random types, and test the results.
randomValue :: (BitWord b w i, RandomGen g) => Type -> Maybe (Gen g b w i) Source #
A generator for values of the given type. This fails if we are given a type that lacks a suitable random value generator.
randomInteger :: (BitWord b w i, RandomGen g) => Gen g b w i Source #
Generate a random integer value. The size parameter is assumed to vary between 1 and 100, and we use it to generate smaller numbers first.
randomWord :: (BitWord b w i, RandomGen g) => Integer -> Gen g b w i Source #
Generate a random word of the given length (i.e., a value of type [w]
)
The size parameter is assumed to vary between 1 and 100, and we use
it to generate smaller numbers first.
randomStream :: RandomGen g => Gen g b w i -> Gen g b w i Source #
Generate a random infinite stream value.