OxL Reference

fn assert_fails

Test helper (§18.2): passes when x is an error of type E, i.e. assert_fails(parse(text), ParseError); otherwise the test fails and shows the value. x is a value of a union type that has E as a member (the call is written with the error type as a second argument, which the compiler turns into the generic argument E).

Example:

oxl✓ checked in CI
use std.core { ParseError }

test "parse rejects text" {
  assert_fails("x".parseInt(), ParseError)
}
@intrinsic("test.assertFails") pub(api) fn assert_fails<E, T>(x: T)

Since. 1.0.0-beta

Parameters

NameType
xT

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/functions.oxl:148

See also