3 // Copyright 2020 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Make sure runtime.panicmakeslice* are called.
14 // Test typechecking passes if len is valid
15 // but cap is out of range for len's type.
17 _ = make([]int, x, 300)
19 capOutOfRange := func() {
21 s := make([]int, i, 1)
24 lenOutOfRange := func() {
26 s := make([]int, i, 3)
34 {capOutOfRange, "cap out of range"},
35 {lenOutOfRange, "len out of range"},
38 for _, tc := range tests {
39 shouldPanic(tc.panicStr, tc.f)
44 func shouldPanic(str string, f func()) {
47 runtimeErr := err.(error).Error()
48 if !strings.Contains(runtimeErr, str) {
49 panic("got panic " + runtimeErr + ", want " + str)