3 // Copyright 2019 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.
11 var tests = []interface{}{
12 func(x int, s int) int {
15 func(x int, s int64) int {
18 func(x int, s int32) int {
21 func(x int, s int16) int {
24 func(x int, s int8) int {
27 func(x int, s int) int {
30 func(x int, s int64) int {
33 func(x int, s int32) int {
36 func(x int, s int16) int {
39 func(x int, s int8) int {
42 func(x uint, s int) uint {
45 func(x uint, s int64) uint {
48 func(x uint, s int32) uint {
51 func(x uint, s int16) uint {
54 func(x uint, s int8) uint {
57 func(x uint, s int) uint {
60 func(x uint, s int64) uint {
63 func(x uint, s int32) uint {
66 func(x uint, s int16) uint {
69 func(x uint, s int8) uint {
75 for _, t := range tests {
76 runTest(reflect.ValueOf(t))
80 func runTest(f reflect.Value) {
84 for _, x := range []int{1, 0, -1} {
85 for _, s := range []int{-99, -64, -63, -32, -31, -16, -15, -8, -7, -1, 0, 1, 7, 8, 15, 16, 31, 32, 63, 64, 99} {
86 args := []reflect.Value{
87 reflect.ValueOf(x).Convert(xt),
88 reflect.ValueOf(s).Convert(st),
95 f.Call(args) // should not panic
101 func shouldPanic(f func()) {
103 if recover() == nil {
104 panic("did not panic")