1
2
3
4
5
6
7
8
9
10 package main
11
12 func main() {
13
14 {
15 x := make([]int, 0)
16 f := func() int { x = make([]int, 2); return 2 }
17 a, b, c := append(x, 1), f(), append(x, 1)
18 if len(a) != 1 || len(c) != 3 {
19 bug()
20 println("append call not ordered:", len(a), b, len(c))
21 }
22 }
23
24
25 {
26 x := make([]int, 1)
27 f := func() int { x = make([]int, 3); return 2 }
28 a, b, c := cap(x), f(), cap(x)
29 if a != 1 || c != 3 {
30 bug()
31 println("cap call not ordered:", a, b, c)
32 }
33 }
34
35
36 {
37 x := 1.0
38 f := func() int { x = 3; return 2 }
39 a, b, c := complex(x, 0), f(), complex(x, 0)
40 if real(a) != 1 || real(c) != 3 {
41 bug()
42 println("complex call not ordered:", a, b, c)
43 }
44 }
45
46
47 {
48 tmp := make([]int, 100)
49 x := make([]int, 1)
50 f := func() int { x = make([]int, 3); return 2 }
51 a, b, c := copy(tmp, x), f(), copy(tmp, x)
52 if a != 1 || c != 3 {
53 bug()
54 println("copy call not ordered:", a, b, c)
55 }
56 }
57
58
59 {
60 x := 1i
61 f := func() int { x = 3i; return 2 }
62 a, b, c := imag(x), f(), imag(x)
63 if a != 1 || c != 3 {
64 bug()
65 println("imag call not ordered:", a, b, c)
66 }
67 }
68
69
70 {
71 x := make([]int, 1)
72 f := func() int { x = make([]int, 3); return 2 }
73 a, b, c := len(x), f(), len(x)
74 if a != 1 || c != 3 {
75 bug()
76 println("len call not ordered:", a, b, c)
77 }
78 }
79
80
81 {
82 x := 1
83 f := func() int { x = 3; return 2 }
84 a, b, c := make([]int, x), f(), make([]int, x)
85 if len(a) != 1 || len(c) != 3 {
86 bug()
87 println("make call not ordered:", len(a), b, len(c))
88 }
89 }
90
91
92 {
93 x := 1 + 0i
94 f := func() int { x = 3; return 2 }
95 a, b, c := real(x), f(), real(x)
96 if a != 1 || c != 3 {
97 bug()
98 println("real call not ordered:", a, b, c)
99 }
100 }
101 }
102
103 var bugged = false
104
105 func bug() {
106 if !bugged {
107 println("BUG")
108 bugged = true
109 }
110 }
View as plain text