Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jmschonfeld
Copy link
Contributor

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

@jmschonfeld
Copy link
Contributor Author

@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() {
Copy link
Contributor

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

Copy link
Contributor Author

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() {
Copy link
Contributor

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)
Copy link
Contributor

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 {
Copy link
Contributor

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this

Copy link
Contributor

@itingliu itingliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants