diff --git a/lib.go b/lib.go index 6bf3536..7b7c2d9 100644 --- a/lib.go +++ b/lib.go @@ -58,3 +58,8 @@ func (c TestClock) Pass(d time.Duration) { func (c TestClock) Jump(t time.Time) { c.clock.jump(t) } + +// Waiting tells how many channels are waiting set by After(). +func (c TestClock) Waiting() int { + return c.clock.waiting() +} diff --git a/test.go b/test.go index f819123..6900031 100644 --- a/test.go +++ b/test.go @@ -100,3 +100,12 @@ func (t test) jump(to time.Time) { s.current = to s = triggerChans(s) } + +func (t test) waiting() int { + s := <-t.state + defer func() { + t.state <- s + }() + + return len(s.chantlist) +}