diff --git a/goose_std.go b/goose_std.go index 9de7e16..987231e 100644 --- a/goose_std.go +++ b/goose_std.go @@ -6,6 +6,13 @@ import ( "github.com/goose-lang/primitive" ) +// Assert(b) panics if b doesn't hold +func Assert(b bool) { + if !b { + panic("assertion failure") + } +} + // BytesEqual returns if the two byte slices are equal. func BytesEqual(x []byte, y []byte) bool { xlen := len(x) diff --git a/goose_std_test.go b/goose_std_test.go index e657628..265089d 100644 --- a/goose_std_test.go +++ b/goose_std_test.go @@ -6,6 +6,13 @@ import ( "github.com/stretchr/testify/assert" ) +func TestAssert(t *testing.T) { + Assert(true) + assert.Panics(t, func() { + Assert(false) + }) +} + func TestBytesEqual(t *testing.T) { assert := assert.New(t)