blob: 3f4e3d1ae6fa9adf095afe91e176daa3708fe86b [file] [log] [blame]
Brent Austinba3052e2015-04-21 16:08:23 -07001// run
2
3// Copyright 2009 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
7// Test typed integer constants.
8
9package main
10
11import "fmt"
12
13type T int
14
15func (t T) String() string { return fmt.Sprintf("T%d", int(t)) }
16
17const (
18 A T = 1 << (1 << iota)
19 B
20 C
21 D
22 E
23)
24
25func main() {
26 s := fmt.Sprintf("%v %v %v %v %v", A, B, C, D, E)
27 if s != "T2 T4 T16 T256 T65536" {
28 println("type info didn't propagate in const: got", s)
29 panic("fail")
30 }
31 x := uint(5)
32 y := float64(uint64(1)<<x) // used to fail to compile
33 if y != 32 {
34 println("wrong y", y)
35 panic("fail")
36 }
37}