2011-08-26 13:15:23 -06:00
|
|
|
// Copyright 2011 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.
|
|
|
|
|
|
|
|
package time
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
// force US/Pacific for time zone tests
|
2013-01-14 15:09:42 -07:00
|
|
|
ForceUSPacificForTesting()
|
2011-08-26 13:15:23 -06:00
|
|
|
}
|
|
|
|
|
2017-09-18 11:22:29 -06:00
|
|
|
func initTestingZone() {
|
|
|
|
z, err := loadLocation("America/Los_Angeles", zoneSources[len(zoneSources)-1:])
|
|
|
|
if err != nil {
|
|
|
|
panic("cannot load America/Los_Angeles for testing: " + err.Error())
|
|
|
|
}
|
|
|
|
z.name = "Local"
|
|
|
|
localLoc = *z
|
|
|
|
}
|
|
|
|
|
2017-10-06 09:16:43 -06:00
|
|
|
var OrigZoneSources = zoneSources
|
2017-09-18 11:22:29 -06:00
|
|
|
|
|
|
|
func forceZipFileForTesting(zipOnly bool) {
|
2017-10-06 09:16:43 -06:00
|
|
|
zoneSources = make([]string, len(OrigZoneSources))
|
|
|
|
copy(zoneSources, OrigZoneSources)
|
2017-09-18 11:22:29 -06:00
|
|
|
if zipOnly {
|
|
|
|
zoneSources = zoneSources[len(zoneSources)-1:]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-26 13:15:23 -06:00
|
|
|
var Interrupt = interrupt
|
2011-12-07 12:47:25 -07:00
|
|
|
var DaysIn = daysIn
|
2013-09-06 13:47:39 -06:00
|
|
|
|
2014-09-04 00:04:04 -06:00
|
|
|
func empty(arg interface{}, seq uintptr) {}
|
2013-09-06 13:47:39 -06:00
|
|
|
|
2020-12-02 10:19:13 -07:00
|
|
|
// Test that a runtimeTimer with a period that would overflow when on
|
|
|
|
// expiration does not throw or cause other timers to hang.
|
2013-09-06 13:47:39 -06:00
|
|
|
//
|
|
|
|
// This test has to be in internal_test.go since it fiddles with
|
|
|
|
// unexported data structures.
|
2020-12-02 10:19:13 -07:00
|
|
|
func CheckRuntimeTimerPeriodOverflow() {
|
|
|
|
// We manually create a runtimeTimer with huge period, but that expires
|
|
|
|
// immediately. The public Timer interface would require waiting for
|
|
|
|
// the entire period before the first update.
|
2013-09-06 13:47:39 -06:00
|
|
|
r := &runtimeTimer{
|
2020-12-02 10:19:13 -07:00
|
|
|
when: runtimeNano(),
|
|
|
|
period: 1<<63 - 1,
|
|
|
|
f: empty,
|
|
|
|
arg: nil,
|
2013-09-06 13:47:39 -06:00
|
|
|
}
|
|
|
|
startTimer(r)
|
2020-12-02 10:19:13 -07:00
|
|
|
defer stopTimer(r)
|
2013-09-06 13:47:39 -06:00
|
|
|
|
2020-12-02 10:19:13 -07:00
|
|
|
// If this test fails, we will either throw (when siftdownTimer detects
|
|
|
|
// bad when on update), or other timers will hang (if the timer in a
|
|
|
|
// heap is in a bad state). There is no reliable way to test this, but
|
|
|
|
// we wait on a short timer here as a smoke test (alternatively, timers
|
|
|
|
// in later tests may hang).
|
|
|
|
<-After(25 * Millisecond)
|
2013-09-06 13:47:39 -06:00
|
|
|
}
|
2018-04-14 01:50:52 -06:00
|
|
|
|
|
|
|
var (
|
|
|
|
MinMonoTime = Time{wall: 1 << 63, ext: -1 << 63, loc: UTC}
|
|
|
|
MaxMonoTime = Time{wall: 1 << 63, ext: 1<<63 - 1, loc: UTC}
|
|
|
|
)
|