From 3173c2884caf3bd375d1f78213ee651f253f59dc Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Mon, 29 Sep 2025 11:55:42 -0700 Subject: [PATCH 1/2] Fix leadingDotSyntax test reliance on current i18n preferences --- .../Formatting/DateFormatStyleTests.swift | 7 +++++++ .../Formatting/DateIntervalFormatStyleTests.swift | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift b/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift index d12c1ba5f..4d90f64ce 100644 --- a/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift +++ b/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift @@ -190,6 +190,9 @@ private struct DateFormatStyleTests { @Test func leadingDotSyntax() async { let date = Date.now let locale = Locale(identifier: "es_ES") + let timeZone = TimeZone.gmt + var calendar = Calendar(identifier: .gregorian) + calendar.timeZone = timeZone await usingCurrentInternationalizationPreferences { #expect(date.formatted(date: .long, time: .complete) == date.formatted(Date.FormatStyle(date: .long, time: .complete))) } @@ -200,6 +203,8 @@ private struct DateFormatStyleTests { .month() .year() .locale(locale) + .timeZone(timeZone) + .calendar(calendar) ) == date.formatted( Date.FormatStyle() @@ -207,6 +212,8 @@ private struct DateFormatStyleTests { .month() .year() .locale(locale) + .timeZone(timeZone) + .calendar(calendar) ) ) } diff --git a/Tests/FoundationInternationalizationTests/Formatting/DateIntervalFormatStyleTests.swift b/Tests/FoundationInternationalizationTests/Formatting/DateIntervalFormatStyleTests.swift index a7c6ad3f8..7a29bcab0 100644 --- a/Tests/FoundationInternationalizationTests/Formatting/DateIntervalFormatStyleTests.swift +++ b/Tests/FoundationInternationalizationTests/Formatting/DateIntervalFormatStyleTests.swift @@ -106,9 +106,9 @@ private struct DateIntervalFormatStyleTests { // This test assumes both the left side and the right side of the comparison has the same `Locale.autoupdatingCurrent`, which assumes the state of the host machine remains unchanged. #expect(range.formatted() == Date.IntervalFormatStyle().format(range)) #expect(range.formatted(date: .numeric, time: .shortened) == Date.IntervalFormatStyle(date: .numeric, time: .shortened).format(range)) + #expect(range.formatted(.interval.day().month().year().locale(locale)) == Date.IntervalFormatStyle().day().month().year().locale(locale).format(range)) } - #expect(range.formatted(.interval.day().month().year().locale(locale)) == Date.IntervalFormatStyle().day().month().year().locale(locale).format(range)) } #if FIXED_ICU_74_DAYPERIOD From f361cc257ca2075993fcf86bd97fa4b45a6984e1 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Mon, 29 Sep 2025 12:12:33 -0700 Subject: [PATCH 2/2] Fix build failure --- .../Formatting/DateFormatStyleTests.swift | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift b/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift index 4d90f64ce..bf5602477 100644 --- a/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift +++ b/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift @@ -190,32 +190,25 @@ private struct DateFormatStyleTests { @Test func leadingDotSyntax() async { let date = Date.now let locale = Locale(identifier: "es_ES") - let timeZone = TimeZone.gmt - var calendar = Calendar(identifier: .gregorian) - calendar.timeZone = timeZone await usingCurrentInternationalizationPreferences { #expect(date.formatted(date: .long, time: .complete) == date.formatted(Date.FormatStyle(date: .long, time: .complete))) - } - #expect( - date.formatted( - .dateTime - .day() - .month() - .year() - .locale(locale) - .timeZone(timeZone) - .calendar(calendar) - ) == - date.formatted( - Date.FormatStyle() - .day() - .month() - .year() - .locale(locale) - .timeZone(timeZone) - .calendar(calendar) + #expect( + date.formatted( + .dateTime + .day() + .month() + .year() + .locale(locale) + ) == + date.formatted( + Date.FormatStyle() + .day() + .month() + .year() + .locale(locale) + ) ) - ) + } } @Test func dateFormatStyleIndividualFields() {