| 1 |
[short] skip |
| 2 |
|
| 3 |
# Control |
| 4 |
! go test example2_test.go example1_test.go |
| 5 |
|
| 6 |
# This test only passes if the source order is preserved |
| 7 |
go test example1_test.go example2_test.go |
| 8 |
|
| 9 |
-- example1_test.go -- |
| 10 |
// Copyright 2013 The Go Authors. All rights reserved. |
| 11 |
// Use of this source code is governed by a BSD-style |
| 12 |
// license that can be found in the LICENSE file. |
| 13 |
|
| 14 |
// Make sure that go test runs Example_z before Example_a, preserving source order. |
| 15 |
|
| 16 |
package p |
| 17 |
|
| 18 |
import "fmt" |
| 19 |
|
| 20 |
var n int |
| 21 |
|
| 22 |
func Example_z() { |
| 23 |
n++ |
| 24 |
fmt.Println(n) |
| 25 |
// Output: 1 |
| 26 |
} |
| 27 |
|
| 28 |
func Example_a() { |
| 29 |
n++ |
| 30 |
fmt.Println(n) |
| 31 |
// Output: 2 |
| 32 |
} |
| 33 |
-- example2_test.go -- |
| 34 |
// Copyright 2013 The Go Authors. All rights reserved. |
| 35 |
// Use of this source code is governed by a BSD-style |
| 36 |
// license that can be found in the LICENSE file. |
| 37 |
|
| 38 |
// Make sure that go test runs Example_y before Example_b, preserving source order. |
| 39 |
|
| 40 |
package p |
| 41 |
|
| 42 |
import "fmt" |
| 43 |
|
| 44 |
func Example_y() { |
| 45 |
n++ |
| 46 |
fmt.Println(n) |
| 47 |
// Output: 3 |
| 48 |
} |
| 49 |
|
| 50 |
func Example_b() { |
| 51 |
n++ |
| 52 |
fmt.Println(n) |
| 53 |
// Output: 4 |
| 54 |
} |