diff options
Diffstat (limited to 'libgo/go/sync/once_test.go')
-rw-r--r-- | libgo/go/sync/once_test.go | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/libgo/go/sync/once_test.go b/libgo/go/sync/once_test.go index 8afda82f3e1..1eec8d18ea5 100644 --- a/libgo/go/sync/once_test.go +++ b/libgo/go/sync/once_test.go @@ -40,22 +40,20 @@ func TestOnce(t *testing.T) { } func TestOncePanic(t *testing.T) { - once := new(Once) - for i := 0; i < 2; i++ { - func() { - defer func() { - if recover() == nil { - t.Fatalf("Once.Do() has not panic'ed") - } - }() - once.Do(func() { - panic("failed") - }) + var once Once + func() { + defer func() { + if r := recover(); r == nil { + t.Fatalf("Once.Do did not panic") + } }() - } - once.Do(func() {}) + once.Do(func() { + panic("failed") + }) + }() + once.Do(func() { - t.Fatalf("Once called twice") + t.Fatalf("Once.Do called twice") }) } |