assert.Equal(t, Error{syscall.SIGUSR2}, ctx.Err())
}
-func TestImmediateCompletion(t *testing.T) {
+func TestPrecompleted(t *testing.T) {
parent, cancel := context.WithCancel(context.Background())
cancel()
<-parent.Done()
<-children[i].Done()
}
}
+
+func BenchmarkPrecompleted(b *testing.B) {
+ parent, cancel := context.WithCancel(context.Background())
+ cancel()
+ <-parent.Done()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ ctx := UntilSignal(parent, syscall.SIGUSR2)
+ <-ctx.Done()
+ }
+}