PHP Класс QCheck\Generator

Based on clojure.test.check.generators.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
alphaChars ( ) : Generator creates a generator that produces only alphabetic characters
alphaNumChars ( ) : Generator creates a generator that produces alphanumeric characters
alphaNumStrings ( ) : Generator creates a generator that produces alphanumeric strings
alphaStrings ( ) : Generator creates a generator that produces alphabetic strings
any ( )
anyPrintable ( )
arraysOf ( self $gen ) : Generator creates a generator that produces arrays whose elements are chosen from $gen.
asciiChars ( ) : Generator creates a generator that produces only ASCII characters
asciiStrings ( ) : Generator creates a generator that produces ASCII strings
bind ( callable $k ) : Generator creates a new generator that passes the result of this generator to the callable $k which should return a new generator.
booleans ( ) : Generator creates a generator that produces true or false. Shrinks to false.
call ( Random $rng, integer $size ) : RoseTree invokes the generator with the given RNG and size
chars ( ) : Generator creates a generator that produces characters from 0-255
choose ( integer $lower, integer $upper ) : Generator creates a generator that returns numbers in the range $lower to $upper, inclusive
containerTypes ( self $innerType )
elements ( ) : Generator creates a generator that randomly chooses from the specified values
fmap ( callable $f ) : Generator maps function f over the values produced by this generator
forAll ( array $args, callable $f )
frequency ( ) : Generator creates a generator that produces values from specified generators based on likelihoods. The likelihood of a generator being chosen is its likelihood divided by the sum of all likelihoods.
intRoseTree ( $val )
intoArrays ( ) : Generator creates a generator that produces arrays whose elements are chosen from this generator.
ints ( ) : Generator creates a generator that returns a positive or negative integer bounded by the generators size parameter.
maps ( self $keygen, self $valgen ) : Generator creates a generator that produces arrays with keys chosen from $keygen and values chosen from $valgen.
mapsFrom ( self $keygen ) : Generator creates a generator that produces arrays with keys chosen from $keygen and values chosen from this generator.
mapsTo ( self $valgen ) : Generator creates a generator that produces arrays with keys chosen from this generator and values chosen from $valgen.
mapsWith ( array $map ) : Generator creates a generator that produces arrays with the same keys as in $map where each corresponding value is chosen from a specified generator.
negInts ( ) : Generator creates a generator that produces negative integers bounded by the generators size parameter.
notEmpty ( $maxTries = 10 )
oneOf ( ) : Generator creates a new generator that randomly chooses a value from the list of provided generators. Shrinks toward earlier generators as well as shrinking the generated value itself.
posInts ( ) : Generator creates a generator that produces positive integers bounded by the generators size parameter.
recursive ( callable $container, self $scalar )
resize ( integer $n ) : Generator creates a new generator based on this generator with size always bound to $n
samples ( integer $maxSize = 100 ) : Generator returns an infinite sequence of random samples from this generator bounded by $maxSize
simplePrintableTypes ( )
simpleTypes ( )
sizes ( $maxSize ) --------------------------------------------------
strictlyNegInts ( ) : Generator creates a generator that produces strictly negative integers bounded by the generators size parameter.
strictlyPosInts ( ) : Generator creates a generator that produces strictly positive integers bounded by the generators size parameter.
strings ( ) : Generator creates a generator that produces strings; may contain unprintable chars
suchThat ( callable $pred, integer $maxTries = 10 ) : Generator creates a new generator that generates values from this generator such that they satisfy callable $pred.
takeSamples ( integer $num = 10 ) : array returns an array of $num random samples from this generator
tuples ( ) : Generator creates a new generator that returns an array whose elements are chosen from the list of given generators. Individual elements shrink according to their generator but the array will never shrink in count.
unit ( mixed $value ) : Generator creates a generator that always returns $value and never shrinks

Приватные методы

Метод Описание
__construct ( callable $gen )
bindGen ( callable $k )
fmapGen ( callable $k )
getArgs ( array $args )
halfs ( $n ) --------------------------------------------------
pureGen ( $value )
randRange ( Random $rng, $lower, $upper )
recursiveHelper ( $container, $scalar, $scalarSize, $childrenSize, $height )
sequence ( Generator[] | Iterator $ms ) : Generator turns a list of generators into a generator of a list
shrinkInt ( $i )
sized ( callable $sizedGen )

Описание методов

alphaChars() публичный статический Метод

creates a generator that produces only alphabetic characters
public static alphaChars ( ) : Generator
Результат Generator

alphaNumChars() публичный статический Метод

creates a generator that produces alphanumeric characters
public static alphaNumChars ( ) : Generator
Результат Generator

alphaNumStrings() публичный статический Метод

creates a generator that produces alphanumeric strings
public static alphaNumStrings ( ) : Generator
Результат Generator

alphaStrings() публичный статический Метод

creates a generator that produces alphabetic strings
public static alphaStrings ( ) : Generator
Результат Generator

any() публичный статический Метод

public static any ( )

anyPrintable() публичный статический Метод

public static anyPrintable ( )

arraysOf() публичный статический Метод

creates a generator that produces arrays whose elements are chosen from $gen.
public static arraysOf ( self $gen ) : Generator
$gen self
Результат Generator

asciiChars() публичный статический Метод

creates a generator that produces only ASCII characters
public static asciiChars ( ) : Generator
Результат Generator

asciiStrings() публичный статический Метод

creates a generator that produces ASCII strings
public static asciiStrings ( ) : Generator
Результат Generator

bind() публичный Метод

