Files
swift-mirror/test/Interpreter/SDK/errors.swift
Doug Gregor 823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00

49 lines
1.0 KiB
Swift

// RUN: rm -rf %t && mkdir %t
// RUN: %target-build-swift %s -import-objc-header %S/Inputs/errors.h -o %t/main
// RUN: %target-run %t/main
// REQUIRES: executable_test
// REQUIRES: objc_interop
//
// Tests for error handling.
//
import StdlibUnittest
struct Problem : Error {}
class ErrorImpl : NSObject, ErrorTest {
func succeed() throws -> AnyObject { return self }
func fail() throws -> AnyObject { throw Problem() }
}
var ErrorHandlingTests = TestSuite("ErrorHandling")
ErrorHandlingTests.test("succeed") {
let obj = ErrorImpl()
let result = testSucceed(obj)
expectTrue(obj === result)
}
ErrorHandlingTests.test("succeedIgnoringError") {
let obj = ErrorImpl()
let result = testSucceedIgnoringError(obj)
expectTrue(obj === result)
}
ErrorHandlingTests.test("fail") {
let obj = ErrorImpl()
let result = testFail(obj)
expectEmpty(result)
}
ErrorHandlingTests.test("failIgnoringError") {
let obj = ErrorImpl()
let result = testFailIgnoringError(obj)
expectEmpty(result)
}
runAllTests()