mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
New value types for Calendar, TimeZone, and Locale
As part of the extensive work on value types in Foundation this year, we decided to also add value types for these three key classes. In addition to adding value semantics, the API was extensively audited to improve Swift interop (especially Calendar). rdar://26628184
This commit is contained in:
@@ -262,22 +262,18 @@ func expectLocalizedEquality(
|
||||
_ localeID: String? = nil,
|
||||
_ message: @autoclosure () -> String = "",
|
||||
showFrame: Bool = true,
|
||||
stackTrace: SourceLocStack = SourceLocStack(),
|
||||
stackTrace: SourceLocStack = SourceLocStack(),
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
let trace = stackTrace.pushIf(showFrame, file: file, line: line)
|
||||
|
||||
let locale = localeID.map {
|
||||
Locale(localeIdentifier: $0)
|
||||
Locale(identifier: $0)
|
||||
} ?? Locale.current
|
||||
|
||||
expectEqual(
|
||||
expected, op(locale),
|
||||
message(), stackTrace: trace)
|
||||
|
||||
expectEqual(
|
||||
op(Locale.system), op(nil),
|
||||
message(), stackTrace: trace)
|
||||
message(), stackTrace: trace)
|
||||
}
|
||||
|
||||
NSStringAPIs.test("capitalizedString(with:)") {
|
||||
@@ -834,8 +830,6 @@ NSStringAPIs.test("init(format:locale:_:...)") {
|
||||
var world: NSString = "world"
|
||||
expectEqual("Hello, world!%42", String(format: "Hello, %@!%%%ld",
|
||||
locale: nil, world, 42))
|
||||
expectEqual("Hello, world!%42", String(format: "Hello, %@!%%%ld",
|
||||
locale: Locale.system, world, 42))
|
||||
}
|
||||
|
||||
NSStringAPIs.test("init(format:locale:arguments:)") {
|
||||
@@ -843,8 +837,6 @@ NSStringAPIs.test("init(format:locale:arguments:)") {
|
||||
let args: [CVarArg] = [ world, 42 ]
|
||||
expectEqual("Hello, world!%42", String(format: "Hello, %@!%%%ld",
|
||||
locale: nil, arguments: args))
|
||||
expectEqual("Hello, world!%42", String(format: "Hello, %@!%%%ld",
|
||||
locale: Locale.system, arguments: args))
|
||||
}
|
||||
|
||||
NSStringAPIs.test("lastPathComponent") {
|
||||
|
||||
Reference in New Issue
Block a user