diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-01-25 21:54:22 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-01-25 21:54:22 +0000 |
commit | 476d22b59304cb6f5820c2644763a2ce43874a41 (patch) | |
tree | c8e8990a2197e33f6fe50a28a16714aafe982102 /libgo/go/testing | |
parent | 422eaae5fe0038ad189b8fd28cfd6a7094d67ae1 (diff) | |
download | gcc-476d22b59304cb6f5820c2644763a2ce43874a41.tar.gz |
libgo: Update to weekly.2012-01-20.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183540 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/testing')
-rw-r--r-- | libgo/go/testing/example.go | 7 | ||||
-rw-r--r-- | libgo/go/testing/testing.go | 30 |
2 files changed, 29 insertions, 8 deletions
diff --git a/libgo/go/testing/example.go b/libgo/go/testing/example.go index fdeda137e76..7f8ff2d0541 100644 --- a/libgo/go/testing/example.go +++ b/libgo/go/testing/example.go @@ -25,13 +25,6 @@ func RunExamples(examples []InternalExample) (ok bool) { var eg InternalExample stdout, stderr := os.Stdout, os.Stderr - defer func() { - os.Stdout, os.Stderr = stdout, stderr - if e := recover(); e != nil { - fmt.Printf("--- FAIL: %s\npanic: %v\n", eg.Name, e) - os.Exit(1) - } - }() for _, eg = range examples { if *chatty { diff --git a/libgo/go/testing/testing.go b/libgo/go/testing/testing.go index cfe212dc1d7..f1acb97e1b6 100644 --- a/libgo/go/testing/testing.go +++ b/libgo/go/testing/testing.go @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. // Package testing provides support for automated testing of Go packages. -// It is intended to be used in concert with the ``gotest'' utility, which automates +// It is intended to be used in concert with the ``go test'' command, which automates // execution of any function of the form // func TestXxx(*testing.T) // where Xxx can be any alphanumeric string (but the first letter must not be in @@ -21,6 +21,7 @@ // fmt.Sprintf("hello") // } // } +// // The benchmark package will vary b.N until the benchmark function lasts // long enough to be timed reliably. The output // testing.BenchmarkHello 10000000 282 ns/op @@ -36,6 +37,33 @@ // big.Len() // } // } +// +// The package also runs and verifies example code. Example functions +// include an introductory comment that is compared with the standard output +// of the function when the tests are run, as in this example of an example: +// +// // hello +// func ExampleHello() { +// fmt.Println("hello") +// } +// +// Example functions without comments are compiled but not executed. +// +// The naming convention to declare examples for a function F, a type T and +// method M on type T are: +// +// func ExampleF() { ... } +// func ExampleT() { ... } +// func ExampleT_M() { ... } +// +// Multiple example functions for a type/function/method may be provided by +// appending a distinct suffix to the name. The suffix must start with a +// lower-case letter. +// +// func ExampleF_suffix() { ... } +// func ExampleT_suffix() { ... } +// func ExampleT_M_suffix() { ... } +// package testing import ( |