1 [short] skip
2
3 # Check that it's okay for test pattern to match only examples.
4 go test -run Example example1_test.go
5 ! stderr '^ok.*\[no tests to run\]'
6 stdout '^ok'
7
8 -- example1_test.go --
9 // Copyright 2013 The Go Authors. All rights reserved.
10 // Use of this source code is governed by a BSD-style
11 // license that can be found in the LICENSE file.
12
13 // Make sure that go test runs Example_Z before Example_A, preserving source order.
14
15 package p
16
17 import "fmt"
18
19 var n int
20
21 func Example_Z() {
22 n++
23 fmt.Println(n)
24 // Output: 1
25 }
26
27 func Example_A() {
28 n++
29 fmt.Println(n)
30 // Output: 2
31 }
32
View as plain text