PHP 클래스 QCheck\Generator

Based on clojure.test.check.generators.
파일 보기 프로젝트 열기: steos/php-quickcheck 1 사용 예제들

공개 메소드들

메소드 설명
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