Commit f0193f20 authored by Drew's avatar Drew

Add "check" to deal with Swift2Errors

parent 26cd0d71
...@@ -105,6 +105,16 @@ extension CarolineTest { ...@@ -105,6 +105,16 @@ extension CarolineTest {
} }
} }
///Check that a function does not return an error
public final func check(_ message: @autoclosure() -> String = "Error thrown", file: String = #file, line: Int = #line, block: () throws -> ()) {
do {
try block()
}
catch {
self.fail("\(message()) - \(error)", file: file, line: line)
}
}
///Assert that the passed closure doesn't throw ///Assert that the passed closure doesn't throw
///- returns: nil if the calling closure throws, otherwise the return value. ///- returns: nil if the calling closure throws, otherwise the return value.
......
...@@ -19,11 +19,15 @@ import CarolineCore ...@@ -19,11 +19,15 @@ import CarolineCore
let allTests: [CarolineTest] = [ let allTests: [CarolineTest] = [
AssertTrue(), AssertTrue(),
AssertFalse(), AssertFalse(),
DictEqual(),
DictEqualInverse(),
DictEqualLengthMismatch(),
DictNotEqual(),
DictNotEqualInverse(),
DictNotEqualLengthMismatch(),
NoErrorCheck(),
ErrorCheck(),
Fail(), Fail(),
SimpleEqual(),
SimpleEqualInverse(),
SimpleNotEqual(),
SimpleNotEqualInverse(),
SequenceEqual(), SequenceEqual(),
SequenceEqualInverse(), SequenceEqualInverse(),
SequenceEqualLengthA(), SequenceEqualLengthA(),
...@@ -36,12 +40,10 @@ let allTests: [CarolineTest] = [ ...@@ -36,12 +40,10 @@ let allTests: [CarolineTest] = [
SequenceNotEqualLengthB(), SequenceNotEqualLengthB(),
SequenceNotEqualLengthC(), SequenceNotEqualLengthC(),
SequenceNotEqualLengthD(), SequenceNotEqualLengthD(),
DictEqual(), SimpleEqual(),
DictEqualInverse(), SimpleEqualInverse(),
DictEqualLengthMismatch(), SimpleNotEqual(),
DictNotEqual(), SimpleNotEqualInverse()
DictNotEqualInverse(),
DictNotEqualLengthMismatch()
] ]
let engine = CarolineCoreEngine() let engine = CarolineCoreEngine()
if !engine.testAll(allTests) { if !engine.testAll(allTests) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment