| 
									
										
										
										
											2012-02-16 23:48:57 -05:00
										 |  |  | // run | 
					
						
							| 
									
										
										
										
											2009-03-12 19:04:38 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Copyright 2009 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. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-19 13:19:43 +11:00
										 |  |  | // Test typed integer constants. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-12 19:04:38 -07:00
										 |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import "fmt" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type T int | 
					
						
							| 
									
										
										
										
											2010-03-24 16:46:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-14 17:16:35 -07:00
										 |  |  | func (t T) String() string { return fmt.Sprintf("T%d", int(t)) } | 
					
						
							| 
									
										
										
										
											2009-03-12 19:04:38 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | const ( | 
					
						
							| 
									
										
										
										
											2010-03-24 16:46:53 -07:00
										 |  |  | 	A T = 1 << (1 << iota) | 
					
						
							|  |  |  | 	B | 
					
						
							|  |  |  | 	C | 
					
						
							|  |  |  | 	D | 
					
						
							|  |  |  | 	E | 
					
						
							| 
									
										
										
										
											2009-03-12 19:04:38 -07:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func main() { | 
					
						
							| 
									
										
										
										
											2010-03-24 16:46:53 -07:00
										 |  |  | 	s := fmt.Sprintf("%v %v %v %v %v", A, B, C, D, E) | 
					
						
							| 
									
										
										
										
											2009-03-12 19:04:38 -07:00
										 |  |  | 	if s != "T2 T4 T16 T256 T65536" { | 
					
						
							| 
									
										
										
										
											2010-03-24 16:46:53 -07:00
										 |  |  | 		println("type info didn't propagate in const: got", s) | 
					
						
							|  |  |  | 		panic("fail") | 
					
						
							| 
									
										
										
										
											2009-03-12 19:04:38 -07:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-12-13 13:42:51 -05:00
										 |  |  | 	x := uint(5) | 
					
						
							|  |  |  | 	y := float64(uint64(1)<<x)	// used to fail to compile | 
					
						
							|  |  |  | 	if y != 32 { | 
					
						
							|  |  |  | 		println("wrong y", y) | 
					
						
							|  |  |  | 		panic("fail") | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-12 19:04:38 -07:00
										 |  |  | } |