blob: 84a4a1aa55cd58cf2169b1c2b83ec517d67f6a26 [file] [log] [blame]
Rémy Oudompheng2ece2f52012-02-18 22:15:42 +01001// run
Ian Lance Taylorb1e8b5f2008-11-17 12:19:02 -08002
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 Pike80a97832012-02-24 11:48:19 +11007// Test var x = x + 1 works.
8
Ian Lance Taylorb1e8b5f2008-11-17 12:19:02 -08009package main
10
11func main() {
Russ Cox00f9f0c2010-03-30 10:34:57 -070012 var x int = 1
13 if x != 1 {
14 print("found ", x, ", expected 1\n")
15 panic("fail")
Rob Pike74dd0ab2009-08-17 13:30:22 -070016 }
17 {
Russ Cox00f9f0c2010-03-30 10:34:57 -070018 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 Pike74dd0ab2009-08-17 13:30:22 -070030 }
Ian Lance Taylorb1e8b5f2008-11-17 12:19:02 -080031}