Checks v0.1.0

Source
Checks that return a readable failure: equality, nearness, text, optionals and outcomes.

Expect

pub func Expect(
    condition: bool,
    message: char8[..]
) -> ! TestFailure

Fails unless condition holds.

Source

Parameters

NameTypeDescription
conditionboolwhat must be true
messagechar8[..]what it means, for the failure

Returns: nothing, or the failure

ExpectEqual<T>

pub func ExpectEqual<T: Display>(
    actual: T,
    expected: T
) -> ! TestFailure

Fails unless actual equals expected, saying both.

Source

Type parameters

NameDescription
T: Displaya type with == that can be displayed

Parameters

NameTypeDescription
actualTwhat the code gave
expectedTwhat it should have given

Returns: nothing, or the failure

ExpectNotEqual<T>

pub func ExpectNotEqual<T: Display>(
    actual: T,
    unexpected: T
) -> ! TestFailure

Fails if actual equals unexpected.

Source

Type parameters

NameDescription
T: Displaya type with == that can be displayed

Parameters

NameTypeDescription
actualTwhat the code gave
unexpectedTwhat it should not have given

Returns: nothing, or the failure

ExpectNear

pub func ExpectNear(
    actual: float64,
    expected: float64,
    tolerance: float64
) -> ! TestFailure

Fails unless actual is within tolerance of expected.

Source

Parameters

NameTypeDescription
actualfloat64what the code gave
expectedfloat64what it should have given
tolerancefloat64how far apart they may be

Returns: nothing, or the failure

ExpectText

pub func ExpectText(
    actual: char8[..],
    expected: char8[..]
) -> ! TestFailure

Fails unless actual is the same text as expected, saying at which byte they part and showing each around it.

Source

Parameters

NameTypeDescription
actualchar8[..]what the code gave
expectedchar8[..]what it should have given

Returns: nothing, or the failure

ExpectSome<T>

pub func ExpectSome<T>(
    value: T?,
    message: char8[..]
) -> T ! TestFailure

The value of value, failing when there is none.

Source

Type parameters

NameDescription
Tthe value's type

Parameters

NameTypeDescription
valueT?the optional value
messagechar8[..]what its absence means, for the failure

Returns: the value, or the failure

ExpectNone<T>

pub func ExpectNone<T>(
    value: T?,
    message: char8[..]
) -> ! TestFailure

Fails when value is present.

Source

Type parameters

NameDescription
Tthe value's type

Parameters

NameTypeDescription
valueT?the optional value
messagechar8[..]what its presence means, for the failure

Returns: nothing, or the failure

ExpectSuccess<T, E>

pub func ExpectSuccess<T, E>(
    outcome: T ! E,
    message: char8[..]
) -> T ! TestFailure

The success of outcome, failing when it failed.

Source

Type parameters

NameDescription
Tthe success's type
Ethe failure's type

Parameters

NameTypeDescription
outcomeT ! Ewhat the code gave
messagechar8[..]what its failure means, for the test's failure

Returns: the success, or the failure

ExpectFailure<T, E>

pub func ExpectFailure<T, E>(
    outcome: T ! E,
    message: char8[..]
) -> E ! TestFailure

The failure of outcome, failing the test when it succeeded.

Source

Type parameters

NameDescription
Tthe success's type
Ethe failure's type

Parameters

NameTypeDescription
outcomeT ! Ewhat the code gave
messagechar8[..]what its success means, for the test's failure

Returns: the failure the code gave, or the test's failure