Commit ff3401a4 authored by Drew's avatar Drew

Swift 2 syntax

parent e5fd9103
Pipeline #2398 passed with stages
in 2 minutes and 54 seconds
......@@ -132,6 +132,7 @@ extension CarolineTest {
}
#endif
#if swift(>=3.0)
///Assert that the passed closure doesn't throw
///- returns: nil if the calling closure throws, otherwise the return value.
///It's not okay to force-unwrap this, use a construction like
......@@ -145,6 +146,18 @@ extension CarolineTest {
return nil
}
}
#else
///- noindex: true
public final func dontThrow<T>(@autoclosure _ message: () -> String = "Unexpectedly threw", file: String = #file, line: Int = #line, closure: () throws -> T) -> T? {
do {
return try closure()
}
catch {
self.fail(message() + "\(error)", file: file, line: line)
return nil
}
}
#endif
}
......
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