// Shared helpers for named tests in this package.
///|
fn assert_true(value : Bool) -> Unit raise {
if !value {
fail("expected true")
}
}
///|
fn assert_false(value : Bool) -> Unit raise {
if value {
fail("expected false")
}
}
///|
fn assert_str_eq(actual : String, expected : String) -> Unit raise {
if actual != expected {
fail("expected '\{expected}', got '\{actual}'")
}
}
///|
fn assert_int_eq(actual : Int, expected : Int) -> Unit raise {
if actual != expected {
fail("expected \{expected}, got \{actual}")
}
}
///|
fn unwrap_file(r : Result[RobotsFile, RobotsError]) -> RobotsFile raise {
match r {
Ok(v) => v
Err(e) => fail("expected Ok, got \{e.to_display()}")
}
}
///|
fn unwrap_decision(
r : Result[AccessDecision, RobotsError],
) -> AccessDecision raise {
match r {
Ok(v) => v
Err(e) => fail("expected Ok, got \{e.to_display()}")
}
}
///|
fn[T] expect_err_kind(
r : Result[T, RobotsError],
kind : RobotsErrorKind,
) -> Unit raise {
match r {
Ok(_) => fail("expected error \{kind.to_string()}")
Err(e) =>
if e.kind() != kind {
fail("expected \{kind.to_string()}, got \{e.to_display()}")
}
}
}