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:
Tony Parker
2016-07-16 15:48:08 -07:00
parent e2a7e92cf0
commit 46a9f57329
20 changed files with 2497 additions and 52 deletions

View File

@@ -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") {