...
1
2
3
4
5
6
7 package main
8
9 func main() {
10 mapSize()
11 }
12
13 func mapSize() {
14
15 const tooBigFor32 = 1<<33 - 1
16 wantPanic(
17 func() {
18 _ = make(map[int]int, int64(tooBigFor32))
19 },
20 "runtime error: ssa.MakeMap.Reserve value 8589934591 does not fit in int",
21 )
22
23
24
25
26
27
28
29 }
30
31 func wantPanic(fn func(), s string) {
32 defer func() {
33 err := recover()
34 if err == nil {
35 panic("expected panic")
36 }
37 if got := err.(error).Error(); got != s {
38 panic("expected panic " + s + " got " + got)
39 }
40 }()
41 fn()
42 }
43
View as plain text