blob: a7c4e0c464eaa4b4d5245ec309134003dce3f0fa [file] [log] [blame]
Colin Cross7bb052a2015-02-03 12:59:37 -08001// run
2
3// Copyright 2010 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.
6
7package main
8
9type I interface {
10 m(a, b, c, d, e, f, g, h byte)
11}
12
13type Int8 int8
14
15func (x Int8) m(a, b, c, d, e, f, g, h byte) {
16 check("Int8", int64(x), 0x01, a, b, c, d, e, f, g, h)
17}
18
19type Uint8 uint8
20
21func (x Uint8) m(a, b, c, d, e, f, g, h byte) {
22 check("Uint8", int64(x), 0x01, a, b, c, d, e, f, g, h)
23}
24
25type Int16 int16
26
27func (x Int16) m(a, b, c, d, e, f, g, h byte) {
28 check("Int16", int64(x), 0x0102, a, b, c, d, e, f, g, h)
29}
30
31type Uint16 uint16
32
33func (x Uint16) m(a, b, c, d, e, f, g, h byte) {
34 check("Uint16", int64(x), 0x0102, a, b, c, d, e, f, g, h)
35}
36
37type Int32 int32
38
39func (x Int32) m(a, b, c, d, e, f, g, h byte) {
40 check("Int32", int64(x), 0x01020304, a, b, c, d, e, f, g, h)
41}
42
43type Uint32 uint32
44
45func (x Uint32) m(a, b, c, d, e, f, g, h byte) {
46 check("Uint32", int64(x), 0x01020304, a, b, c, d, e, f, g, h)
47}
48
49type Int64 int64
50
51func (x Int64) m(a, b, c, d, e, f, g, h byte) {
52 check("Int64", int64(x), 0x0102030405060708, a, b, c, d, e, f, g, h)
53}
54
55type Uint64 uint64
56
57func (x Uint64) m(a, b, c, d, e, f, g, h byte) {
58 check("Uint64", int64(x), 0x0102030405060708, a, b, c, d, e, f, g, h)
59}
60
61var test = []I{
62 Int8(0x01),
63 Uint8(0x01),
64 Int16(0x0102),
65 Uint16(0x0102),
66 Int32(0x01020304),
67 Uint32(0x01020304),
68 Int64(0x0102030405060708),
69 Uint64(0x0102030405060708),
70}
71
72func main() {
73 for _, t := range test {
74 t.m(0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17)
75 }
76}
77
78var bug = false
79
80func check(desc string, have, want int64, a, b, c, d, e, f, g, h byte) {
81 if have != want || a != 0x10 || b != 0x11 || c != 0x12 || d != 0x13 || e != 0x14 || f != 0x15 || g != 0x16 || h != 0x17 {
82 if !bug {
83 bug = true
84 println("BUG")
85 }
86 println(desc, "check", have, want, a, b, c, d, e, f, g, h)
87 }
88}