Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,8 @@ internal final class _LocaleICU: _LocaleProtocol, Sendable {
}
}

// Check prefs
if let firstWeekdayPref = prefs?.firstWeekday {
// Check prefs. The value doesn't matter here - we check it again in the `forceFirstWeekday` function, and it is immutable.
if prefs?.firstWeekday != nil {
let calendarId = calendarIdentifier
if let first = forceFirstWeekday(calendarId) {
state.firstDayOfWeek = first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ internal class _NSSwiftLocale: _NSLocaleBridge, @unchecked Sendable {
switch locale.temperatureUnit {
case .celsius: return NSLocaleTemperatureUnitCelsius
case .fahrenheit: return NSLocaleTemperatureUnitFahrenheit
#if !FOUNDATION_FRAMEWORK
// On non-framework builds, the enum is non-closed and `package` visibility, so we need a default
default: return NSLocaleTemperatureUnitCelsius
#endif
}
case .decimalSeparator: return self.decimalSeparator
case .groupingSeparator: return self.groupingSeparator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ internal final class _TimeZoneICU: _TimeZoneProtocol, Sendable {
return Self.timeZoneDisplayName(for: c, timeZoneName: identifier, localeName: locID, isShort: false, isGeneric: true, isDaylight: false)
case .shortGeneric:
return Self.timeZoneDisplayName(for: c, timeZoneName: identifier, localeName: locID, isShort: true, isGeneric: true, isDaylight: false)
#if FOUNDATION_FRAMEWORK
// We only need this when building in ObjC mode, when the enum comes from a .h
@unknown default:
// Use standard style
return Self.timeZoneDisplayName(for: c, timeZoneName: identifier, localeName: locID, isShort: false, isGeneric: false, isDaylight: false)
#endif
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ final class AttributedStringIndexValidityTests: XCTestCase {
}

public func testMutationInvalidation() {
func checkInPlace(_ mutation: (inout AttributedString) -> (), file: StaticString = #file, line: UInt = #line) {
func checkInPlace(_ mutation: (inout AttributedString) -> (), file: StaticString = #filePath, line: UInt = #line) {
var str = AttributedString("Hello World")
let idxA = str.startIndex
let idxB = str.index(afterCharacter: idxA)
Expand All @@ -158,7 +158,7 @@ final class AttributedStringIndexValidityTests: XCTestCase {
XCTAssertFalse(RangeSet(idxA ..< idxB).isValid(within: str), "Initial range set was valid in in-place mutated", file: file, line: line)
}

func checkCopy(_ mutation: (inout AttributedString) -> (), file: StaticString = #file, line: UInt = #line) {
func checkCopy(_ mutation: (inout AttributedString) -> (), file: StaticString = #filePath, line: UInt = #line) {
let str = AttributedString("Hello World")
let idxA = str.startIndex
let idxB = str.index(afterCharacter: idxA)
Expand All @@ -185,7 +185,7 @@ final class AttributedStringIndexValidityTests: XCTestCase {
XCTAssertFalse(RangeSet(idxA ..< idxB).isValid(within: copy), "Initial range set was valid in copy", file: file, line: line)
}

func check(_ mutation: (inout AttributedString) -> (), file: StaticString = #file, line: UInt = #line) {
func check(_ mutation: (inout AttributedString) -> (), file: StaticString = #filePath, line: UInt = #line) {
checkInPlace(mutation, file: file, line: line)
checkCopy(mutation, file: file, line: line)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1882,7 +1882,7 @@ E {
func check<T: Equatable>(
_ a: some Sequence<T>,
_ b: some Sequence<T>,
file: StaticString = #file, line: UInt = #line
file: StaticString = #filePath, line: UInt = #line
) {
XCTAssertTrue(
a.elementsEqual(b),
Expand Down
1 change: 1 addition & 0 deletions Tests/FoundationEssentialsTests/DataIOTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class DataIOTests : XCTestCase {

#if FOUNDATION_FRAMEWORK
// String(contentsOf:) is not available outside the framework yet
@available(*, deprecated)
func test_emptyFileString() {
let data = Data()
let url = testURL()
Expand Down
2 changes: 1 addition & 1 deletion Tests/FoundationEssentialsTests/StringTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ final class StringTests : XCTestCase {

}

func verifyEncoding(_ encoding: String._Encoding, valid: [String], invalid: [String], file: StaticString = #file, line: UInt = #line) throws {
func verifyEncoding(_ encoding: String._Encoding, valid: [String], invalid: [String], file: StaticString = #filePath, line: UInt = #line) throws {
for string in valid {
let data = try XCTUnwrap(string.data(using: encoding), "Failed to encode \(string.debugDescription)", file: file, line: line)
XCTAssertNotNil(String(data: data, encoding: encoding), "Failed to decode \(data) (\(string.debugDescription))", file: file, line: line)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ final class DateComponentsTests : XCTestCase {
extension DateComponentsTests {
func date(from string: String, nanoseconds: Int? = nil) -> Date {
let d = try! Date(string, strategy: Date.ParseStrategy(format: "\(year: .extended(minimumLength: 4))-\(month: .twoDigits)-\(day: .twoDigits) \(hour: .twoDigits(clock: .twentyFourHour, hourCycle: .zeroBased)):\(minute: .twoDigits):\(second: .twoDigits) \(timeZone: .iso8601(.short))", locale: Locale(identifier: "en_US"), timeZone: TimeZone.gmt))
if let nanoseconds {
var comps = Calendar(identifier: .gregorian).dateComponents([.era, .year, .month, .day, .hour, .minute, .second, .nanosecond, .weekday, .weekdayOrdinal, .quarter, .weekOfMonth, .weekOfYear, .yearForWeekOfYear, .timeZone, .calendar], from: d)
if nanoseconds != nil {
let comps = Calendar(identifier: .gregorian).dateComponents([.era, .year, .month, .day, .hour, .minute, .second, .nanosecond, .weekday, .weekdayOrdinal, .quarter, .weekOfMonth, .weekOfYear, .yearForWeekOfYear, .timeZone, .calendar], from: d)
return Calendar(identifier: .gregorian).date(from: comps)!
}
return d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ final class DateAttributedFormatStyleTests : XCTestCase {

func test(dateStyle: Date.FormatStyle.DateStyle, timeStyle: Date.FormatStyle.TimeStyle, dateFormatOverride: [Date.FormatStyle.DateStyle: String], expected: [Segment], file: StaticString = #filePath, line: UInt = #line) {
let locale = Locale.localeAsIfCurrent(name: enUS, overrides: .init(dateFormats: dateFormatOverride))
let style = Date.FormatStyle(date: dateStyle, time: timeStyle, locale: locale, calendar: Calendar(identifier: .gregorian), timeZone: TimeZone(identifier: "PST")!, capitalizationContext: .standalone).attributed
let style = Date.FormatStyle(date: dateStyle, time: timeStyle, locale: locale, calendar: Calendar(identifier: .gregorian), timeZone: TimeZone(identifier: "PST")!, capitalizationContext: .standalone).attributedStyle
XCTAssertEqual(style.format(date), expected.attributedString, file: file, line: line)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ final class NumberFormatStyleTests: XCTestCase {

func testCurrency_Codable() throws {
let gbpInUS = Decimal.FormatStyle.Currency(code: "GBP", locale: enUSLocale)
let encoded = try JSONEncoder().encode(gbpInUS)
let _ = try JSONEncoder().encode(gbpInUS)
// Valid JSON presentation of the format style
let previouslyEncoded = """
{
Expand Down