]> Cypherpunks.ru repositories - gostls13.git/blob - test/func8.go
test: explanatory comments [c-g]*
[gostls13.git] / test / func8.go
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
9 package main
10
11 var calledf int
12
13 func f() int {
14         calledf++
15         return 0
16 }
17
18 func g() int {
19         return calledf
20 }
21
22 var xy string
23
24 func x() bool {
25         for false {
26         } // no inlining
27         xy += "x"
28         return false
29 }
30
31 func y() string {
32         for false {
33         } // no inlining
34         xy += "y"
35         return "abc"
36 }
37
38 func main() {
39         if f() == g() {
40                 println("wrong f,g order")
41         }
42
43         if x() == (y() == "abc") {
44                 panic("wrong compare")
45         }
46         if xy != "xy" {
47                 println("wrong x,y order")
48         }
49 }