NoRedInk/elm-check/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Check.Investigator

Sub-module containing the Investigator type used by elm-check.

This sub-module contains several predefined investigator generators and means of composing them to create your own. Note that most generators provided are only well-suited to local development. Property-based testing is by its nature a very slow process and is best paired with some sort of continuous integration service. Consider making your own, more general investigator generators when migrating from local to cloud-based.

Shrink

shrink : Investigator a -> Shrinker a

Shrink a value from an Investigator generator.

int : Investigator Int


shrink int 10 == [0,5,7,8,9]

Investigator Definition

type alias Investigator a =
{ generator : Generator a
, shrinker : Shrinker a
}

An Investigator type is a Random Generator paired with a shrinking strategy, or Shrinker. Shrinkers are defined in elm-shrink.

investigator : Generator a -> Shrinker a -> Investigator a

Investigator constructor. Construct an Investigator from a generator and a shrinker.

Basic Investigator Generators

void : Investigator ()

Investigator void. Uses a constant generator and the void shrinker from elm-shrink.

bool : Investigator Bool

Investigator bool. Uses the bool generator from elm-random-extra and the bool shrinker from elm-shrink.

order : Investigator Order

Investigator order. Uses the order generator from elm-random-extra and the order shrinker from elm-shrink.

random : Investigator a -> Generator a

Extract a Random Generator from and an Investigator generator.

int : Investigator Int

Investigator int. Generates random ints between -50 and 50 and the int shrinker from elm-shrink. Ideal for local testing.

rangeInt : Int -> Int -> Investigator Int

Investigator int constructor. Generates random ints between a given min and a given max value.

float : Investigator Float

Investigator float. Generates random floats between -50 and 50 and the float shrinker from elm-shrink. Ideal for local testing.

percentage : Investigator Float

Investigator percentage. Generates random floats between 0.0 and 1.0 and the float shrinker from elm-shrink. Useful in conjunction with tuple to facilitate things like generating an array and then selecting one of its elements at random.

char : Investigator Char

Investigator char. Generates random ascii chars disregarding the control characters using the char 32 127 generator from elm-random-extra and the character shrinker from elm-shrink. Ideal for local testing or if your domain deals exclusively with ascii and you do not care about control characters.

upperCaseChar : Investigator Char

Investigator char. Generates random ascii chars using the upperCaseLatin generator from elm-random-extra and the character shrinker from elm-shrink.

lowerCaseChar : Investigator Char

Investigator char. Generates random ascii chars using the lowerCaseLatin generator from elm-random-extra and the character shrinker from elm-shrink.

ascii : Investigator Char

Investigator char. Generates random ascii chars using the ascii generator from elm-random-extra and the char shrinker from elm-shrink. Ideal for local testing or if your domain deals exclusively with ascii.

unicode : Investigator Char

Investigator char. Generates a random UTF-8 character using the unicode generator from elm-random-extra and the char shrinker from elm-shrink.

string : Investigator String

Investigator string. Generates random ascii strings of size between 0 and 10 using the rangeLengthString generator from elm-random-extra and the string shrinker from elm-shrink. Ideal for local testing.

maybe : Investigator a -> Investigator (Maybe a)

Investigator maybe constructor. Generates random maybe values from a given investigator generator using the maybe generator constructor from elm-random-extra and the maybe shrinker constructor from elm-shrink.

Investigator error
-> Investigator value
-> Investigator (Result error value)

Investigator result constructor. Generates random result values from a given investigator generator using the result generator constructor from elm-random-extra and the result shrinker constrctor from elm-shrink.

list : Investigator a -> Investigator (List a)

Investigator list constructor. Generates random lists of values of size between 0 and 10 from a given investigator generator using the rangeLengthList generator constructor from elm-random-extra and the list shrinker constructor from elm-shrink. Ideal for local testing.

array : Investigator a -> Investigator (Array a)

Investigator array constructor. Generates random arrays of values of size between 0 and 10 from a given investigator generator using the rangeLengthArray generator constructor from elm-random-extra and the array shrinker constructor from elm-shrink. Ideal for local testing.

tuple : ( Investigator a, Investigator b ) -> Investigator ( a, b )

Investigator 2-tuple constructor. Generates random 2-tuples from a 2-tuple of investigator generators. Uses the tuple shrinker constructor from elm-shrink.

( Investigator a, Investigator b, Investigator c )
-> Investigator ( a, b, c )

Investigator 3-tuple constructor. Generates random 3-tuples from a 3-tuple of investigator generators. Uses the tuple3 shrinker constrctor from elm-shrink.

( Investigator a
, Investigator b
, Investigator c
, Investigator d
)
-> Investigator ( a, b, c, d )

Investigator 4-tuple constructor. Generates random 4-tuples from a 4-tuple of investigator generators. Uses the tuple4 shrinker constrctor from elm-shrink.

( Investigator a
, Investigator b
, Investigator c
, Investigator d
, Investigator e
)
-> Investigator ( a, b, c, d, e )

Investigator 5-tuple constructor. Generates random 5-tuples from a 5-tuple of investigator generators. Uses the tuple5 shrinker constrctor from elm-shrink.

func : Investigator b -> Investigator (a -> b)

Investigator of functions. Takes an investigator for the return type and returns an investigator of functions. Uses the func generator from elm-random-extra and does not perform any shrinking.

func2 : Investigator c -> Investigator (a -> b -> c)
func3 : Investigator d -> Investigator (a -> b -> c -> d)
func4 : Investigator e -> Investigator (a -> b -> c -> d -> e)
func5 : Investigator f -> Investigator (a -> b -> c -> d -> e -> f)