Rémy Oudompheng | 2ece2f5 | 2012-02-18 22:15:42 +0100 | [diff] [blame] | 1 | // run |
Ian Lance Taylor | b1e8b5f | 2008-11-17 12:19:02 -0800 | [diff] [blame] | 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 | |
Rob Pike | 80a9783 | 2012-02-24 11:48:19 +1100 | [diff] [blame] | 7 | // Test var x = x + 1 works. |
| 8 | |
Ian Lance Taylor | b1e8b5f | 2008-11-17 12:19:02 -0800 | [diff] [blame] | 9 | package main |
| 10 | |
| 11 | func main() { |
Russ Cox | 00f9f0c | 2010-03-30 10:34:57 -0700 | [diff] [blame] | 12 | var x int = 1 |
| 13 | if x != 1 { |
| 14 | print("found ", x, ", expected 1\n") |
| 15 | panic("fail") |
Rob Pike | 74dd0ab | 2009-08-17 13:30:22 -0700 | [diff] [blame] | 16 | } |
| 17 | { |
Russ Cox | 00f9f0c | 2010-03-30 10:34:57 -0700 | [diff] [blame] | 18 | var x int = x + 1 |
| 19 | if x != 2 { |
| 20 | print("found ", x, ", expected 2\n") |
| 21 | panic("fail") |
| 22 | } |
| 23 | } |
| 24 | { |
| 25 | x := x + 1 |
| 26 | if x != 2 { |
| 27 | print("found ", x, ", expected 2\n") |
| 28 | panic("fail") |
| 29 | } |
Rob Pike | 74dd0ab | 2009-08-17 13:30:22 -0700 | [diff] [blame] | 30 | } |
Ian Lance Taylor | b1e8b5f | 2008-11-17 12:19:02 -0800 | [diff] [blame] | 31 | } |