3 // Copyright 2014 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 order of calls to builtin functions.
8 // Discovered during CL 144530045 review.
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 {
20 println("append call not ordered:", len(a), b, len(c))
27 f := func() int { x = make([]int, 3); return 2 }
28 a, b, c := cap(x), f(), cap(x)
31 println("cap call not ordered:", a, b, c)
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 {
42 println("complex call not ordered:", a, b, c)
48 tmp := make([]int, 100)
50 f := func() int { x = make([]int, 3); return 2 }
51 a, b, c := copy(tmp, x), f(), copy(tmp, x)
54 println("copy call not ordered:", a, b, c)
61 f := func() int { x = 3i; return 2 }
62 a, b, c := imag(x), f(), imag(x)
65 println("imag call not ordered:", a, b, c)
72 f := func() int { x = make([]int, 3); return 2 }
73 a, b, c := len(x), f(), len(x)
76 println("len call not ordered:", a, b, c)
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 {
87 println("make call not ordered:", len(a), b, len(c))
94 f := func() int { x = 3; return 2 }
95 a, b, c := real(x), f(), real(x)
98 println("real call not ordered:", a, b, c)