diff --git a/clock.go b/clock.go index 1030f96..5f0e543 100644 --- a/clock.go +++ b/clock.go @@ -27,7 +27,7 @@ type Timer interface { Stop() bool } -// The Timer is an interface for time.Ticket, and can also be swapped in mocks. +// The Ticker is an interface for time.Ticker, and can also be swapped in mocks. // This *does* change its API so that it can fit into an interface -- rather // than using the channel at .C, you should call Chan() and use the // returned channel just as you would .C. diff --git a/default.go b/default.go index 85bb622..f958a5f 100644 --- a/default.go +++ b/default.go @@ -54,6 +54,6 @@ func (d *defaultTicker) Chan() <-chan time.Time { return d.C } -// Default clock that uses time.Now as its time source. This is what you should +// C holds a default clock that uses time.Now as its time source. This is what you should // normally use in your code. var C = DefaultClock{} diff --git a/mock.go b/mock.go index 60529d0..a35c531 100644 --- a/mock.go +++ b/mock.go @@ -70,14 +70,14 @@ func (m *MockClock) AfterFunc(d time.Duration, f func()) Timer { return t } -// NewTimer creates a new Timer that will send the current time on its channel after at least duration d. +// NewTimer creates a new mock Timer that will send the current time on its channel after at least duration d. func (m *MockClock) NewTimer(d time.Duration) Timer { t := NewMockTimer(m) t.Reset(d) return t } -// NewTimer creates a new Timer that will send the current time on its channel after at least duration d. +// NewTicker returns a new mock Ticker containing a channel that will send the time with a period specified by the duration argument. // Note: unlike the default ticker included in Go, the mock ticker will *never* skip ticks as time advances. func (m *MockClock) NewTicker(d time.Duration) Ticker { return NewMockTicker(m, d) @@ -88,7 +88,7 @@ func (m *MockClock) Since(t time.Time) time.Duration { return m.Now().Sub(t) } -// Sets the mock clock's time to the given absolute time. +// SetTime sets the mock clock's time to the given absolute time. func (m *MockClock) SetTime(t time.Time) { m.cond.L.Lock() defer m.cond.L.Unlock() @@ -98,7 +98,7 @@ func (m *MockClock) SetTime(t time.Time) { m.cond.Broadcast() } -// Adds the given time duration to the clock. +// AddTime adds the given time duration to the clock. func (m *MockClock) AddTime(d time.Duration) { m.cond.L.Lock() defer m.cond.L.Unlock() @@ -114,7 +114,7 @@ func assertFuture(a, b time.Time) { } } -// Creates a new mock clock, with its current time set to the provided +// NewMockClock creates a new mock clock, with its current time set to the provided // optional start time. func NewMockClock(start ...time.Time) *MockClock { m := &MockClock{cond: sync.NewCond(new(sync.Mutex))} diff --git a/ticker.go b/ticker.go index 8b9fe77..3285341 100644 --- a/ticker.go +++ b/ticker.go @@ -49,7 +49,7 @@ func (m *mockTicker) Stop() { m.stop <- true } -// Creates a new Ticker using the provided Clock. You should not use this +// NewMockTicker creates a new Ticker using the provided Clock. You should not use this // directly outside of unit tests; use Clock.NewTicker(). func NewMockTicker(c Clock, interval time.Duration) Ticker { t := &mockTicker{ @@ -65,4 +65,3 @@ func NewMockTicker(c Clock, interval time.Duration) Ticker { <-ready return t } - diff --git a/timer.go b/timer.go index 888a67f..7c514ee 100644 --- a/timer.go +++ b/timer.go @@ -70,7 +70,7 @@ func (m *mockTimer) Stop() bool { return wasActive } -// Creates a new Timer using the provided Clock. You should not use this +// NewMockTimer creates a new Timer using the provided Clock. You should not use this // directly outside of unit tests; use Clock.NewTimer(). func NewMockTimer(c Clock) Timer { return &mockTimer{