diff options
author | Keith Randall <khr@golang.org> | 2022-04-19 08:55:04 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2022-04-19 17:05:22 +0000 |
commit | 689dc17793991746eb27ba4520d45af19a661f98 (patch) | |
tree | 8f2376323df5a59b96bb0408295d8b070c078b2c | |
parent | 0670afa1b3aaed740816c5ffc9825d154c47d188 (diff) | |
download | go-689dc17793991746eb27ba4520d45af19a661f98.tar.gz go-689dc17793991746eb27ba4520d45af19a661f98.zip |
reflect: adjust MapRange allocation test for noopt builder
Change-Id: I55899ff0ed2c3c01f24ab1ccf133ce4236049e39
Reviewed-on: https://go-review.googlesource.com/c/go/+/401074
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
-rw-r--r-- | src/reflect/all_test.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index f7adf2fa1a..f18df4e6c5 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -11,6 +11,7 @@ import ( "fmt" "go/token" "internal/goarch" + "internal/testenv" "io" "math" "math/rand" @@ -373,8 +374,12 @@ func TestMapIterSet(t *testing.T) { // Calling MapRange should not allocate even though it returns a *MapIter. // The function is inlineable, so if the local usage does not escape // the *MapIter, it can remain stack allocated. - if got != 0 { - t.Errorf("wanted 0 alloc, got %d", got) + want := 0 + if strings.HasSuffix(testenv.Builder(), "-noopt") { + want = 1 // no inlining with the noopt builder + } + if got != want { + t.Errorf("wanted %d alloc, got %d", want, got) } } |