Repository navigation
New matchers
Three new matchers from Wave 1 of the Hamcrest parity backlog:
is.Anything[A any]()
Always passes regardless of the actual value. Useful as a placeholder in composite matchers where one position is a "don't care".
then.AssertThat(t, result, is.Anything[string]())
// Handy inside has.EveryElement when some positions are unchecked
then.AssertThat(t, items, has.EveryElement(
is.EqualTo("first"),
is.Anything[string](),
))is.SameInstance[A comparable](expected)
Passes when actual == expected (pointer/reference identity). For pointer types this checks same object in memory, not just equal value.
x := &MyStruct{V: 1}
y := x
z := &MyStruct{V: 1}
then.AssertThat(t, y, is.SameInstance(x)) // passes
then.AssertThat(t, z, is.SameInstance(x)) // fails — different pointeris.Zero[A any]()
Passes when actual is the zero value for its type: 0, "", false, nil pointer, zero struct, etc. Correctly handles the Go typed-nil trap — a (*MyError)(nil) stored as error is not zero, consistent with == nil semantics.
then.AssertThat(t, 0, is.Zero[int]())
then.AssertThat(t, "", is.Zero[string]())
then.AssertThat(t, false, is.Zero[bool]())Notes
All three matchers clear match.Actual on each invocation so they compose correctly inside is.AllOf() and then.Eventually() without leaving stale diagnostic output from a prior failure.