creates a new generator that passes the result of this generator to the callable $k which should return a new generator.
public bind ( callable $k ) : Generator
$k callable
Результат Generator

booleans() публичный статический Метод

creates a generator that produces true or false. Shrinks to false.
public static booleans ( ) : Generator
Результат Generator

call() публичный Метод

invokes the generator with the given RNG and size
public call ( Random $rng, integer $size ) : RoseTree
$rng Random
$size integer
Результат RoseTree

chars() публичный статический Метод

creates a generator that produces characters from 0-255
public static chars ( ) : Generator
Результат Generator

choose() публичный статический Метод

creates a generator that returns numbers in the range $lower to $upper, inclusive
public static choose ( integer $lower, integer $upper ) : Generator
$lower integer
$upper integer
Результат Generator

containerTypes() публичный статический Метод

public static containerTypes ( self $innerType )
$innerType self

elements() публичный статический Метод

Accepts either a variadic number of args or a single array of values. Example: Gen::elements('foo', 'bar', 'baz') Gen::elements(['foo', 'bar', 'baz'])
public static elements ( ) : Generator
Результат Generator

fmap() публичный Метод

maps function f over the values produced by this generator
public fmap ( callable $f ) : Generator
$f callable
Результат Generator

forAll() публичный статический Метод

public static forAll ( array $args, callable $f )
$args array
$f callable

frequency() публичный статический Метод

Example: Gen::frequency( 5, Gen::ints(), 3, Gen::booleans(), 2, Gen::alphaStrings() )
public static frequency ( ) : Generator
Результат Generator

intRoseTree() публичный статический Метод

public static intRoseTree ( $val )

intoArrays() публичный Метод

creates a generator that produces arrays whose elements are chosen from this generator.
public intoArrays ( ) : Generator
Результат Generator

ints() публичный статический Метод

creates a generator that returns a positive or negative integer bounded by the generators size parameter.
public static ints ( ) : Generator
Результат Generator

maps() публичный статический Метод

creates a generator that produces arrays with keys chosen from $keygen and values chosen from $valgen.
public static maps ( self $keygen, self $valgen ) : Generator
$keygen self
$valgen self
Результат Generator

mapsFrom() публичный Метод

creates a generator that produces arrays with keys chosen from $keygen and values chosen from this generator.
public mapsFrom ( self $keygen ) : Generator
$keygen self
Результат Generator

mapsTo() публичный Метод

creates a generator that produces arrays with keys chosen from this generator and values chosen from $valgen.
public mapsTo ( self $valgen ) : Generator
$valgen self
Результат Generator

mapsWith() публичный статический Метод

Example: Gen::mapsWith( 'foo' => Gen::booleans(), 'bar' => Gen::ints() )
public static mapsWith ( array $map ) : Generator
$map array
Результат Generator

negInts() публичный статический Метод

creates a generator that produces negative integers bounded by the generators size parameter.
public static negInts ( ) : Generator
Результат Generator

notEmpty() публичный Метод

public notEmpty ( $maxTries = 10 )

oneOf() публичный статический Метод

Accepts either a variadic number of args or a single array of generators. Example: Gen::oneOf(Gen::booleans(), Gen::ints()) Gen::oneOf([Gen::booleans(), Gen::ints()])
public static oneOf ( ) : Generator
Результат Generator

posInts() публичный статический Метод

creates a generator that produces positive integers bounded by the generators size parameter.
public static posInts ( ) : Generator
Результат Generator

recursive() публичный статический Метод

public static recursive ( callable $container, self $scalar )
$container callable
$scalar self

resize() публичный Метод

creates a new generator based on this generator with size always bound to $n
public resize ( integer $n ) : Generator
$n integer
Результат Generator

samples() публичный Метод

returns an infinite sequence of random samples from this generator bounded by $maxSize
public samples ( integer $maxSize = 100 ) : Generator
$maxSize integer
Результат Generator

simplePrintableTypes() публичный статический Метод

public static simplePrintableTypes ( )

simpleTypes() публичный статический Метод

public static simpleTypes ( )

sizes() публичный статический Метод

--------------------------------------------------
public static sizes ( $maxSize )

strictlyNegInts() публичный статический Метод

creates a generator that produces strictly negative integers bounded by the generators size parameter.
public static strictlyNegInts ( ) : Generator
Результат Generator

strictlyPosInts() публичный статический Метод

creates a generator that produces strictly positive integers bounded by the generators size parameter.
public static strictlyPosInts ( ) : Generator
Результат Generator

strings() публичный статический Метод

creates a generator that produces strings; may contain unprintable chars
public static strings ( ) : Generator
Результат Generator

suchThat() публичный Метод

At most $maxTries attempts will be made to generate a value that satisfies the predicate. At every retry the size parameter will be increased. In case of failure an exception will be thrown.
public suchThat ( callable $pred, integer $maxTries = 10 ) : Generator
$pred callable
$maxTries integer
Результат Generator

takeSamples() публичный Метод

returns an array of $num random samples from this generator
public takeSamples ( integer $num = 10 ) : array
$num integer
Результат array

tuples() публичный статический Метод

Accepts either a variadic number of args or a single array of generators. Example: Gen::tuples(Gen::booleans(), Gen::ints()) Gen::tuples([Gen::booleans(), Gen::ints()])
public static tuples ( ) : Generator
Результат Generator

unit() публичный статический Метод

creates a generator that always returns $value and never shrinks
public static unit ( mixed $value ) : Generator
$value mixed
Результат Generator