WIP: clauses unit tests

This commit is contained in:
John Rommel Estropia
2016-05-26 01:03:01 +09:00
parent 02be72b0b7
commit 7942cf411e
14 changed files with 577 additions and 270 deletions

View File

@@ -60,7 +60,7 @@ import CoreData
- a version appears twice as a key in a dictionary literal
- a loop is found in any of the paths
*/
public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, DictionaryLiteralConvertible, ArrayLiteralConvertible {
public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, DictionaryLiteralConvertible, ArrayLiteralConvertible, Equatable {
/**
Initializes the `MigrationChain` with empty values, which instructs the `DataStack` to use the .xcdatamodel's current version as the final version, and to disable progressive migrations.
@@ -248,3 +248,16 @@ public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, D
private let versionTree: [String: String]
}
// MARK: - MigrationChain: Equatable
@warn_unused_result
public func == (lhs: MigrationChain, rhs: MigrationChain) -> Bool {
return lhs.versionTree == rhs.versionTree
&& lhs.rootVersions == rhs.rootVersions
&& lhs.leafVersions == rhs.leafVersions
&& lhs.valid == rhs.valid
}

View File

@@ -92,6 +92,38 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
self.bridgeToSwift.redo()
}
/**
Immediately flushes all pending changes to the transaction's observers. This is useful in conjunction with `ListMonitor`s and `ObjectMonitor`s created from `UnsafeDataTransaction`s used to manage temporary "scratch" data.
- Important: Note that unlike `commit()`, `flush()` does not propagate/save updates to the `DataStack` and the persistent store. However, the flushed changes will be seen by children transactions created further from the current transaction (i.e. through `transaction.beginUnsafe()`)
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
*/
@objc
public func flush(error error: NSErrorPointer) {
bridge(error) {
try self.bridgeToSwift.flush()
}
}
/**
Flushes all pending changes to the transaction's observers at the end of the `closure`'s execution. This is useful in conjunction with `ListMonitor`s and `ObjectMonitor`s created from `UnsafeDataTransaction`s used to manage temporary "scratch" data.
- Important: Note that unlike `commit()`, `flush()` does not propagate/save updates to the `DataStack` and the persistent store. However, the flushed changes will be seen by children transactions created further from the current transaction (i.e. through `transaction.beginUnsafe()`)
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
- parameter closure: the closure where changes can be made prior to the flush
*/
@objc
public func flush(error error: NSErrorPointer, block: () -> Void) throws {
bridge(error) {
block()
try self.bridgeToSwift.context.save()
}
}
/**
Begins a child transaction where `NSManagedObject` creates, updates, and deletes can be made. This is useful for making temporary changes, such as partially filled forms.

View File

@@ -36,7 +36,7 @@ public extension NSManagedObject {
When using an `UnsafeDataTransaction` and passing around a temporary object, you can use this property to execute fetches and updates to the transaction without having to pass around both the object and the transaction instances.
- Note: The internal reference to the transaction is `weak`, and it is still the developer's responsibility to retain a strong reference to the `UnsafeDataTransaction`.
- Important: The internal reference to the transaction is `weak`, and it is still the developer's responsibility to retain a strong reference to the `UnsafeDataTransaction`.
*/
@nonobjc
public var unsafeDataTransaction: UnsafeDataTransaction? {