func AbortsContains
AbortsContains requires that the code inside the specified func aborts (panics when crossing another realm) and the abort message contains the specified substring. See uassert.AbortsWithMessage for `rlm` semantics.
v0 - Unaudited: This is an initial version that has not yet been formally audited. A fully audited version will be pu...
v0 - Unaudited This is an initial version of this package that has not yet been formally audited. A fully audited version will be published as a subsequent release. Use in production at your own risk.
urequire - fail-fast test assertionsSister package to uassert. Same assertions, but each one calls t.FailNow() on failure so the test stops immediately instead of continuing.
1import (
2 "testing"
3
4 "gno.land/p/nt/urequire/v0"
5)
6
7func TestPipeline(t *testing.T) {
8 out, err := Build()
9 urequire.NoError(t, err) // aborts the test if Build failed
10 urequire.NotNil(t, out) // out is safe to dereference below
11 urequire.Equal(t, "ready", out.Status)
12}
Helpers take uassert.TestingT and return nothing — they either pass or stop the test.
Equality and emptiness:
1func Equal(t uassert.TestingT, expected, actual any, msgs ...string)
2func NotEqual(t uassert.TestingT, expected, actual any, msgs ...string)
3func Empty(t uassert.TestingT, obj any, msgs ...string)
4func NotEmpty(t uassert.TestingT, obj any, msgs ...string)
Truthiness and nil:
1func True(t uassert.TestingT, value bool, msgs ...string)
2func False(t uassert.TestingT, value bool, msgs ...string)
3func Nil(t uassert.TestingT, value any, msgs ...string)
4func NotNil(t uassert.TestingT, value any, msgs ...string)
5func TypedNil(t uassert.TestingT, value any, msgs ...string)
6func NotTypedNil(t uassert.TestingT, value any, msgs ...string)
Errors:
1func NoError(t uassert.TestingT, err error, msgs ...string)
2func Error(t uassert.TestingT, err error, msgs ...string)
3func ErrorContains(t uassert.TestingT, err error, contains string, msgs ...string)
4func ErrorIs(t uassert.TestingT, err, target error, msgs ...string)
Panics and aborts (f may be func() or func(realm); pass the test's own cur as rlm):
1func PanicsWithMessage(t uassert.TestingT, rlm realm, msg string, f any, msgs ...string)
2func PanicsContains(t uassert.TestingT, rlm realm, substr string, f any, msgs ...string)
3func NotPanics(t uassert.TestingT, rlm realm, f any, msgs ...string)
4func AbortsWithMessage(t uassert.TestingT, rlm realm, msg string, f any, msgs ...string)
5func AbortsContains(t uassert.TestingT, rlm realm, substr string, f any, msgs ...string)
6func NotAborts(t uassert.TestingT, rlm realm, f any, msgs ...string)
urequire when the rest of the test depends on the assertion holding (e.g. a nil check before dereferencing). Use uassert when you want to collect multiple failures from the same test run.urequire helper is a thin wrapper that calls the matching uassert helper and then t.FailNow() on failure.v0 - Unaudited: This is an initial version that has not yet been formally audited. A fully audited version will be published as a subsequent release. Use in production at your own risk.
Package urequire provides test assertion functions that immediately fail the test on error, complementing the uassert package.
urequire is a sister package for uassert. XXX: codegen the package.
AbortsContains requires that the code inside the specified func aborts (panics when crossing another realm) and the abort message contains the specified substring. See uassert.AbortsWithMessage for `rlm` semantics.
AbortsWithMessage requires that the code inside the specified func aborts (panics when crossing another realm). Use PanicsWithMessage for requiring local panics within the same realm. Note: This relies on gno's `revive` mechanism to catch aborts. See uassert.AbortsWithMessage for `rlm` semantics.
Empty requires that the specified object is empty (zero value, empty string/slice/map, or nil).
Equal requires that two objects are equal.
Error requires that a function returned an error (i.e. not `nil`).
ErrorContains requires that a function returned an error (i.e. not `nil`) and that the error contains the specified substring.
ErrorIs requires that the given error matches the target error.
False requires that the specified value is false.
Nil requires that the value is nil.
NoError requires that a function returned no error (i.e. `nil`).
NotAborts requires that the code inside the specified func does NOT abort when crossing an execution boundary (e.g., VM call). Use NotPanics for requiring the absence of local panics within the same realm. Note: This relies on Gno's `revive` mechanism. See uassert.AbortsWithMessage for `rlm` semantics.
NotEmpty requires that the specified object is not empty.
NotEqual requires that two objects are not equal.
NotNil requires that the value is not nil.
NotPanics requires that the code inside the specified func does NOT panic locally within the same execution realm. Use NotAborts for requiring the absence of panics that cross execution boundaries (aborts). See uassert.AbortsWithMessage for `rlm` semantics.
NotTypedNil requires that the value is not a typed-nil (nil pointer) value.
PanicsContains requires that the code inside the specified func panics locally within the same execution realm and the panic message contains the specified substring. See uassert.AbortsWithMessage for `rlm` semantics.
PanicsWithMessage requires that the code inside the specified func panics locally within the same execution realm. Use AbortsWithMessage for requiring panics that cross execution boundaries (aborts). See uassert.AbortsWithMessage for `rlm` semantics.
True requires that the specified value is true.
TypedNil requires that the value is a typed-nil (nil pointer) value.