...

Text file src/cmd/go/testdata/script/test_match_only_example.txt

Documentation: cmd/go/testdata/script

     1[short] skip
     2
     3# Check that it's okay for test pattern to match only examples.
     4go test -run Example example1_test.go
     5! stderr '^ok.*\[no tests to run\]'
     6stdout '^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
    15package p
    16
    17import "fmt"
    18
    19var n int
    20
    21func Example_Z() {
    22	n++
    23	fmt.Println(n)
    24	// Output: 1
    25}
    26
    27func Example_A() {
    28	n++
    29	fmt.Println(n)
    30	// Output: 2
    31}

View as plain text