3 // Copyright 2011 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.
7 // Test reordering of assignments.
33 func check(x []int, x0, x1, x2 int) {
34 if x[0] != x0 || x[1] != x1 || x[2] != x2 {
35 fmt.Printf("%v, want %d,%d,%d\n", x, x0, x1, x2)
40 func check3(x, y, z, xx, yy, zz int) {
41 if x != xx || y != yy || z != zz {
42 fmt.Printf("%d,%d,%d, want %d,%d,%d\n", x, y, z, xx, yy, zz)
67 x[1], y[0] = f(0), f(1)
75 x[1], y[0] = gx[0], gx[1]
95 check3(x, y, z, 2, 1, 3)
98 func f1(x, y, z int) (xx, yy, zz int) {
102 func f2() (x, y, z int) {
108 check3(x, y, z, 2, 1, 3)
112 m := make(map[int]int)
119 // Issue #13433: Left-to-right assignment of OAS2XXX nodes.
125 checkOAS2XXX(x, "x, x = fn()")
128 var c = make(chan bool, 10)
131 checkOAS2XXX(x, "x, x <-c")
134 var m = map[int]bool{0: false}
136 checkOAS2XXX(x, "x, x = m[0]")
139 var i interface{} = false
141 checkOAS2XXX(x, "x, x = i.(bool)")
145 func fn() (bool, bool) { return false, true }
147 // checks the order of OAS2XXX.
148 func checkOAS2XXX(x bool, s string) {
150 fmt.Printf("%s; got=(false); want=(true)\n", s)
156 func fp() (*int, int) { return nil, 42 }