1// run 2 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. 6 7// Test evaluation order. 8 9package main 10 11var calledf int 12 13func f() int { 14 calledf++ 15 return 0 16} 17 18func g() int { 19 return calledf 20} 21 22var xy string 23 24//go:noinline 25func x() bool { 26 xy += "x" 27 return false 28} 29 30//go:noinline 31func y() string { 32 xy += "y" 33 return "abc" 34} 35 36func main() { 37 if f() == g() { 38 panic("wrong f,g order") 39 } 40 41 if x() == (y() == "abc") { 42 panic("wrong compare") 43 } 44 if xy != "xy" { 45 panic("wrong x,y order") 46 } 47} 48