aboutsummaryrefslogtreecommitdiff
path: root/src/sync/map_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/sync/map_test.go')
-rw-r--r--src/sync/map_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/sync/map_test.go b/src/sync/map_test.go
index 1eb3fc68a5..20872f3b72 100644
--- a/src/sync/map_test.go
+++ b/src/sync/map_test.go
@@ -5,6 +5,7 @@
package sync_test
import (
+ "internal/testenv"
"math/rand"
"reflect"
"runtime"
@@ -280,3 +281,16 @@ func TestCompareAndSwap_NonExistingKey(t *testing.T) {
t.Fatalf("CompareAndSwap on an non-existing key succeeded")
}
}
+
+func TestMapRangeNoAllocations(t *testing.T) { // Issue 62404
+ testenv.SkipIfOptimizationOff(t)
+ var m sync.Map
+ allocs := testing.AllocsPerRun(10, func() {
+ m.Range(func(key, value any) bool {
+ return true
+ })
+ })
+ if allocs > 0 {
+ t.Errorf("AllocsPerRun of m.Range = %v; want 0", allocs)
+ }
+}