mirror of
https://github.com/apple/swift.git
synced 2026-06-27 12:25:55 +02:00
e202e90294
Despite their similar names and uses, these protocols no longer share much functionality - the former is used to take @objc enums defined in Swift that conform to Error and expose them as NSErrors, and the latter handles NS_ERROR_ENUM C enums, which get imported into Swift as a wrapper around NSError. We can actually simplify them quite a bit. - Eliminate base protocol __BridgedNSError, which no longer provides any implementation for _BridgedStoredNSError. - Eliminate default implementations that match what the compiler would synthesize. - Adopt recursive constraints and where-clauses on associated types (and update the Clang importer to handle this). - Collapse signed and unsigned default implementations when reasonable. - Fold _BridgedStoredNSError's _nsErrorDomain into the existing public requirement CustomNSError.errorDomain. rdar://problem/35230080
107 lines
3.2 KiB
Swift
107 lines
3.2 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-build-swift %s -o %t/a.out3 -swift-version 3 && %target-run %t/a.out3
|
|
// RUN: %target-build-swift %s -o %t/a.out4 -swift-version 4 && %target-run %t/a.out4
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: objc_interop
|
|
|
|
// UNSUPPORTED: OS=tvos
|
|
|
|
import Intents
|
|
import StdlibUnittest
|
|
|
|
let IntentsTestSuite = TestSuite("Intents")
|
|
|
|
#if swift(>=4)
|
|
let swiftVersion = "4"
|
|
#else
|
|
let swiftVersion = "3"
|
|
#endif
|
|
|
|
if #available(OSX 10.12, iOS 10.0, watchOS 3.2, *) {
|
|
|
|
IntentsTestSuite.test("ErrorDomain/\(swiftVersion)") {
|
|
expectEqual("IntentsErrorDomain", INIntentErrorDomain)
|
|
}
|
|
|
|
IntentsTestSuite.test("extension/\(swiftVersion)") {
|
|
expectEqual("IntentsErrorDomain", INIntentError.errorDomain)
|
|
}
|
|
}
|
|
|
|
#if os(iOS)
|
|
if #available(iOS 11.0, *) {
|
|
|
|
IntentsTestSuite.test("INParameter KeyPath/\(swiftVersion)") {
|
|
let param = INParameter(keyPath: \INRequestRideIntent.pickupLocation)
|
|
expectEqual("pickupLocation", param?.parameterKeyPath)
|
|
if let typ = param?.parameterClass {
|
|
expectEqual(INRequestRideIntent.self, typ)
|
|
}
|
|
else {
|
|
expectUnreachable()
|
|
}
|
|
}
|
|
|
|
IntentsTestSuite.test("INSetProfileInCarIntent/defaultProfile availability/\(swiftVersion)") {
|
|
func f(profile: INSetProfileInCarIntent) {
|
|
var isDefaultProfile = profile.isDefaultProfile
|
|
expectType(Bool?.self, &isDefaultProfile)
|
|
#if !swift(>=4)
|
|
var defaultProfile = profile.defaultProfile
|
|
expectType(Int?.self, &defaultProfile)
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#if os(iOS) || os(watchOS)
|
|
if #available(iOS 10.0, watchOS 3.2, *) {
|
|
|
|
IntentsTestSuite.test("INRideOption usesMeteredFare/\(swiftVersion)") {
|
|
func f(rideOption: inout INRideOption) {
|
|
#if swift(>=4)
|
|
rideOption.usesMeteredFare = true
|
|
expectType(Bool?.self, &rideOption.usesMeteredFare)
|
|
expectTrue(rideOption.usesMeteredFare ?? false)
|
|
#else
|
|
rideOption.usesMeteredFare = NSNumber(value: true)
|
|
expectType(NSNumber?.self, &rideOption.usesMeteredFare)
|
|
expectTrue(rideOption.usesMeteredFare?.boolValue ?? false)
|
|
#endif
|
|
}
|
|
}
|
|
|
|
}
|
|
#endif
|
|
|
|
#if os(iOS)
|
|
if #available(iOS 11.0, *) {
|
|
IntentsTestSuite.test("INSetProfileInCarIntent Initializers/\(swiftVersion)") {
|
|
#if swift(>=4)
|
|
_ = INSetProfileInCarIntent()
|
|
_ = INSetProfileInCarIntent(isDefaultProfile: nil)
|
|
_ = INSetProfileInCarIntent(profileName: nil)
|
|
_ = INSetProfileInCarIntent(profileName: nil, isDefaultProfile: nil)
|
|
_ = INSetProfileInCarIntent(profileNumber: nil)
|
|
_ = INSetProfileInCarIntent(profileNumber: nil, isDefaultProfile: nil)
|
|
_ = INSetProfileInCarIntent(profileNumber: nil, profileName: nil)
|
|
_ = INSetProfileInCarIntent(
|
|
profileNumber: nil, profileName: nil, isDefaultProfile: nil)
|
|
#else
|
|
_ = INSetProfileInCarIntent()
|
|
_ = INSetProfileInCarIntent(defaultProfile: nil)
|
|
_ = INSetProfileInCarIntent(profileName: nil)
|
|
_ = INSetProfileInCarIntent(profileName: nil, defaultProfile: nil)
|
|
_ = INSetProfileInCarIntent(profileNumber: nil)
|
|
_ = INSetProfileInCarIntent(profileNumber: nil, defaultProfile: nil)
|
|
_ = INSetProfileInCarIntent(profileNumber: nil, profileName: nil)
|
|
_ = INSetProfileInCarIntent(
|
|
profileNumber: nil, profileName: nil, defaultProfile: nil)
|
|
#endif
|
|
}
|
|
}
|
|
#endif
|
|
|
|
runAllTests()
|