PropertyHelper¶
Per-sample helper for property-based tests.
Each instance is scoped to a single sample. Classification calls
(classify, tabulate, cover) count toward that sample, and
complete/expect_action/complete_action complete the sample,
not the overall test.
Public fields¶
let env: Env val¶
Public Functions¶
classify¶
Tag this sample with label for distribution reporting.
Parameters¶
- label: String val
Returns¶
- None val
collect¶
Classify this sample by the string representation of value.
Parameters¶
- value: Stringable box
Returns¶
- None val
tabulate¶
Record label under heading for cross-tabulation reporting.
Parameters¶
Returns¶
- None val
cover¶
Record whether condition holds for label. The property fails
if fewer than min_pct percent of samples satisfy the condition.
The default min_pct of 0.0 reports coverage without enforcing it.
Parameters¶
Returns¶
- None val
log¶
Log a message. When verbose is true, the message is only shown
in verbose output mode.
Parameters¶
Returns¶
- None val
fail¶
Flag this sample as having failed.
Parameters¶
- msg: String val = "Test failed"
Returns¶
- None val
assert_true¶
Assert that actual is true.
Parameters¶
Returns¶
- Bool val
assert_false¶
Assert that actual is false.
fun box assert_false(
actual: Bool val,
msg: String val = "",
loc: SourceLoc val = __loc)
: Bool val
Parameters¶
Returns¶
- Bool val
assert_error¶
Assert that test throws an error when called.
Parameters¶
Returns¶
- Bool val
assert_no_error¶
Assert that test does not throw an error when called.
fun box assert_no_error(
test: ITest box,
msg: String val = "",
loc: SourceLoc val = __loc)
: Bool val
Parameters¶
Returns¶
- Bool val
assert_is[A: A]¶
Assert that expect and actual are the same instance.
fun box assert_is[A: A](
expect: A,
actual: A,
msg: String val = "",
loc: SourceLoc val = __loc)
: Bool val
Parameters¶
Returns¶
- Bool val
assert_isnt[A: A]¶
Assert that not_expect and actual are different instances.
fun box assert_isnt[A: A](
not_expect: A,
actual: A,
msg: String val = "",
loc: SourceLoc val = __loc)
: Bool val
Parameters¶
Returns¶
- Bool val
assert_eq[A: (Equatable[A] #read & Stringable #read)]¶
Assert that expect and actual are equal.
fun box assert_eq[A: (Equatable[A] #read & Stringable #read)](
expect: A,
actual: A,
msg: String val = "",
loc: SourceLoc val = __loc)
: Bool val
Parameters¶
Returns¶
- Bool val
assert_ne[A: (Equatable[A] #read & Stringable #read)]¶
Assert that not_expect and actual are not equal.
fun box assert_ne[A: (Equatable[A] #read & Stringable #read)](
not_expect: A,
actual: A,
msg: String val = "",
loc: SourceLoc val = __loc)
: Bool val
Parameters¶
Returns¶
- Bool val
assert_array_eq[A: (Equatable[A] #read & Stringable #read)]¶
Assert that the contents of expect and actual are equal.
fun box assert_array_eq[A: (Equatable[A] #read & Stringable #read)](
expect: ReadSeq[A] box,
actual: ReadSeq[A] box,
msg: String val = "",
loc: SourceLoc val = __loc)
: Bool val
Parameters¶
Returns¶
- Bool val
assert_array_eq_unordered[A: (Equatable[A] #read & Stringable #read)]¶
Assert that the contents of expect and actual are equal
regardless of order.
fun box assert_array_eq_unordered[A: (Equatable[A] #read & Stringable #read)](
expect: ReadSeq[A] box,
actual: ReadSeq[A] box,
msg: String val = "",
loc: SourceLoc val = __loc)
: Bool val
Parameters¶
Returns¶
- Bool val
long_test¶
Switch this property to async mode. Each sample runs until
complete is called or timeout nanoseconds elapse.
Parameters¶
- timeout: U64 val
Returns¶
- None val
complete¶
Complete this sample. Only needed for async properties
(those that call long_test).
Parameters¶
- success: Bool val
Returns¶
- None val
expect_action¶
Register an expected action for this sample. All expected actions must complete before the sample finishes.
Parameters¶
- name: String val
Returns¶
- None val
complete_action¶
Mark an expected action as successfully completed for this sample.
Parameters¶
- name: String val
Returns¶
- None val
fail_action¶
Mark an action as failed for this sample. The sample fails immediately.
Parameters¶
- name: String val
Returns¶
- None val
dispose_when_done¶
Pass an actor to be disposed when this sample finishes.
Parameters¶
- disposable: DisposableActor tag
Returns¶
- None val