Skip to content

PropertyHelper

[Source]

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.

class val PropertyHelper

Public fields

let env: Env val

[Source]


Public Functions

classify

[Source]

Tag this sample with label for distribution reporting.

fun box classify(
  label: String val)
: None val

Parameters

Returns


collect

[Source]

Classify this sample by the string representation of value.

fun box collect(
  value: Stringable box)
: None val

Parameters

Returns


tabulate

[Source]

Record label under heading for cross-tabulation reporting.

fun box tabulate(
  heading: String val,
  label: String val)
: None val

Parameters

Returns


cover

[Source]

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.

fun box cover(
  condition: Bool val,
  label: String val,
  min_pct: F64 val = 0.0)
: None val

Parameters

Returns


log

[Source]

Log a message. When verbose is true, the message is only shown in verbose output mode.

fun box log(
  msg: String val,
  verbose: Bool val = false)
: None val

Parameters

Returns


fail

[Source]

Flag this sample as having failed.

fun box fail(
  msg: String val = "Test failed")
: None val

Parameters

  • msg: String val = "Test failed"

Returns


assert_true

[Source]

Assert that actual is true.

fun box assert_true(
  actual: Bool val,
  msg: String val = "",
  loc: SourceLoc val = __loc)
: Bool val

Parameters

Returns


assert_false

[Source]

Assert that actual is false.

fun box assert_false(
  actual: Bool val,
  msg: String val = "",
  loc: SourceLoc val = __loc)
: Bool val

Parameters

Returns


assert_error

[Source]

Assert that test throws an error when called.

fun box assert_error(
  test: ITest box,
  msg: String val = "",
  loc: SourceLoc val = __loc)
: Bool val

Parameters

Returns


assert_no_error

[Source]

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


assert_is[A: A]

[Source]

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


assert_isnt[A: A]

[Source]

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


assert_eq[A: (Equatable[A] #read & Stringable #read)]

[Source]

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


assert_ne[A: (Equatable[A] #read & Stringable #read)]

[Source]

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


assert_array_eq[A: (Equatable[A] #read & Stringable #read)]

[Source]

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


assert_array_eq_unordered[A: (Equatable[A] #read & Stringable #read)]

[Source]

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


long_test

[Source]

Switch this property to async mode. Each sample runs until complete is called or timeout nanoseconds elapse.

fun box long_test(
  timeout: U64 val)
: None val

Parameters

  • timeout: U64 val

Returns


complete

[Source]

Complete this sample. Only needed for async properties (those that call long_test).

fun box complete(
  success: Bool val)
: None val

Parameters

Returns


expect_action

[Source]

Register an expected action for this sample. All expected actions must complete before the sample finishes.

fun box expect_action(
  name: String val)
: None val

Parameters

Returns


complete_action

[Source]

Mark an expected action as successfully completed for this sample.

fun box complete_action(
  name: String val)
: None val

Parameters

Returns


fail_action

[Source]

Mark an action as failed for this sample. The sample fails immediately.

fun box fail_action(
  name: String val)
: None val

Parameters

Returns


dispose_when_done

[Source]

Pass an actor to be disposed when this sample finishes.

fun box dispose_when_done(
  disposable: DisposableActor tag)
: None val

Parameters

Returns