Commit 37f46822 authored by Drew's avatar Drew

Merge branch 'master' of code.sealedabstract.com:drewcrawford/Caroline

parents e32bd75b 35fb0c96
Pipeline #2388 passed with stages
in 2 minutes and 36 seconds
......@@ -81,56 +81,65 @@ extension CarolineTest {
///- parameter message: A reason for failure
public final func assert<T: Equatable>(_ a: T, equals b: T, _ message: @autoclosure () -> String = "Assertion failed", file: String = #file, line: Int = #line) {
if a != b {
self.fail("\(message()) - \(a) != \(b)", file: file, line: line)
self.fail("\(message()) - \(cdump(a)) != \(cdump(b))", file: file, line: line)
}
}
///Assert that two objects aren't equal
///- parameter message: A reason for failure
public final func assert<T: Equatable>(_ a: T, notEqual b: T, _ message: @autoclosure () -> String = "Assertion failed", file: String = #file, line: Int = #line) {
if a == b {
self.fail("\(message()) - \(a) == \(b)", file: file, line: line)
self.fail("\(message()) - \(cdump(a)) == \(cdump(b))", file: file, line: line)
}
}
///Assert that two sequences are equal
///- parameter message: A reason for failure
public final func assert<T:Sequence where T.Iterator.Element: Equatable>(_ a: T, equals b: T, _ message: @autoclosure () -> String = "Assertion failed", file: String = #file, line: Int = #line) {
if !compare(a,b) {
self.fail("\(message()) - \(a) != \(b)", file: file, line: line)
self.fail("\(message()) - \(cdump(a)) != \(cdump(b))", file: file, line: line)
}
}
///Assert that two sequences aren't equal
///- parameter message: A reason for failure
public final func assert<T:Sequence where T.Iterator.Element: Equatable>(_ a: T, notEqual b: T, _ message: @autoclosure () -> String = "Assertion failed", file: String = #file, line: Int = #line) {
if compare(a,b) {
self.fail("\(message()) - \(a) == \(b)", file: file, line: line)
self.fail("\(message()) - \(cdump(a)) == \(cdump(b))", file: file, line: line)
}
}
#else
///- noindex: true
public final func assert<T: Equatable>(_ a: T, equals b: T, @autoclosure _ message: () -> String = "Assertion failed", file: String = #file, line: Int = #line) {
if a != b {
self.fail("\(message()) - \(a) != \(b)", file: file, line: line)
self.fail("\(message()) - \(cdump(a)) != \(cdump(b))", file: file, line: line)
}
}
///- noindex: true
public final func assert<T: Equatable>(_ a: T, notEqual b: T, @autoclosure _ message: () -> String = "Assertion failed", file: String = #file, line: Int = #line) {
if a == b {
self.fail("\(message()) - \(a) == \(b)", file: file, line: line)
self.fail("\(message()) - \(cdump(a)) == \(cdump(b))", file: file, line: line)
}
}
///- noindex: true
public final func assert<T:SequenceType where T.Generator.Element: Equatable>(_ a: T, equals b: T, @autoclosure _ message: () -> String = "Assertion failed", file: String = #file, line: Int = #line) {
if !compare(a,b) {
self.fail("\(message()) - \(a) != \(b)", file: file, line: line)
self.fail("\(message()) - \(cdump(a)) != \(cdump(b))", file: file, line: line)
}
}
///- noindex: true
public final func assert<T:SequenceType where T.Generator.Element: Equatable>(_ a: T, notEqual b: T, @autoclosure _ message: () -> String = "Assertion failed", file: String = #file, line: Int = #line) {
if compare(a,b) {
self.fail("\(message()) - \(a) == \(b)", file: file, line: line)
self.fail("\(message()) - \(cdump(a)) == \(cdump(b))", file: file, line: line)
}
}
#endif
}
private func cdump(_ t: Any) -> String {
if let t = t as? CustomDebugStringConvertible {
return t.debugDescription
}
else if let t = t as? CustomStringConvertible {
return t.description
}
return "\(t)"
}
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