| // Copyright 2020 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // Make sure runtime.panicmakeslice* are called. |
| // Test typechecking passes if len is valid |
| // but cap is out of range for len's type. |
| capOutOfRange := func() { |
| lenOutOfRange := func() { |
| {capOutOfRange, "cap out of range"}, |
| {lenOutOfRange, "len out of range"}, |
| for _, tc := range tests { |
| shouldPanic(tc.panicStr, tc.f) |
| func shouldPanic(str string, f func()) { |
| runtimeErr := err.(error).Error() |
| if !strings.Contains(runtimeErr, str) { |
| panic("got panic " + runtimeErr + ", want " + str) |