]> Cypherpunks repositories - gostls13.git/commitdiff
testing: document example with unordered output
authorAlexander Döring <email@alexd.ch>
Mon, 10 Apr 2017 18:57:45 +0000 (20:57 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 10 Apr 2017 19:55:45 +0000 (19:55 +0000)
Copy the documentation and example from cmd/go.

Fixes #18840.

Change-Id: Id8022762b48576fb4031de05287d07a6ed23f480
Reviewed-on: https://go-review.googlesource.com/37440
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/testing/testing.go

index 130977f106cc4fd354a6c062bbd5d0a2e2d9681b..e5a3c3b93c1be70061ac07ac05d7b2490986a0df 100644 (file)
 // ignores leading and trailing space.) These are examples of an example:
 //
 //     func ExampleHello() {
-//             fmt.Println("hello")
-//             // Output: hello
+//         fmt.Println("hello")
+//         // Output: hello
 //     }
 //
 //     func ExampleSalutations() {
-//             fmt.Println("hello, and")
-//             fmt.Println("goodbye")
-//             // Output:
-//             // hello, and
-//             // goodbye
+//         fmt.Println("hello, and")
+//         fmt.Println("goodbye")
+//         // Output:
+//         // hello, and
+//         // goodbye
+//     }
+//
+// The comment prefix "Unordered output:" is like "Output:", but matches any
+// line order:
+//
+//     func ExamplePerm() {
+//         for _, value := range Perm(4) {
+//             fmt.Println(value)
+//         }
+//         // Unordered output: 4
+//         // 2
+//         // 1
+//         // 3
+//         // 0
 //     }
 //
 // Example functions without output comments are compiled but not executed.