diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-12 01:31:45 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-12 01:31:45 +0000 |
commit | 9a0e3259f44ad2de9c65f14f756dab01b3598391 (patch) | |
tree | 86a3b8019380d5fad53258c4baba3dd9e1e7c736 /libgo/go/time/sleep_test.go | |
parent | c6135f063335419e4b5df0b4e1caf145882c8a4b (diff) | |
download | gcc-9a0e3259f44ad2de9c65f14f756dab01b3598391.zip gcc-9a0e3259f44ad2de9c65f14f756dab01b3598391.tar.gz gcc-9a0e3259f44ad2de9c65f14f756dab01b3598391.tar.bz2 |
libgo: Update to weekly.2011-12-14.
From-SVN: r183118
Diffstat (limited to 'libgo/go/time/sleep_test.go')
-rw-r--r-- | libgo/go/time/sleep_test.go | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/libgo/go/time/sleep_test.go b/libgo/go/time/sleep_test.go index cbcc897..3cb088c 100644 --- a/libgo/go/time/sleep_test.go +++ b/libgo/go/time/sleep_test.go @@ -39,7 +39,7 @@ func TestAfterFunc(t *testing.T) { i-- if i >= 0 { AfterFunc(0, f) - Sleep(1e9) + Sleep(1 * Second) } else { c <- true } @@ -91,7 +91,7 @@ func BenchmarkAfter(b *testing.B) { func BenchmarkStop(b *testing.B) { for i := 0; i < b.N; i++ { - NewTimer(1e9).Stop() + NewTimer(1 * Second).Stop() } } @@ -119,19 +119,17 @@ func TestAfterTick(t *testing.T) { t1 := Now() d := t1.Sub(t0) target := Delta * Count - slop := target * 2 / 10 - if d < target-slop || d > target+slop { + if d < target*9/10 || d > target*30/10 { t.Fatalf("%d ticks of %s took %s, expected %s", Count, Delta, d, target) } } func TestAfterStop(t *testing.T) { - const msec = 1e6 - AfterFunc(100*msec, func() {}) - t0 := NewTimer(50 * msec) + AfterFunc(100*Millisecond, func() {}) + t0 := NewTimer(50 * Millisecond) c1 := make(chan bool, 1) - t1 := AfterFunc(150*msec, func() { c1 <- true }) - c2 := After(200 * msec) + t1 := AfterFunc(150*Millisecond, func() { c1 <- true }) + c2 := After(200 * Millisecond) if !t0.Stop() { t.Fatalf("failed to stop event 0") } @@ -199,9 +197,8 @@ func testAfterQueuing(t *testing.T) error { } dt := r.t.Sub(t0) target := Duration(slot) * Delta - slop := Delta / 4 - if dt < target-slop || dt > target+slop { - return fmt.Errorf("After(%s) arrived at %s, expected [%s,%s]", target, dt, target-slop, target+slop) + if dt < target-Delta/2 || dt > target+Delta*10 { + return fmt.Errorf("After(%s) arrived at %s, expected [%s,%s]", target, dt, target-Delta/2, target+Delta*10) } } return nil @@ -213,12 +210,12 @@ func TestTimerStopStress(t *testing.T) { } for i := 0; i < 100; i++ { go func(i int) { - timer := AfterFunc(2e9, func() { + timer := AfterFunc(2*Second, func() { t.Fatalf("timer %d was not stopped", i) }) - Sleep(1e9) + Sleep(1 * Second) timer.Stop() }(i) } - Sleep(3e9) + Sleep(3 * Second) } |