mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This is bullet (5) of the proposed solution in SE-0112, and the last major piece to be implemented.
28 lines
694 B
Swift
28 lines
694 B
Swift
// RUN: %target-run-simple-swift
|
|
// REQUIRES: executable_test
|
|
|
|
import StdlibUnittest
|
|
|
|
|
|
enum ClericalErrorDomain: Error {
|
|
case MisplacedDocument(name: String)
|
|
case AccidentallyErasedTape(fromMinute: Double, toMinute: Double)
|
|
}
|
|
|
|
enum EmptyErrorDomain: Error {}
|
|
|
|
var EnumError = TestSuite("Enum Error derivation")
|
|
|
|
EnumError.test("default codes") {
|
|
let a: ClericalErrorDomain = .MisplacedDocument(name: "check-in times.doc")
|
|
let b: ClericalErrorDomain
|
|
= .AccidentallyErasedTape(fromMinute: 5, toMinute: 23.5)
|
|
expectEqual(a._domain, "main.ClericalErrorDomain")
|
|
expectEqual(b._domain, "main.ClericalErrorDomain")
|
|
|
|
expectEqual(a._code, 0)
|
|
expectEqual(b._code, 1)
|
|
}
|
|
|
|
runAllTests()
|