| // Copyright 2009 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| func (o *one) Increment() { |
| func run(t *testing.T, once *Once, o *one, c chan bool) { |
| once.Do(func() { o.Increment() }) |
| t.Errorf("once failed inside run: %d is not 1", v) |
| func TestOnce(t *testing.T) { |
| t.Errorf("once failed outside run: %d is not 1", *o) |
| func TestOncePanic(t *testing.T) { |
| if r := recover(); r == nil { |
| t.Fatalf("Once.Do did not panic") |
| t.Fatalf("Once.Do called twice") |
| func BenchmarkOnce(b *testing.B) { |
| b.RunParallel(func(pb *testing.PB) { |