mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This reverts commit e07e88706d. The
crash came back, so there's obviously more I need to investigate here:
https://ci.swift.org/job/swift-PR-osx-smoke-test/881/testReport/junit/Swift(macosx-x86_64)/stdlib/ErrorProtocol_swift/
55 lines
1.5 KiB
Swift
55 lines
1.5 KiB
Swift
// RUN: %target-run-simple-swift
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: rdar27541751
|
|
// REQUIRES: objc_interop
|
|
|
|
import SwiftPrivate
|
|
import StdlibUnittest
|
|
import Foundation
|
|
|
|
|
|
enum SomeError : Error {
|
|
case GoneToFail
|
|
}
|
|
|
|
struct ErrorAsNSErrorRaceTest : RaceTestWithPerTrialData {
|
|
class RaceData {
|
|
let error: Error
|
|
|
|
init(error: Error) {
|
|
self.error = error
|
|
}
|
|
}
|
|
|
|
func makeRaceData() -> RaceData {
|
|
return RaceData(error: SomeError.GoneToFail)
|
|
}
|
|
|
|
func makeThreadLocalData() {}
|
|
|
|
func thread1(_ raceData: RaceData, _: inout Void) -> Observation3Int {
|
|
let ns = raceData.error as NSError
|
|
// Use valueForKey to bypass bridging, so we can verify that the identity
|
|
// of the unbridged NSString object is stable.
|
|
let domainInt: Int = unsafeBitCast(ns.value(forKey: "domain").map { $0 as AnyObject },
|
|
to: Int.self)
|
|
let code: Int = ns.code
|
|
let userInfoInt: Int = unsafeBitCast(ns.value(forKey: "userInfo").map { $0 as AnyObject },
|
|
to: Int.self)
|
|
return Observation3Int(domainInt, code, userInfoInt)
|
|
}
|
|
|
|
func evaluateObservations(
|
|
_ observations: [Observation3Int],
|
|
_ sink: (RaceTestObservationEvaluation) -> Void
|
|
) {
|
|
sink(evaluateObservationsAllEqual(observations))
|
|
}
|
|
}
|
|
|
|
var ErrorRaceTestSuite = TestSuite("Error races")
|
|
ErrorRaceTestSuite.test("NSError bridging") {
|
|
runRaceTest(ErrorAsNSErrorRaceTest.self, operations: 1000)
|
|
}
|
|
runAllTests()
|