lib/sync: Make the clock a function pointer

This commit is contained in:
greatroar
2021-11-27 15:35:07 +01:00
committed by Jakob Borg
parent 6a9716e8a1
commit c366933416
2 changed files with 17 additions and 27 deletions
+9 -9
View File
@@ -57,10 +57,10 @@ func TestTypes(t *testing.T) {
}
func TestMutex(t *testing.T) {
oldClock := defaultClock
oldClock := timeNow
clock := newTestClock()
defaultClock = clock
defer func() { defaultClock = oldClock }()
timeNow = clock.Now
defer func() { timeNow = oldClock }()
debug = true
l.SetDebug("sync", true)
@@ -97,10 +97,10 @@ func TestMutex(t *testing.T) {
}
func TestRWMutex(t *testing.T) {
oldClock := defaultClock
oldClock := timeNow
clock := newTestClock()
defaultClock = clock
defer func() { defaultClock = oldClock }()
timeNow = clock.Now
defer func() { timeNow = oldClock }()
debug = true
l.SetDebug("sync", true)
@@ -170,10 +170,10 @@ func TestRWMutex(t *testing.T) {
}
func TestWaitGroup(t *testing.T) {
oldClock := defaultClock
oldClock := timeNow
clock := newTestClock()
defaultClock = clock
defer func() { defaultClock = oldClock }()
timeNow = clock.Now
defer func() { timeNow = oldClock }()
debug = true
l.SetDebug("sync", true)