refactor(tinyssert): move NewDisabledAssertions definition closer to disabledAssertions
This commit is contained in:
@@ -230,14 +230,6 @@ type helperT interface {
|
||||
Helper()
|
||||
}
|
||||
|
||||
// Creates a new implementation of Assertions that always return true, with the exception
|
||||
// of [Assertions.Fail] and [Assertions.FailNow] which returns false, and [Assertions.CallerInfo]
|
||||
// which returns the actual caller info (uses [CallerInfo] underlying). It is useful it you use
|
||||
// assertions in production and want to disable them without changing any code.
|
||||
func NewDisabledAssertions() Assertions {
|
||||
return &disabledAssertions{}
|
||||
}
|
||||
|
||||
type assertions struct {
|
||||
panic bool
|
||||
|
||||
@@ -528,6 +520,14 @@ func isTest(name, prefix string) bool {
|
||||
|
||||
type disabledAssertions struct{}
|
||||
|
||||
// Creates a new implementation of Assertions that always return true, with the exception
|
||||
// of [Assertions.Fail] and [Assertions.FailNow] which returns false, and [Assertions.CallerInfo]
|
||||
// which returns the actual caller info (uses [CallerInfo] underlying). It is useful it you use
|
||||
// assertions in production and want to disable them without changing any code.
|
||||
func NewDisabledAssertions() Assertions {
|
||||
return &disabledAssertions{}
|
||||
}
|
||||
|
||||
func (*disabledAssertions) OK(any, ...any) bool { return true }
|
||||
func (*disabledAssertions) Equal(_, _ any, _ ...any) bool { return true }
|
||||
func (*disabledAssertions) NotEqual(_, _ any, _ ...any) bool { return true }
|
||||
|
||||
Reference in New Issue
Block a user