-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Description
Go version
go version go1.25.5 darwin/arm64
Output of go env in your module/workspace:
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/laurent/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/laurent/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/x0/dt1r4xs14t90401t6q70ptn40000gn/T/go-build4044326039=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/laurent/code/personal/github.com/lvjp/s3hobby/s3libs/go.mod'
GOMODCACHE='/Users/laurent/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/laurent/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.25.5/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/laurent/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.25.5/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.5'
GOWORK='/Users/laurent/code/personal/github.com/lvjp/s3hobby/go.work'
PKG_CONFIG='pkg-config'What did you do?
A non-pointer value of a type that implements quick.Generator should have his interface called.
I expect that none of those tests should fail: https://go.dev/play/p/kImtXi-sQK4
What did you see happen?
=== RUN TestQuickGenerator
=== RUN TestQuickGenerator/plain
prog_test.go:60: #1: failed on input 4601851300195147788
=== RUN TestQuickGenerator/pointer
=== RUN TestQuickGenerator/struct
prog_test.go:60: #1: failed on input main.MyStruct{Plain:4601851300195147788, Pointer:(*main.MyType)(0xc0000127d0)}
=== RUN TestQuickGenerator/struct_pointer
prog_test.go:60: #2: failed on input &main.MyStruct{Plain:-5205285703879964783, Pointer:(*main.MyType)(0xc000012840)}
--- FAIL: TestQuickGenerator (0.00s)
--- FAIL: TestQuickGenerator/plain (0.00s)
--- PASS: TestQuickGenerator/pointer (0.00s)
--- FAIL: TestQuickGenerator/struct (0.00s)
--- FAIL: TestQuickGenerator/struct_pointer (0.00s)
FAIL
What did you expect to see?
All tests PASS
=== RUN TestQuickGenerator
=== RUN TestQuickGenerator/plain
=== RUN TestQuickGenerator/pointer
=== RUN TestQuickGenerator/struct
=== RUN TestQuickGenerator/struct_pointer
--- PASS: TestQuickGenerator (0.00s)
--- PASS: TestQuickGenerator/plain (0.00s)
--- PASS: TestQuickGenerator/pointer (0.00s)
--- PASS: TestQuickGenerator/struct (0.00s)
--- PASS: TestQuickGenerator/struct_pointer (0.00s)
PASS
I noticed that this output can be done with a little patch at testing/quick/quick.go :
func sizedValue(t reflect.Type, rand *rand.Rand, size int) (value reflect.Value, ok bool) {
if m, ok := reflect.Zero(t).Interface().(Generator); ok {
return m.Generate(rand, size), true
+ } else if m, ok := reflect.New(t).Interface().(Generator); ok {
+ return reflect.Indirect(m.Generate(rand, size)), true
}Metadata
Metadata
Assignees
Labels
No labels