bump gomega to 1.29.0
This commit is contained in:
49
vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go
generated
vendored
49
vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go
generated
vendored
@@ -7,6 +7,7 @@ package cmpopts
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"time"
|
||||
@@ -16,10 +17,10 @@ import (
|
||||
|
||||
func equateAlways(_, _ interface{}) bool { return true }
|
||||
|
||||
// EquateEmpty returns a Comparer option that determines all maps and slices
|
||||
// EquateEmpty returns a [cmp.Comparer] option that determines all maps and slices
|
||||
// with a length of zero to be equal, regardless of whether they are nil.
|
||||
//
|
||||
// EquateEmpty can be used in conjunction with SortSlices and SortMaps.
|
||||
// EquateEmpty can be used in conjunction with [SortSlices] and [SortMaps].
|
||||
func EquateEmpty() cmp.Option {
|
||||
return cmp.FilterValues(isEmpty, cmp.Comparer(equateAlways))
|
||||
}
|
||||
@@ -31,7 +32,7 @@ func isEmpty(x, y interface{}) bool {
|
||||
(vx.Len() == 0 && vy.Len() == 0)
|
||||
}
|
||||
|
||||
// EquateApprox returns a Comparer option that determines float32 or float64
|
||||
// EquateApprox returns a [cmp.Comparer] option that determines float32 or float64
|
||||
// values to be equal if they are within a relative fraction or absolute margin.
|
||||
// This option is not used when either x or y is NaN or infinite.
|
||||
//
|
||||
@@ -45,7 +46,7 @@ func isEmpty(x, y interface{}) bool {
|
||||
//
|
||||
// |x-y| ≤ max(fraction*min(|x|, |y|), margin)
|
||||
//
|
||||
// EquateApprox can be used in conjunction with EquateNaNs.
|
||||
// EquateApprox can be used in conjunction with [EquateNaNs].
|
||||
func EquateApprox(fraction, margin float64) cmp.Option {
|
||||
if margin < 0 || fraction < 0 || math.IsNaN(margin) || math.IsNaN(fraction) {
|
||||
panic("margin or fraction must be a non-negative number")
|
||||
@@ -73,10 +74,10 @@ func (a approximator) compareF32(x, y float32) bool {
|
||||
return a.compareF64(float64(x), float64(y))
|
||||
}
|
||||
|
||||
// EquateNaNs returns a Comparer option that determines float32 and float64
|
||||
// EquateNaNs returns a [cmp.Comparer] option that determines float32 and float64
|
||||
// NaN values to be equal.
|
||||
//
|
||||
// EquateNaNs can be used in conjunction with EquateApprox.
|
||||
// EquateNaNs can be used in conjunction with [EquateApprox].
|
||||
func EquateNaNs() cmp.Option {
|
||||
return cmp.Options{
|
||||
cmp.FilterValues(areNaNsF64s, cmp.Comparer(equateAlways)),
|
||||
@@ -91,8 +92,8 @@ func areNaNsF32s(x, y float32) bool {
|
||||
return areNaNsF64s(float64(x), float64(y))
|
||||
}
|
||||
|
||||
// EquateApproxTime returns a Comparer option that determines two non-zero
|
||||
// time.Time values to be equal if they are within some margin of one another.
|
||||
// EquateApproxTime returns a [cmp.Comparer] option that determines two non-zero
|
||||
// [time.Time] values to be equal if they are within some margin of one another.
|
||||
// If both times have a monotonic clock reading, then the monotonic time
|
||||
// difference will be used. The margin must be non-negative.
|
||||
func EquateApproxTime(margin time.Duration) cmp.Option {
|
||||
@@ -131,8 +132,8 @@ type anyError struct{}
|
||||
func (anyError) Error() string { return "any error" }
|
||||
func (anyError) Is(err error) bool { return err != nil }
|
||||
|
||||
// EquateErrors returns a Comparer option that determines errors to be equal
|
||||
// if errors.Is reports them to match. The AnyError error can be used to
|
||||
// EquateErrors returns a [cmp.Comparer] option that determines errors to be equal
|
||||
// if [errors.Is] reports them to match. The [AnyError] error can be used to
|
||||
// match any non-nil error.
|
||||
func EquateErrors() cmp.Option {
|
||||
return cmp.FilterValues(areConcreteErrors, cmp.Comparer(compareErrors))
|
||||
@@ -154,3 +155,31 @@ func compareErrors(x, y interface{}) bool {
|
||||
ye := y.(error)
|
||||
return errors.Is(xe, ye) || errors.Is(ye, xe)
|
||||
}
|
||||
|
||||
// EquateComparable returns a [cmp.Option] that determines equality
|
||||
// of comparable types by directly comparing them using the == operator in Go.
|
||||
// The types to compare are specified by passing a value of that type.
|
||||
// This option should only be used on types that are documented as being
|
||||
// safe for direct == comparison. For example, [net/netip.Addr] is documented
|
||||
// as being semantically safe to use with ==, while [time.Time] is documented
|
||||
// to discourage the use of == on time values.
|
||||
func EquateComparable(typs ...interface{}) cmp.Option {
|
||||
types := make(typesFilter)
|
||||
for _, typ := range typs {
|
||||
switch t := reflect.TypeOf(typ); {
|
||||
case !t.Comparable():
|
||||
panic(fmt.Sprintf("%T is not a comparable Go type", typ))
|
||||
case types[t]:
|
||||
panic(fmt.Sprintf("%T is already specified", typ))
|
||||
default:
|
||||
types[t] = true
|
||||
}
|
||||
}
|
||||
return cmp.FilterPath(types.filter, cmp.Comparer(equateAny))
|
||||
}
|
||||
|
||||
type typesFilter map[reflect.Type]bool
|
||||
|
||||
func (tf typesFilter) filter(p cmp.Path) bool { return tf[p.Last().Type()] }
|
||||
|
||||
func equateAny(x, y interface{}) bool { return x == y }
|
||||
|
16
vendor/github.com/google/go-cmp/cmp/cmpopts/ignore.go
generated
vendored
16
vendor/github.com/google/go-cmp/cmp/cmpopts/ignore.go
generated
vendored
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/google/go-cmp/cmp/internal/function"
|
||||
)
|
||||
|
||||
// IgnoreFields returns an Option that ignores fields of the
|
||||
// IgnoreFields returns an [cmp.Option] that ignores fields of the
|
||||
// given names on a single struct type. It respects the names of exported fields
|
||||
// that are forwarded due to struct embedding.
|
||||
// The struct type is specified by passing in a value of that type.
|
||||
@@ -26,7 +26,7 @@ func IgnoreFields(typ interface{}, names ...string) cmp.Option {
|
||||
return cmp.FilterPath(sf.filter, cmp.Ignore())
|
||||
}
|
||||
|
||||
// IgnoreTypes returns an Option that ignores all values assignable to
|
||||
// IgnoreTypes returns an [cmp.Option] that ignores all values assignable to
|
||||
// certain types, which are specified by passing in a value of each type.
|
||||
func IgnoreTypes(typs ...interface{}) cmp.Option {
|
||||
tf := newTypeFilter(typs...)
|
||||
@@ -59,10 +59,10 @@ func (tf typeFilter) filter(p cmp.Path) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IgnoreInterfaces returns an Option that ignores all values or references of
|
||||
// IgnoreInterfaces returns an [cmp.Option] that ignores all values or references of
|
||||
// values assignable to certain interface types. These interfaces are specified
|
||||
// by passing in an anonymous struct with the interface types embedded in it.
|
||||
// For example, to ignore sync.Locker, pass in struct{sync.Locker}{}.
|
||||
// For example, to ignore [sync.Locker], pass in struct{sync.Locker}{}.
|
||||
func IgnoreInterfaces(ifaces interface{}) cmp.Option {
|
||||
tf := newIfaceFilter(ifaces)
|
||||
return cmp.FilterPath(tf.filter, cmp.Ignore())
|
||||
@@ -107,7 +107,7 @@ func (tf ifaceFilter) filter(p cmp.Path) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IgnoreUnexported returns an Option that only ignores the immediate unexported
|
||||
// IgnoreUnexported returns an [cmp.Option] that only ignores the immediate unexported
|
||||
// fields of a struct, including anonymous fields of unexported types.
|
||||
// In particular, unexported fields within the struct's exported fields
|
||||
// of struct types, including anonymous fields, will not be ignored unless the
|
||||
@@ -115,7 +115,7 @@ func (tf ifaceFilter) filter(p cmp.Path) bool {
|
||||
//
|
||||
// Avoid ignoring unexported fields of a type which you do not control (i.e. a
|
||||
// type from another repository), as changes to the implementation of such types
|
||||
// may change how the comparison behaves. Prefer a custom Comparer instead.
|
||||
// may change how the comparison behaves. Prefer a custom [cmp.Comparer] instead.
|
||||
func IgnoreUnexported(typs ...interface{}) cmp.Option {
|
||||
ux := newUnexportedFilter(typs...)
|
||||
return cmp.FilterPath(ux.filter, cmp.Ignore())
|
||||
@@ -148,7 +148,7 @@ func isExported(id string) bool {
|
||||
return unicode.IsUpper(r)
|
||||
}
|
||||
|
||||
// IgnoreSliceElements returns an Option that ignores elements of []V.
|
||||
// IgnoreSliceElements returns an [cmp.Option] that ignores elements of []V.
|
||||
// The discard function must be of the form "func(T) bool" which is used to
|
||||
// ignore slice elements of type V, where V is assignable to T.
|
||||
// Elements are ignored if the function reports true.
|
||||
@@ -176,7 +176,7 @@ func IgnoreSliceElements(discardFunc interface{}) cmp.Option {
|
||||
}, cmp.Ignore())
|
||||
}
|
||||
|
||||
// IgnoreMapEntries returns an Option that ignores entries of map[K]V.
|
||||
// IgnoreMapEntries returns an [cmp.Option] that ignores entries of map[K]V.
|
||||
// The discard function must be of the form "func(T, R) bool" which is used to
|
||||
// ignore map entries of type K and V, where K and V are assignable to T and R.
|
||||
// Entries are ignored if the function reports true.
|
||||
|
12
vendor/github.com/google/go-cmp/cmp/cmpopts/sort.go
generated
vendored
12
vendor/github.com/google/go-cmp/cmp/cmpopts/sort.go
generated
vendored
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/google/go-cmp/cmp/internal/function"
|
||||
)
|
||||
|
||||
// SortSlices returns a Transformer option that sorts all []V.
|
||||
// SortSlices returns a [cmp.Transformer] option that sorts all []V.
|
||||
// The less function must be of the form "func(T, T) bool" which is used to
|
||||
// sort any slice with element type V that is assignable to T.
|
||||
//
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
// The less function does not have to be "total". That is, if !less(x, y) and
|
||||
// !less(y, x) for two elements x and y, their relative order is maintained.
|
||||
//
|
||||
// SortSlices can be used in conjunction with EquateEmpty.
|
||||
// SortSlices can be used in conjunction with [EquateEmpty].
|
||||
func SortSlices(lessFunc interface{}) cmp.Option {
|
||||
vf := reflect.ValueOf(lessFunc)
|
||||
if !function.IsType(vf.Type(), function.Less) || vf.IsNil() {
|
||||
@@ -82,13 +82,13 @@ func (ss sliceSorter) less(v reflect.Value, i, j int) bool {
|
||||
return ss.fnc.Call([]reflect.Value{vx, vy})[0].Bool()
|
||||
}
|
||||
|
||||
// SortMaps returns a Transformer option that flattens map[K]V types to be a
|
||||
// SortMaps returns a [cmp.Transformer] option that flattens map[K]V types to be a
|
||||
// sorted []struct{K, V}. The less function must be of the form
|
||||
// "func(T, T) bool" which is used to sort any map with key K that is
|
||||
// assignable to T.
|
||||
//
|
||||
// Flattening the map into a slice has the property that cmp.Equal is able to
|
||||
// use Comparers on K or the K.Equal method if it exists.
|
||||
// Flattening the map into a slice has the property that [cmp.Equal] is able to
|
||||
// use [cmp.Comparer] options on K or the K.Equal method if it exists.
|
||||
//
|
||||
// The less function must be:
|
||||
// - Deterministic: less(x, y) == less(x, y)
|
||||
@@ -96,7 +96,7 @@ func (ss sliceSorter) less(v reflect.Value, i, j int) bool {
|
||||
// - Transitive: if !less(x, y) and !less(y, z), then !less(x, z)
|
||||
// - Total: if x != y, then either less(x, y) or less(y, x)
|
||||
//
|
||||
// SortMaps can be used in conjunction with EquateEmpty.
|
||||
// SortMaps can be used in conjunction with [EquateEmpty].
|
||||
func SortMaps(lessFunc interface{}) cmp.Option {
|
||||
vf := reflect.ValueOf(lessFunc)
|
||||
if !function.IsType(vf.Type(), function.Less) || vf.IsNil() {
|
||||
|
4
vendor/github.com/google/go-cmp/cmp/cmpopts/xform.go
generated
vendored
4
vendor/github.com/google/go-cmp/cmp/cmpopts/xform.go
generated
vendored
@@ -19,7 +19,7 @@ func (xf xformFilter) filter(p cmp.Path) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// AcyclicTransformer returns a Transformer with a filter applied that ensures
|
||||
// AcyclicTransformer returns a [cmp.Transformer] with a filter applied that ensures
|
||||
// that the transformer cannot be recursively applied upon its own output.
|
||||
//
|
||||
// An example use case is a transformer that splits a string by lines:
|
||||
@@ -28,7 +28,7 @@ func (xf xformFilter) filter(p cmp.Path) bool {
|
||||
// return strings.Split(s, "\n")
|
||||
// })
|
||||
//
|
||||
// Had this been an unfiltered Transformer instead, this would result in an
|
||||
// Had this been an unfiltered [cmp.Transformer] instead, this would result in an
|
||||
// infinite cycle converting a string to []string to [][]string and so on.
|
||||
func AcyclicTransformer(name string, xformFunc interface{}) cmp.Option {
|
||||
xf := xformFilter{cmp.Transformer(name, xformFunc)}
|
||||
|
Reference in New Issue
Block a user