importing unit tests

This commit is contained in:
John Rommel Estropia
2016-06-12 20:34:13 +09:00
parent 8e5c7ec9b2
commit 76a2bc1da2
15 changed files with 1603 additions and 404 deletions

View File

@@ -70,4 +70,16 @@ public extension CoreStore {
functionName: functionName
)
}
@noreturn
internal static func abort(message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) {
self.logger.abort(
message,
fileName: fileName,
lineNumber: lineNumber,
functionName: functionName
)
Swift.fatalError(message, file: fileName, line: UInt(lineNumber))
}
}

View File

@@ -80,6 +80,17 @@ public protocol CoreStoreLogger {
*/
func assert(@autoclosure condition: () -> Bool, @autoclosure message: () -> String, fileName: StaticString, lineNumber: Int, functionName: StaticString)
/**
Handles fatal errors made throughout the `CoreStore` framework. The app wil terminate after this method is called.
- Important: Implementers may guarantee that the function doesn't return, either by calling another `@noreturn` function such as `fatalError()` or `abort()`, or by raising an exception. If the implementation does not terminate the app, CoreStore will call an internal `fatalError()` to do so.
- parameter message: the fatal error message
- parameter fileName: the source file name
- parameter lineNumber: the source line number
- parameter functionName: the source function name
*/
func abort(message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString)
// MARK: Deprecated
@@ -100,4 +111,9 @@ extension CoreStoreLogger {
self.log(error: error.bridgeToSwift, message: message, fileName: fileName, lineNumber: lineNumber, functionName: functionName)
}
public func abort(message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
Swift.fatalError(message, file: fileName, line: UInt(lineNumber))
}
}

View File

@@ -111,7 +111,22 @@ public final class DefaultLogger: CoreStoreLogger {
return
}
Swift.print("❗ [CoreStore: Assertion Failure] \((fileName.stringValue as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message())\n")
Swift.fatalError()
Swift.fatalError(file: fileName, line: UInt(lineNumber))
#endif
}
/**
Handles fatal errors made throughout the `CoreStore` framework.
- Important: This method should be marked `@noreturn` and implementers should guarantee that the function doesn't, either by calling another `@noreturn` function such as `fatalError()` or `abort()`, or by raising an exception.
- parameter message: the fatal error message
- parameter fileName: the source file name
- parameter lineNumber: the source line number
- parameter functionName: the source function name
*/
public func abort(message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
Swift.print("❗ [CoreStore: Fatal Error] \((fileName.stringValue as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
Swift.fatalError(file: fileName, line: UInt(lineNumber))
}
}