summaryrefslogtreecommitdiffstats
path: root/libgo/go/time/sleep_test.go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-03-16 23:05:44 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-03-16 23:05:44 +0000
commit31c6ec422702226aabab7d082da16663e6c3e72c (patch)
tree44176975832a3faf1626836e70c97d5edd674122 /libgo/go/time/sleep_test.go
parentb3145af52cfb7c84d62a8e4ceeb165a7369718da (diff)
downloadppe42-gcc-31c6ec422702226aabab7d082da16663e6c3e72c.tar.gz
ppe42-gcc-31c6ec422702226aabab7d082da16663e6c3e72c.zip
Update to current version of Go library (revision 94d654be2064).
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171076 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/time/sleep_test.go')
-rw-r--r--libgo/go/time/sleep_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/libgo/go/time/sleep_test.go b/libgo/go/time/sleep_test.go
index 9e36288f886..8bf599c3e1a 100644
--- a/libgo/go/time/sleep_test.go
+++ b/libgo/go/time/sleep_test.go
@@ -64,6 +64,18 @@ func BenchmarkAfterFunc(b *testing.B) {
<-c
}
+func BenchmarkAfter(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ <-After(1)
+ }
+}
+
+func BenchmarkStop(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ NewTimer(1e9).Stop()
+ }
+}
+
func TestAfter(t *testing.T) {
const delay = int64(100e6)
start := Nanoseconds()
@@ -94,6 +106,32 @@ func TestAfterTick(t *testing.T) {
}
}
+func TestAfterStop(t *testing.T) {
+ const msec = 1e6
+ AfterFunc(100*msec, func() {})
+ t0 := NewTimer(50 * msec)
+ c1 := make(chan bool, 1)
+ t1 := AfterFunc(150*msec, func() { c1 <- true })
+ c2 := After(200 * msec)
+ if !t0.Stop() {
+ t.Fatalf("failed to stop event 0")
+ }
+ if !t1.Stop() {
+ t.Fatalf("failed to stop event 1")
+ }
+ <-c2
+ select {
+ case <-t0.C:
+ t.Fatalf("event 0 was not stopped")
+ case <-c1:
+ t.Fatalf("event 1 was not stopped")
+ default:
+ }
+ if t1.Stop() {
+ t.Fatalf("Stop returned true twice")
+ }
+}
+
var slots = []int{5, 3, 6, 6, 6, 1, 1, 2, 7, 9, 4, 8, 0}
type afterResult struct {
OpenPOWER on IntegriCloud