A fluent assertion library for MoonBit
Dependencies
moon add moonrockz/expectimport {
"moonrockz/expect",
} for "test"test "basic assertions" {
// Equality
@expect.expect(1 + 1).to_equal(2)
@expect.expect(1).to_not_equal(2)
// Booleans
@expect.expect(true).to_be_true()
@expect.expect(false).to_be_false()
// Ordering (any type that implements Compare)
@expect.expect(5).to_be_greater_than(3)
@expect.expect(5).to_be_greater_than_or_equal(5)
@expect.expect(3).to_be_less_than(5)
@expect.expect(3).to_be_less_than_or_equal(3)
@expect.expect(3).to_be_between(1, 5) // inclusive
@expect.expect(4).to_be_between(1, 5, high_inclusive=false)
// Signs (Int, Int16, Int64, UInt, UInt16, UInt64, Double, Float)
@expect.expect(3).to_be_positive()
@expect.expect(-3).to_be_negative()
@expect.expect(0).to_be_zero()
// Floating-point numbers (Double and Float)
@expect.expect(0.1 + 0.2).to_be_close_to(0.3) // default tolerance 1e-9
@expect.expect(1.0).to_be_close_to(1.05, tolerance=0.1) // absolute
@expect.expect(1000.0).to_be_close_to(1001.0, relative=0.01) // 1%
@expect.expect(1.0).to_be_close_to(1.0000000000000002, ulps=1)
@expect.expect(0.0 / 0.0).to_be_nan()
@expect.expect(1.0).to_be_finite()
// Options
@expect.expect(Some(42)).to_be_some()
@expect.expect((None : Int?)).to_be_none()
// Results
let ok : Result[Int, String] = Ok(1)
@expect.expect(ok).to_be_ok()
@expect.expect((Err("boom") : Result[Int, String])).to_be_err()
// Strings
@expect.expect("hello world").to_contain("world")
@expect.expect("hello world").to_start_with("hello")
@expect.expect("hello world").to_end_with("world")
@expect.expect("order 42").to_match("[[:digit:]]+") // regex search
@expect.expect("42").to_match_fully("[[:digit:]]+") // whole string
@expect.expect("Hello").to_equal_ignoring_case("hello")
@expect.expect("a b\nc").to_equal_ignoring_whitespace("abc")
@expect.expect(" \t").to_be_blank()
@expect.expect("a-b-c").to_contain_times("-", 2)
@expect.expect("one two three").to_contain_substrings_in_order(["one", "three"])
// Arrays
@expect.expect([1, 2, 3]).to_contain_element(2)
@expect.expect([1, 2, 3]).to_contain_all([3, 1])
@expect.expect([3, 1, 2]).to_equal_ignoring_order([1, 2, 3])
@expect.expect([2, 4, 6]).to_all_satisfy(x => x % 2 == 0)
@expect.expect([1, 2, 3]).to_contain_exactly([1, 2, 3]) // same order
@expect.expect([1, 2, 2]).to_contain_only([2, 1]) // any order, repeats allowed
@expect.expect([1, 2, 3]).to_contain_in_order([1, 3]) // gaps allowed
@expect.expect([1, 2, 3]).to_start_with_elements([1, 2])
@expect.expect([1, 2, 3]).to_end_with_elements([3])
@expect.expect([1, 2, 3]).to_contain_none_of([4, 5])
@expect.expect([1, 2, 3]).to_any_satisfy(x => x > 2)
@expect.expect([1, 2, 3]).to_none_satisfy(x => x > 3)
@expect.expect([1, 2, 3, 4]).to_have_count_satisfying(2, x => x % 2 == 0)
@expect.expect([1, 2, 2]).to_be_sorted()
@expect.expect(["a", "bb"]).to_be_sorted_by(s => s.length())
@expect.expect([1, 2, 3]).to_have_no_duplicates()
@expect.expect([1, 5]).to_satisfy_respectively([
it => it.to_equal(1),
it => it.to_be_greater_than(2),
])
// Maps
@expect.expect({ "a": 1 }).to_contain_key("a")
@expect.expect({ "a": 1 }).to_contain_value(1)
@expect.expect({ "a": 1, "b": 2 }).to_contain_entry("a", 1)
@expect.expect({ "a": 1, "b": 2 }).to_contain_entries({ "b": 2 })
// Length (String, Array, Map, Set, views, Deque, List, and the other core collections)
@expect.expect("").to_be_empty()
@expect.expect([1, 2, 3]).to_have_length(3)
// Any value
@expect.expect(4).to_satisfy(x => x % 2 == 0, description="is even")
@expect.expect(2).to_be_one_of([1, 2, 3])
@expect.expect(2).to_be_in(Set([1, 2, 3]))
// Chars (ASCII, except to_be_whitespace)
@expect.expect('7').to_be_digit()
@expect.expect('a').to_be_letter()
@expect.expect(' ').to_be_whitespace()
@expect.expect('A').to_be_upper_case()
@expect.expect('a').to_be_lower_case()
}@expect.expect(3).not().to_equal(5)
@expect.expect([1, 2]).not().to_be_empty()@expect.expect(Some(42)).unwrap_some().to_be_greater_than(40)
@expect.expect(parse("1")).unwrap_ok().to_equal(1)
@expect.expect(parse("x")).unwrap_err().to_equal(ParseError::Invalid)// Fails with: user.address.city: expect(received).to_equal(expected) ...
@expect.expect(user, label="user")
.get("address", u => u.address)
.get("city", a => a.city)
.to_equal("Paris")| Method | On | Returns an expectation on | Fails when |
|---|---|---|---|
| get(name, f) | any value | f(value) | never |
| element(i) | Array | the element at index i | i is out of range |
| first(), last() | Array | the first or last element | the array is empty |
| single() | Array | the only element | the array does not have exactly one element |
| value_at(key) | Map | the value for key | the key is missing |
| fst(), snd() | pair | the first or second part | never |
@expect.expect(age).to(@expect.all_of([
@expect.satisfying(a => a >= 18, description=">= 18"),
@expect.is_not(@expect.equal_to(99)),
]))
@expect.expect(users).to_contain_element_matching(
@expect.field("name", u => u.name, @expect.equal_to("Ada")),
)| Function | Matches values that |
|---|---|
| equal_to(x) | equal x |
| satisfying(pred, description?) | satisfy pred |
| field(name, f, m) | give a result that matches m when you apply f |
| all_of([m1, m2]) | match every matcher |
| any_of([m1, m2]) | match at least one matcher |
| is_not(m) | do not match m |
| matching(description, block) | pass the method matchers in block |
@expect.expect(users).to_contain_element_matching(
@expect.field("age", u => u.age, @expect.matching("an adult", it => {
it.to_be_greater_than_or_equal(18)
})),
)expect(received).to(matcher)
Expected: all of (> 1, < 5, even)
Received: 7
Mismatch:
< 5: was 7
even: was 7pub fn even() -> @expect.Matcher[Int] {
{
describe: () => "even",
check: x => if x % 2 == 0 { None } else { Some("was odd") },
}
}import {
"moonrockz/expect",
"moonrockz/expect/with_source",
} for "test"@with_source.expect(user.age + 1).to_equal(20)expect(user.age + 1).to_equal(expected)
Expected: 20
Received: 18test "order summary" {
// Inline snapshot of the `Show` output. `--update` fills in `content`.
inspect(summary(order), content="3 items, $12.50")
// Inline snapshot of the `Debug` output, for any type that derives Debug.
@debug.debug_inspect(order.items, content="...")
}
test "report" (it : @test.T) {
// File snapshot, stored in __snapshot__/report.txt.
it.writeln(render_report(data))
it.snapshot(filename="report.txt")
}@expect.for_all((xs : Array[Int]) => {
@expect.expect(xs.rev().rev()).to_equal(xs)
})for_all(property) failed after 3 test(s)
Counterexample: 50
Shrinks: 26 successful, 37 attempted
Failure:
src/math_test.mbt:3:46-3:75@me/app: expect(received).to_be_less_than(expected)
Expected: < 50
Received: 50import {
"moonrockz/expect",
"moonrockz/expect/async_expect",
} for "test"async test "worker drains the queue" {
start_worker(queue)
@async_expect.eventually(() => @expect.expect(queue.length()).to_equal(0))
// timeout=1000 and interval=50 milliseconds by default
}eventually(block) did not pass within 1000 ms (20 attempts)
Last failure:
src/worker_test.mbt:3:45-3:78@me/app: expect(received).to_equal(expected)
Expected: 0
Received: 2@expect.expect_all(s => {
s.expect(user.name).to_equal("Ada")
s.expect(user.age).to_be_greater_than(18)
s.expect(user.tags).first().to_equal("admin")
})2 of 3 assertions failed
(1) src/user_test.mbt:12:3-12:40@me/app: expect(received).to_equal(expected)
Expected: "Ada"
Received: "Bob"
(2) src/user_test.mbt:13:3-13:45@me/app: expect(received).to_be_greater_than(expected)
Expected: > 18
Received: 17@expect.expect(saved).to_be_equivalent_to(
draft,
excluding=["id", "items[*].id"], // skip these paths; [*] matches any index
ignoring_order=true, // compare arrays as multisets, at every depth
tolerance=0.01, // numbers may differ by up to 0.01
)expect(received).to_be_equivalent_to(expected)
Expected: equivalent to { id: 1, owner: "Ada", balance: { cents: 1050 } }
Received: { id: 1, owner: "Ada", balance: { cents: 1005 } }
Differences:
balance.cents: expected 1050, received 1005@expect.expect(age).all(it => {
it.to_be_greater_than(0)
it.to_be_less_than(150)
})@expect.expect_call(() => parse("x")).to_raise()
@expect.expect_call(() => parse("x")).to_raise(containing="invalid")
@expect.expect_call(() => parse("1")).not().to_raise()
// Check the type of the error with an `is` pattern
@expect.expect_call(() => parse("x")).to_raise_matching(
e => e is ParseError::Invalid(_),
description="an Invalid error",
)
// Chain on the error or on the returned value
@expect.expect_call(() => parse("x")).to_raise_error().message().to_contain("invalid")
@expect.expect_call(() => parse("1")).to_return().to_equal(1)let order : Json = { "id": 7, "items": [{ "sku": "A1", "qty": 2 }] }
@expect.expect(order).at("items[0].sku").to_equal("A1")
@expect.expect(order).to_contain_json({ "items": [{ "qty": 2 }] })expect(received).at(path)
Expected: a value at "items[3].sku"
Received: {"id":7,"items":[{"sku":"A1","qty":2}]}
Found: items is an array of length 1// Fails with: user id: expect(received).to_equal(expected) ...
@expect.expect(3, label="user id").to_equal(5)// Fails with:
// retries: expect(received).to_equal(expected)
// Expected: 4
// Received: 3
// Because: the client retries three times
@expect.expect(3, label="retries")
.because("the client retries three times")
.to_equal(4)@expect.expect_elements(deque.iter()).to_contain_element(3)
@expect.expect_elements(sorted_set.iter()).first().to_equal(1)struct Bag {
items : Array[Int]
} derive(Debug)
impl @expect.HasLength for Bag with length(self) {
self.items.length()
}#callsite(autofill(loc))
fn @expect.Expectation::to_be_even(
self : @expect.Expectation[Int],
loc~ : SourceLoc,
) -> Unit raise Error {
self.assert_that(
self.actual % 2 == 0,
"to_be_even",
expected=() => "an even number",
received=() => @debug.to_string(self.actual),
loc~,
)
}
test "custom matcher" {
@expect.expect(4).to_be_even()
@expect.expect(3).not().to_be_even()
}expect(received).to_be_even()
Expected: an even number
Received: 3test "to_be_even message" {
inspect(
@expect.failure_message(() => @expect.expect(3).to_be_even()),
content=(
#|expect(received).to_be_even()
#|Expected: an even number
#|Received: 3
),
)
@expect.expect_failure(() => @expect.expect(3).to_be_even())
.to_contain("Expected: an even number")
}src/point_test.mbt:10:3-10:58@me/app FAILED: expect(received).to_equal(expected)
Expected: { x: 1, y: 3 }
Received: { x: 1, y: 2 }
Diff (- expected, + received):
@@ -1,4 +1,4 @@
{
x: 1,
- y: 3,
+ y: 2,
? ^
}Expected: "hello world"
Received: "hello wurld"
^ first difference at index 7struct Point {
x : Int
y : Int
} derive(Eq, Debug)| Constructor | Use it to |
|---|---|
| Repr::record(map) | show a struct with the fields you choose, in your order |
| Repr::ctor(name, args) | show a constructor such as Money(1050) |
| Repr::literal(text) | show text as it is, without quotes, such as $10.50 |
| Repr::omitted() | hide a value, shown as ... |
| Repr::opaque_(name, repr) | show a wrapped value, such as <Id: 42> |
| Repr(value) | use the Debug output of a field |
struct Money {
cents : Int
} derive(Eq)
impl @debug.Debug for Money with fn to_repr(self) {
let dollars = self.cents / 100
let cents = self.cents % 100
let padding = if cents < 10 { "0" } else { "" }
Repr::literal("$\{dollars}.\{padding}\{cents}")
}
struct Account {
owner : String
password : String
balance : Money
} derive(Eq)
impl @debug.Debug for Account with fn to_repr(self) {
Repr::record({
"owner": Repr(self.owner),
"password": Repr::omitted(),
"balance": Repr(self.balance),
})
}expect(received).to_equal(expected)
Expected: { owner: "Ada", password: ..., balance: $10.50 }
Received: { owner: "Ada", password: ..., balance: $10.05 }
Diff (- expected, + received):
@@ -1,5 +1,5 @@
{
owner: "Ada",
password: ...,
- balance: $10.50,
+ balance: $10.05,
? ^^
}pub trait FloatingPoint {
fn as_double(Self) -> Double
fn ulp_distance(Self, Self) -> UInt64
fn describe(Self) -> String
}pub(open) trait HasLength {
fn length(Self) -> Int
}impl HasLength for FixedArray[T]fn[T] length(self : FixedArray[T]) -> Intimpl HasLength for PriorityQueue[T]impl HasLength for PriorityQueue[T]impl HasLength for StringViewfn length(self : StringView) -> Intpub struct Expectation[T] {
actual : T
negated : Bool
label : String
reason : String
scope : Scope?
source : () -> String?
}#callsite(autofill(loc))
fn[T] Expectation::all(self : Expectation[T], block : (Expectation[T]) -> Unit raise, loc~ : SourceLoc) -> Unit raisefn[T] Expectation::assert_that(self : Expectation[T], pass : Bool, matcher : String, expected~ : () -> String, received~ : () -> String, args? : String, details? : () -> Array[(String, String)], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::at(self : Expectation[Json], path : String, loc~ : SourceLoc) -> Expectation[Json] raise#callsite(autofill(loc))
fn[T : Debug] Expectation::element(self : Expectation[Array[T]], index : Int, loc~ : SourceLoc) -> Expectation[T] raise#callsite(autofill(loc))
fn[T : Debug] Expectation::first(self : Expectation[Array[T]], loc~ : SourceLoc) -> Expectation[T] raise#callsite(autofill(loc))
fn[A, B] Expectation::fst(self : Expectation[(A, B)], loc~ : SourceLoc) -> Expectation[A] raise#callsite(autofill(loc))
fn[T, U] Expectation::get(self : Expectation[T], name : String, f : (T) -> U, loc~ : SourceLoc) -> Expectation[U] raise#callsite(autofill(loc))
fn[T : Debug] Expectation::last(self : Expectation[Array[T]], loc~ : SourceLoc) -> Expectation[T] raise#callsite(autofill(loc))
fn[T : Debug] Expectation::single(self : Expectation[Array[T]], loc~ : SourceLoc) -> Expectation[T] raise#callsite(autofill(loc))
fn[A, B] Expectation::snd(self : Expectation[(A, B)], loc~ : SourceLoc) -> Expectation[B] raise#callsite(autofill(loc))
fn[T : Debug] Expectation::to(self : Expectation[T], matcher : Matcher[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug] Expectation::to_all_satisfy(self : Expectation[Array[T]], predicate : (T) -> Bool, description? : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug] Expectation::to_any_satisfy(self : Expectation[Array[T]], predicate : (T) -> Bool, description? : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Compare + Debug + Eq] Expectation::to_be_between(self : Expectation[T], low : T, high : T, low_inclusive? : Bool, high_inclusive? : Bool, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_be_blank(self : Expectation[String], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[F : FloatingPoint] Expectation::to_be_close_to(self : Expectation[F], expected : F, tolerance? : Double, relative? : Double, ulps? : Int, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_be_digit(self : Expectation[Char], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[C : HasLength + Debug] Expectation::to_be_empty(self : Expectation[C], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
#deprecated("Use `to_be_empty` instead")
fn Expectation::to_be_empty_string(self : Expectation[String], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug] Expectation::to_be_equivalent_to(self : Expectation[T], expected : T, excluding? : Array[String], ignoring_order? : Bool, tolerance? : Double, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug, E : Debug] Expectation::to_be_err(self : Expectation[Result[T, E]], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_be_false(self : Expectation[Bool], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[F : FloatingPoint] Expectation::to_be_finite(self : Expectation[F], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Compare + Debug + Eq] Expectation::to_be_greater_than(self : Expectation[T], other : T, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Compare + Debug + Eq] Expectation::to_be_greater_than_or_equal(self : Expectation[T], other : T, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Hash + Eq + Debug] Expectation::to_be_in(self : Expectation[T], set : Set[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Compare + Debug + Eq] Expectation::to_be_less_than(self : Expectation[T], other : T, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Compare + Debug + Eq] Expectation::to_be_less_than_or_equal(self : Expectation[T], other : T, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_be_letter(self : Expectation[Char], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_be_lower_case(self : Expectation[Char], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[F : FloatingPoint] Expectation::to_be_nan(self : Expectation[F], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Number + Debug + Compare + Eq] Expectation::to_be_negative(self : Expectation[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug] Expectation::to_be_none(self : Expectation[T?], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug, E : Debug] Expectation::to_be_ok(self : Expectation[Result[T, E]], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_be_one_of(self : Expectation[T], values : Array[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Number + Debug + Compare + Eq] Expectation::to_be_positive(self : Expectation[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T] Expectation::to_be_some(self : Expectation[T?], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Compare + Debug + Eq] Expectation::to_be_sorted(self : Expectation[Array[T]], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug, K : Compare + Eq] Expectation::to_be_sorted_by(self : Expectation[Array[T]], key : (T) -> K, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_be_true(self : Expectation[Bool], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_be_upper_case(self : Expectation[Char], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_be_whitespace(self : Expectation[Char], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Number + Debug + Compare + Eq] Expectation::to_be_zero(self : Expectation[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_contain(self : Expectation[String], substring : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_contain_all(self : Expectation[Array[T]], elements : Array[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_contain_element(self : Expectation[Array[T]], element : T, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug] Expectation::to_contain_element_matching(self : Expectation[Array[T]], matcher : Matcher[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[K : Hash + Eq + Debug, V : Eq + Debug] Expectation::to_contain_entries(self : Expectation[Map[K, V]], expected : Map[K, V], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[K : Hash + Eq + Debug, V : Eq + Debug] Expectation::to_contain_entry(self : Expectation[Map[K, V]], key : K, value : V, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_contain_exactly(self : Expectation[Array[T]], expected : Array[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_contain_in_order(self : Expectation[Array[T]], expected : Array[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_contain_json(self : Expectation[Json], expected : Json, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[K : Hash + Eq + Debug, V : Debug] Expectation::to_contain_key(self : Expectation[Map[K, V]], key : K, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_contain_none_of(self : Expectation[Array[T]], values : Array[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_contain_only(self : Expectation[Array[T]], expected : Array[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_contain_substrings_in_order(self : Expectation[String], parts : Array[String], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_contain_times(self : Expectation[String], text : String, count : Int, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[K : Debug, V : Eq + Debug] Expectation::to_contain_value(self : Expectation[Map[K, V]], value : V, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_end_with(self : Expectation[String], suffix : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_end_with_elements(self : Expectation[Array[T]], suffix : Array[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_equal(self : Expectation[T], expected : T, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_equal_ignoring_case(self : Expectation[String], expected : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_equal_ignoring_order(self : Expectation[Array[T]], expected : Array[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_equal_ignoring_whitespace(self : Expectation[String], expected : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug] Expectation::to_have_count_satisfying(self : Expectation[Array[T]], count : Int, predicate : (T) -> Bool, description? : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[C : HasLength + Debug] Expectation::to_have_length(self : Expectation[C], expected : Int, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
#deprecated("Use `to_have_length` instead")
fn Expectation::to_have_length_string(self : Expectation[String], expected : Int, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_have_no_duplicates(self : Expectation[Array[T]], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_match(self : Expectation[String], pattern : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_match_fully(self : Expectation[String], pattern : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug] Expectation::to_none_satisfy(self : Expectation[Array[T]], predicate : (T) -> Bool, description? : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_not_equal(self : Expectation[T], other : T, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T] Expectation::to_raise(self : Expectation[() -> T raise], containing? : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T] Expectation::to_raise_error(self : Expectation[() -> T raise], loc~ : SourceLoc) -> Expectation[Error] raise#callsite(autofill(loc))
fn[T] Expectation::to_raise_matching(self : Expectation[() -> T raise], predicate : (Error) -> Bool, description? : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T] Expectation::to_return(self : Expectation[() -> T raise], loc~ : SourceLoc) -> Expectation[T] raise#callsite(autofill(loc))
fn[T : Debug] Expectation::to_satisfy(self : Expectation[T], predicate : (T) -> Bool, description? : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug] Expectation::to_satisfy_respectively(self : Expectation[Array[T]], checks : Array[(Expectation[T]) -> Unit raise], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn Expectation::to_start_with(self : Expectation[String], prefix : String, loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Eq + Debug] Expectation::to_start_with_elements(self : Expectation[Array[T]], prefix : Array[T], loc~ : SourceLoc) -> Unit raise#callsite(autofill(loc))
fn[T : Debug, E] Expectation::unwrap_err(self : Expectation[Result[T, E]], loc~ : SourceLoc) -> Expectation[E] raise#callsite(autofill(loc))
fn[T, E : Debug] Expectation::unwrap_ok(self : Expectation[Result[T, E]], loc~ : SourceLoc) -> Expectation[T] raise#callsite(autofill(loc))
fn[T] Expectation::unwrap_some(self : Expectation[T?], loc~ : SourceLoc) -> Expectation[T] raise#callsite(autofill(loc))
fn[K : Hash + Eq + Debug, V : Debug] Expectation::value_at(self : Expectation[Map[K, V]], key : K, loc~ : SourceLoc) -> Expectation[V] raisepub(all) struct Matcher[T] {
describe : () -> String
check : (T) -> String?
}pub struct Scope {
// private fields
}fn[T] Scope::expect_call(self : Scope, f : () -> T raise, label? : String) -> Expectation[() -> T raise]fn[T] expect_call(f : () -> T raise, label? : String, source? : () -> String) -> Expectation[() -> T raise]#callsite(autofill(loc))
fn expect_failure(f : () -> Unit raise, label? : String, loc~ : SourceLoc) -> Expectation[String] raiseInstall
Download zipA fluent assertion library for MoonBit
Dependencies