-
Notifications
You must be signed in to change notification settings - Fork 193
Convert Gregorian Calendar tests to swift-testing #1365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Convert Gregorian Calendar tests to swift-testing #1365
Conversation
@swift-ci please test |
// Accessing the integer julianDay of a remote date should not crash | ||
let d = Date(julianDate: 9223372036854775808) // Int64.max + 1 | ||
_ = d.julianDay | ||
} | ||
|
||
// MARK: Date from components | ||
func testDateFromComponents_DST() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you move this into FoundationI18n? I would pretty much appreciate that we keep it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops - so sorry about that! I cherry-picked the changes for this file, but accidentally didn't commit the changes for the additional file in the internationalization suite as well. Yes these tests were moved to FoundationInternationalizationTests
because they rely implicitly on FoundationInternationalization
(mostly via non-GMT timezones / unlocalized locales) and so eventually once the FoundationInternationalization
import is removed from FoundationEssentialsTests
, they will fail. I've added that file to this PR now. Thanks for catching that!
@@ -168,79 +119,27 @@ final class GregorianCalendarTests : XCTestCase { | |||
test(.init(weekOfYear: 43, yearForWeekOfYear: 2935), expected: Date(timeIntervalSince1970: 30477945600.0)) | |||
} | |||
|
|||
func testDateFromComponents_componentsTimeZone() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with keeping this test
} | ||
|
||
var calendar = _CalendarGregorian(identifier: .gregorian, timeZone: TimeZone(identifier: "America/Los_Angeles")!, locale: nil, firstWeekday: 1, minimumDaysInFirstWeek: 1, gregorianStartDate: nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here 🙏
@@ -588,30 +480,6 @@ final class GregorianCalendarTests : XCTestCase { | |||
|
|||
testAdding(.init(day: -7, weekOfYear: 2), to: oct24_1582, wrap: true, expected: Date(timeIntervalSince1970:-12215318400.0)) // expect: 1582-11-30 00:00:00 - adding 2 weeks is 1582-11-07, adding -7 days wraps around to 1582-11-30 | |||
|
|||
do { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this
@@ -623,1817 +491,16 @@ final class GregorianCalendarTests : XCTestCase { | |||
} | |||
} | |||
|
|||
func testAddDateComponents_DST() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This converts the last of FoundationEssentials tests to swift-testing (the Gregorian calendar tests). Aside from converting to swift-testing, the only modification is that the final test now explicitly specifies the GMT timezone to avoid relying on the default timezone which other tests may change in parallel