Functions
The following functions are available globally.
-
Run the provided block. If a mach “BAD_INSTRUCTION” exception is raised, catch it and return a BadInstructionException (which captures stack information about the throw site, if desired). Otherwise return nil. NOTE: This function is only intended for use in test harnesses – use in a distributed build is almost certainly a bad choice. If a “BAD_INSTRUCTION” exception is raised, the block will be exited before completion via Objective-C exception. The risks associated with an Objective-C exception apply here: most Swift/Objective-C functions are not exception-safe. Memory may be leaked and the program will not necessarily be left in a safe state.
Declaration
Swift
public func catchBadInstruction(in block: @escaping () -> Void) -> BadInstructionException?
Parameters
block
a function without parameters that will be run
Return Value
if an EXC_BAD_INSTRUCTION is raised during the execution of
block
then a BadInstructionException will be returned, otherwisenil
. -
Undocumented
Declaration
Swift
public func MACH_MSGH_BITS_REMOTE(_ bits: UInt32) -> UInt32
-
Undocumented
Declaration
Swift
public func MACH_MSGH_BITS(_ remote: UInt32, _ local: UInt32) -> UInt32
-
withAssertionHandler(_:
Asynchronousfile: line: closure: ) Allows you to temporarily replace the current Nimble assertion handler with the one provided for the scope of the closure.
Once the closure finishes, then the original Nimble assertion handler is restored.
@warning Unlike the synchronous version of this call, this does not support catching Objective-C exceptions.
@see AssertionHandler
Declaration
Swift
public func withAssertionHandler(_ tempAssertionHandler: AssertionHandler, file: FileString = #file, line: UInt = #line, closure: () async throws -> Void) async
-
gatherExpectations(silently:
Asynchronousclosure: ) Captures expectations that occur in the given closure. Note that all expectations will still go through to the default Nimble handler.
This can be useful if you want to gather information about expectations that occur within a closure.
@warning Unlike the synchronous version of this call, this does not support catching Objective-C exceptions.
@param silently expectations are no longer send to the default Nimble assertion handler when this is true. Defaults to false.
@see gatherFailingExpectations
Declaration
Swift
public func gatherExpectations(silently: Bool = false, closure: () async -> Void) async -> [AssertionRecord]
-
gatherFailingExpectations(silently:
Asynchronousclosure: ) Captures failed expectations that occur in the given closure. Note that all expectations will still go through to the default Nimble handler.
This can be useful if you want to gather information about failed expectations that occur within a closure.
@warning Unlike the synchronous version of this call, this does not support catching Objective-C exceptions.
@param silently expectations are no longer send to the default Nimble assertion handler when this is true. Defaults to false.
@see gatherExpectations @see raiseException source for an example use case.
Declaration
Swift
public func gatherFailingExpectations(silently: Bool = false, closure: () async -> Void) async -> [AssertionRecord]
-
Allows you to temporarily replace the current Nimble assertion handler with the one provided for the scope of the closure.
@warning This form of
withAssertionHandler
does not work in any kind of async context. Use the async form ofwithAssertionHandler
if you are running tests in an async context.Once the closure finishes, then the original Nimble assertion handler is restored.
@see AssertionHandler
Declaration
Swift
public func withAssertionHandler(_ tempAssertionHandler: AssertionHandler, file: FileString = #file, line: UInt = #line, closure: () throws -> Void)
-
Captures expectations that occur in the given closure. Note that all expectations will still go through to the default Nimble handler.
This can be useful if you want to gather information about expectations that occur within a closure.
@warning This form of
gatherExpectations
does not work in any kind of async context. Use the async form ofgatherExpectations
if you are running tests in an async context.@param silently expectations are no longer send to the default Nimble assertion handler when this is true. Defaults to false.
@see gatherFailingExpectations
Declaration
Swift
public func gatherExpectations(silently: Bool = false, closure: () -> Void) -> [AssertionRecord]
-
Captures failed expectations that occur in the given closure. Note that all expectations will still go through to the default Nimble handler.
This can be useful if you want to gather information about failed expectations that occur within a closure.
@warning This form of
gatherFailingExpectations
does not work in any kind of async context. Use the async form ofgatherFailingExpectations
if you are running tests in an async context.@param silently expectations are no longer send to the default Nimble assertion handler when this is true. Defaults to false.
@see gatherExpectations @see raiseException source for an example use case.
Declaration
Swift
public func gatherFailingExpectations(silently: Bool = false, closure: () -> Void) -> [AssertionRecord]
-
Undocumented
Declaration
Swift
public func recordFailure(_ message: String, location: SourceLocation)
-
expect(file:
Asynchronousline: _: ) Make an
AsyncExpectation
on a given actual value. The value given is lazily evaluated.Declaration
Swift
public func expect<T>(file: FileString = #file, line: UInt = #line, _ expression: @escaping () async throws -> T?) async -> AsyncExpectation<T>
-
expect(file:
Asynchronousline: _: ) Make an
AsyncExpectation
on a given actual value. The closure is lazily invoked.Declaration
Swift
public func expect<T>(file: FileString = #file, line: UInt = #line, _ expression: () -> (() async throws -> T)) async -> AsyncExpectation<T>
-
expect(file:
Asynchronousline: _: ) Make an
AsyncExpectation
on a given actual value. The closure is lazily invoked.Declaration
Swift
public func expect<T>(file: FileString = #file, line: UInt = #line, _ expression: () -> (() async throws -> T?)) async -> AsyncExpectation<T>
-
expect(file:
Asynchronousline: _: ) Make an
AsyncExpectation
on a given actual value. The closure is lazily invoked.Declaration
Swift
public func expect(file: FileString = #file, line: UInt = #line, _ expression: () -> (() async throws -> Void)) async -> AsyncExpectation<Void>
-
waitUntil(timeout:
Asynchronousfile: line: action: ) Wait asynchronously until the done closure is called or the timeout has been reached.
@discussion Call the done() closure to indicate the waiting has completed.
@warning Unlike the synchronous version of this call, this does not support catching Objective-C exceptions.
Declaration
Swift
public func waitUntil(timeout: DispatchTimeInterval = AsyncDefaults.timeout, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) async -> Void) async
-
waitUntil(timeout:
Asynchronousfile: line: action: ) Wait asynchronously until the done closure is called or the timeout has been reached.
@discussion Call the done() closure to indicate the waiting has completed.
@warning Unlike the synchronous version of this call, this does not support catching Objective-C exceptions.
Declaration
Swift
public func waitUntil(timeout: DispatchTimeInterval = AsyncDefaults.timeout, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) async
-
Wait asynchronously until the done closure is called or the timeout has been reached.
@discussion Call the done() closure to indicate the waiting has completed.
This function manages the main run loop (
NSRunLoop.mainRunLoop()
) while this function is executing. Any attempts to touch the run loop may cause non-deterministic behavior.Declaration
Swift
@available(*, noasync, message: "the sync version of `waitUntil` does not work in async contexts. Use the async version with the same name as a drop-in replacement") public func waitUntil(timeout: DispatchTimeInterval = AsyncDefaults.timeout, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void)
-
Make an
Expectation
on a given actual value. The value given is lazily evaluated.Declaration
Swift
public func expect<T>(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure @escaping () throws -> T?) -> SyncExpectation<T>
-
Make an
Expectation
on a given actual value. The closure is lazily invoked.Declaration
Swift
public func expect<T>(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure () -> (() throws -> T)) -> SyncExpectation<T>
-
Make an
Expectation
on a given actual value. The closure is lazily invoked.Declaration
Swift
public func expect<T>(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure () -> (() throws -> T?)) -> SyncExpectation<T>
-
Make an
Expectation
on a given actual value. The closure is lazily invoked.Declaration
Swift
public func expect(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure () -> (() throws -> Void)) -> SyncExpectation<Void>
-
Always fails the test with a message and a specified location.
Declaration
Swift
public func fail(_ message: String, location: SourceLocation)
-
Always fails the test with a message.
Declaration
Swift
public func fail(_ message: String, file: FileString = #file, line: UInt = #line)
-
Always fails the test.
Declaration
Swift
public func fail(_ file: FileString = #file, line: UInt = #line)
-
Undocumented
Declaration
Swift
public func allPass<S: Sequence>( _ passFunc: @escaping (S.Element) throws -> Bool ) -> Predicate<S>
-
Undocumented
Declaration
Swift
public func allPass<S: Sequence>( _ passName: String, _ passFunc: @escaping (S.Element) throws -> Bool ) -> Predicate<S>
-
A Nimble matcher that succeeds when the actual value is an instance of the given class.
Declaration
Swift
public func beAKindOf<T>(_ expectedType: T.Type) -> Predicate<Any>
-
A Nimble matcher that succeeds when the actual value is an instance of the given class. @see beAnInstanceOf if you want to match against the exact class
Declaration
Swift
public func beAKindOf(_ expectedClass: AnyClass) -> Predicate<NSObject>
-
A Nimble matcher that succeeds when the actual value is an exact instance of the given class.
Declaration
Swift
public func beAnInstanceOf<T>(_ expectedType: T.Type) -> Predicate<Any>
-
A Nimble matcher that succeeds when the actual value is an instance of the given class. @see beAKindOf if you want to match against subclasses
Declaration
Swift
public func beAnInstanceOf(_ expectedClass: AnyClass) -> Predicate<NSObject>
-
Undocumented
Declaration
Swift
public func defaultDelta<F>() -> F where F : FloatingPoint
-
A Nimble matcher that succeeds when a value is close to another. This is used for floating point values which can have imprecise results when doing arithmetic on them.
@see equal
Declaration
Swift
public func beCloseTo<Value: FloatingPoint>( _ expectedValue: Value, within delta: Value = defaultDelta() ) -> Predicate<Value>
-
A Nimble matcher that succeeds when a value is close to another. This is used for floating point values which can have imprecise results when doing arithmetic on them.
@see equal
Declaration
Swift
public func beCloseTo<Value: NMBDoubleConvertible>( _ expectedValue: Value, within delta: Double = DefaultDelta ) -> Predicate<Value>
-
Undocumented
Declaration
Swift
public func beCloseTo<Value: FloatingPoint, Values: Collection>( _ expectedValues: Values, within delta: Value = defaultDelta() ) -> Predicate<Values> where Values.Element == Value
-
Undocumented
Declaration
Swift
public func ≈ <Exp, Value>(lhs: Exp, rhs: Value) where Exp : Expectation, Value : Collection, Value == Exp.Value, Value.Element : FloatingPoint
-
Undocumented
Declaration
Swift
public func ≈ <Exp, Value>(lhs: Exp, rhs: Value) where Exp : Expectation, Value : FloatingPoint, Value == Exp.Value
-
Undocumented
Declaration
Swift
public func ≈ <Exp, Value>(lhs: Exp, rhs: (expected: Value, delta: Value)) where Exp : Expectation, Value : FloatingPoint, Value == Exp.Value
-
Undocumented
Declaration
Swift
public func == <Exp, Value>(lhs: Exp, rhs: (expected: Value, delta: Value)) where Exp : Expectation, Value : FloatingPoint, Value == Exp.Value
-
Undocumented
Declaration
Swift
public func ≈ <Exp, Value>(lhs: Exp, rhs: Value) where Exp : Expectation, Value : NMBDoubleConvertible, Value == Exp.Value
-
Undocumented
Declaration
Swift
public func ≈ <Exp, Value>(lhs: Exp, rhs: (expected: Value, delta: Double)) where Exp : Expectation, Value : NMBDoubleConvertible, Value == Exp.Value
-
Undocumented
Declaration
Swift
public func == <Exp, Value>(lhs: Exp, rhs: (expected: Value, delta: Double)) where Exp : Expectation, Value : NMBDoubleConvertible, Value == Exp.Value
-
Undocumented
Declaration
Swift
public func ± <Value>(lhs: Value, rhs: Value) -> (expected: Value, delta: Value) where Value : FloatingPoint
-
Undocumented
Declaration
Swift
public func ± <Value>(lhs: Value, rhs: Double) -> (expected: Value, delta: Double) where Value : NMBDoubleConvertible
-
A Nimble matcher that succeeds when a value is “empty”. For collections, this means the are no items in that collection. For strings, it is an empty string.
Declaration
Swift
public func beEmpty<S>() -> Predicate<S> where S : Sequence
-
A Nimble matcher that succeeds when a value is “empty”. For collections, this means the are no items in that collection. For strings, it is an empty string.
Declaration
Swift
public func beEmpty<S>() -> Predicate<S> where S : SetAlgebra
-
A Nimble matcher that succeeds when a value is “empty”. For collections, this means the are no items in that collection. For strings, it is an empty string.
Declaration
Swift
public func beEmpty<S>() -> Predicate<S> where S : Sequence, S : SetAlgebra
-
A Nimble matcher that succeeds when a value is “empty”. For collections, this means the are no items in that collection. For strings, it is an empty string.
Declaration
Swift
public func beEmpty() -> Predicate<String>
-
A Nimble matcher that succeeds when a value is “empty”. For collections, this means the are no items in that collection. For NSString instances, it is an empty string.
Declaration
Swift
public func beEmpty() -> Predicate<NSString>
-
A Nimble matcher that succeeds when a value is “empty”. For collections, this means the are no items in that collection. For strings, it is an empty string.
Declaration
Swift
public func beEmpty() -> Predicate<NSDictionary>
-
A Nimble matcher that succeeds when a value is “empty”. For collections, this means the are no items in that collection. For strings, it is an empty string.
Declaration
Swift
public func beEmpty() -> Predicate<NSArray>
-
A Nimble matcher that succeeds when a value is “empty”. For collections, this means the are no items in that collection. For strings, it is an empty string.
Declaration
Swift
public func beEmpty() -> Predicate<NMBCollection>
-
A Nimble matcher that succeeds when the actual value is greater than the expected value.
Declaration
Swift
public func beGreaterThan<T>(_ expectedValue: T?) -> Predicate<T> where T : Comparable
-
Undocumented
Declaration
Swift
public func > <Exp, T>(lhs: Exp, rhs: T) where Exp : Expectation, T : Comparable, T == Exp.Value
-
A Nimble matcher that succeeds when the actual value is greater than the expected value.
Declaration
Swift
public func beGreaterThan<T>(_ expectedValue: T?) -> Predicate<T> where T : NMBComparable
-
Undocumented
Declaration
Swift
public func > <Exp, T>(lhs: Exp, rhs: T?) where Exp : Expectation, T : NMBComparable, T == Exp.Value
-
A Nimble matcher that succeeds when the actual value is greater than or equal to the expected value.
Declaration
Swift
public func beGreaterThanOrEqualTo<T>(_ expectedValue: T?) -> Predicate<T> where T : Comparable
-
Undocumented
Declaration
Swift
public func >= <Exp, T>(lhs: Exp, rhs: T) where Exp : Expectation, T : Comparable, T == Exp.Value
-
A Nimble matcher that succeeds when the actual value is greater than or equal to the expected value.
Declaration
Swift
public func beGreaterThanOrEqualTo<T>(_ expectedValue: T?) -> Predicate<T> where T : NMBComparable
-
Undocumented
Declaration
Swift
public func >= <Exp, T>(lhs: Exp, rhs: T) where Exp : Expectation, T : NMBComparable, T == Exp.Value
-
A Nimble matcher that succeeds when the actual value is the same instance as the expected instance.
Declaration
Swift
public func beIdenticalTo(_ expected: AnyObject?) -> Predicate<AnyObject>
-
Undocumented
Declaration
Swift
public func === <Exp>(lhs: Exp, rhs: AnyObject?) where Exp : Expectation, Exp.Value == AnyObject
-
Undocumented
Declaration
Swift
public func !== <Exp>(lhs: Exp, rhs: AnyObject?) where Exp : Expectation, Exp.Value == AnyObject
-
A Nimble matcher that succeeds when the actual value is the same instance as the expected instance.
Alias for “beIdenticalTo”.
Declaration
Swift
public func be(_ expected: AnyObject?) -> Predicate<AnyObject>
-
A Nimble matcher that succeeds when the actual value is less than the expected value.
Declaration
Swift
public func beLessThan<T>(_ expectedValue: T?) -> Predicate<T> where T : Comparable
-
Undocumented
Declaration
Swift
public func < <Exp, V>(lhs: Exp, rhs: V) where Exp : Expectation, V : Comparable, V == Exp.Value
-
A Nimble matcher that succeeds when the actual value is less than the expected value.
Declaration
Swift
public func beLessThan<T>(_ expectedValue: T?) -> Predicate<T> where T : NMBComparable
-
Undocumented
Declaration
Swift
public func < <Exp, V>(lhs: Exp, rhs: V?) where Exp : Expectation, V : NMBComparable, V == Exp.Value
-
A Nimble matcher that succeeds when the actual value is less than or equal to the expected value.
Declaration
Swift
public func beLessThanOrEqualTo<T>(_ expectedValue: T?) -> Predicate<T> where T : Comparable
-
Undocumented
Declaration
Swift
public func <= <Exp, T>(lhs: Exp, rhs: T) where Exp : Expectation, T : Comparable, T == Exp.Value
-
A Nimble matcher that succeeds when the actual value is less than or equal to the expected value.
Declaration
Swift
public func beLessThanOrEqualTo<T>(_ expectedValue: T?) -> Predicate<T> where T : NMBComparable
-
Undocumented
Declaration
Swift
public func <= <Exp, T>(lhs: Exp, rhs: T) where Exp : Expectation, T : NMBComparable, T == Exp.Value
-
A Nimble matcher that succeeds when the actual value is exactly true. This matcher will not match against nils.
Declaration
Swift
public func beTrue() -> Predicate<Bool>
-
A Nimble matcher that succeeds when the actual value is exactly false. This matcher will not match against nils.
Declaration
Swift
public func beFalse() -> Predicate<Bool>
-
A Nimble matcher that succeeds when the actual value is not logically false.
Declaration
Swift
public func beTruthy<T>() -> Predicate<T> where T : Equatable, T : ExpressibleByBooleanLiteral
-
A Nimble matcher that succeeds when the actual value is logically false. This matcher will match against nils.
Declaration
Swift
public func beFalsy<T>() -> Predicate<T> where T : Equatable, T : ExpressibleByBooleanLiteral
-
A Nimble matcher that succeeds when the actual value is nil.
Declaration
Swift
public func beNil<T>() -> Predicate<T>
-
A Nimble matcher for Result that succeeds when the actual value is success.
You can pass a closure to do any arbitrary custom matching to the value inside result. The closure only gets called when the result is success.
Declaration
Swift
public func beSuccess<Success, Failure>( test: ((Success) -> Void)? = nil ) -> Predicate<Result<Success, Failure>>
-
A Nimble matcher for Result that succeeds when the actual value is failure.
You can pass a closure to do any arbitrary custom matching to the error inside result. The closure only gets called when the result is failure.
Declaration
Swift
public func beFailure<Success, Failure>( test: ((Failure) -> Void)? = nil ) -> Predicate<Result<Success, Failure>>
-
A Nimble matcher that succeeds when the actual value is Void.
Declaration
Swift
public func beVoid() -> Predicate<()>
-
Undocumented
Declaration
Swift
public func == <Exp>(lhs: Exp, rhs: ()) where Exp : Expectation, Exp.Value == ()
-
Undocumented
Declaration
Swift
public func != <Exp>(lhs: Exp, rhs: ()) where Exp : Expectation, Exp.Value == ()
-
A Nimble matcher that succeeds when the actual value is within given range.
Declaration
Swift
public func beWithin<T>(_ range: Range<T>) -> Predicate<T> where T : Comparable
-
A Nimble matcher that succeeds when the actual value is within given range.
Declaration
Swift
public func beWithin<T>(_ range: ClosedRange<T>) -> Predicate<T> where T : Comparable
-
A Nimble matcher that succeeds when the actual sequence’s first element is equal to the expected value.
Declaration
Swift
public func beginWith<S>(_ startingElement: S.Element) -> Predicate<S> where S : Sequence, S.Element : Equatable
-
A Nimble matcher that succeeds when the actual collection’s first element is equal to the expected object.
Declaration
Swift
public func beginWith(_ startingElement: Any) -> Predicate<NMBOrderedCollection>
-
A Nimble matcher that succeeds when the actual string contains expected substring where the expected substring’s location is zero.
Declaration
Swift
public func beginWith(_ startingSubstring: String) -> Predicate<String>
-
A Nimble matcher that succeeds when the exepected sequence is a prefix of the actual sequence.
This is a matcher abstraction for https://developer.apple.com/documentation/swift/sequence/2854218-starts
Declaration
Swift
public func beginWith<Seq1: Sequence, Seq2: Sequence>(prefix expectedPrefix: Seq2?) -> Predicate<Seq1> where Seq1.Element: Equatable, Seq1.Element == Seq2.Element
-
A Nimble matcher that succeeds when the expected sequence is the prefix of the actual sequence, using the given predicate as the equivalence test.
This is a matcher abstraction for https://developer.apple.com/documentation/swift/sequence/2996828-starts
Declaration
Swift
public func beginWith<Seq1: Sequence, Seq2: Sequence>( prefix expectedPrefix: Seq2?, by areEquivalent: @escaping (Seq1.Element, Seq2.Element) -> Bool ) -> Predicate<Seq1>
-
A Nimble matcher that succeeds when the actual sequence contains the expected values.
Declaration
Swift
public func contain<S>(_ items: S.Element...) -> Predicate<S> where S : Sequence, S.Element : Equatable
-
A Nimble matcher that succeeds when the actual sequence contains the expected values.
Declaration
Swift
public func contain<S>(_ items: [S.Element]) -> Predicate<S> where S : Sequence, S.Element : Equatable
-
A Nimble matcher that succeeds when the actual set contains the expected values.
Declaration
Swift
public func contain<S>(_ items: S.Element...) -> Predicate<S> where S : SetAlgebra, S.Element : Equatable
-
A Nimble matcher that succeeds when the actual set contains the expected values.
Declaration
Swift
public func contain<S>(_ items: [S.Element]) -> Predicate<S> where S : SetAlgebra, S.Element : Equatable
-
A Nimble matcher that succeeds when the actual set contains the expected values.
Declaration
Swift
public func contain<S>(_ items: S.Element...) -> Predicate<S> where S : Sequence, S : SetAlgebra, S.Element : Equatable
-
A Nimble matcher that succeeds when the actual set contains the expected values.
Declaration
Swift
public func contain<S>(_ items: [S.Element]) -> Predicate<S> where S : Sequence, S : SetAlgebra, S.Element : Equatable
-
A Nimble matcher that succeeds when the actual string contains the expected substring.
Declaration
Swift
public func contain(_ substrings: String...) -> Predicate<String>
-
Undocumented
Declaration
Swift
public func contain(_ substrings: [String]) -> Predicate<String>
-
A Nimble matcher that succeeds when the actual string contains the expected substring.
Declaration
Swift
public func contain(_ substrings: NSString...) -> Predicate<NSString>
-
Undocumented
Declaration
Swift
public func contain(_ substrings: [NSString]) -> Predicate<NSString>
-
A Nimble matcher that succeeds when the actual collection contains the expected object.
Declaration
Swift
public func contain(_ items: Any?...) -> Predicate<NMBContainer>
-
Undocumented
Declaration
Swift
public func contain(_ items: [Any?]) -> Predicate<NMBContainer>
-
Undocumented
Declaration
Swift
public func containElementSatisfying<S: Sequence>( _ predicate: @escaping ((S.Element) -> Bool), _ predicateDescription: String = "" ) -> Predicate<S>
-
A Nimble matcher that succeeds when the actual sequence and the exepected sequence contain the same elements in the same order.
This is a matcher abstraction for https://developer.apple.com/documentation/swift/sequence/2854213-elementsequal
Declaration
Swift
public func elementsEqual<Seq1: Sequence, Seq2: Sequence>( _ expectedValue: Seq2? ) -> Predicate<Seq1> where Seq1.Element: Equatable, Seq1.Element == Seq2.Element
-
A Nimble matcher that succeeds when the actual sequence and the exepected sequence contain equivalent elements in the same order, using the given predicate as the equivalence test.
This is a matcher abstraction for https://developer.apple.com/documentation/swift/sequence/2949668-elementsequal
Declaration
Swift
public func elementsEqual<Seq1: Sequence, Seq2: Sequence>( _ expectedValue: Seq2?, by areEquivalent: @escaping (Seq1.Element, Seq2.Element) -> Bool ) -> Predicate<Seq1>
-
A Nimble matcher that succeeds when the actual sequence’s last element is equal to the expected value.
Declaration
Swift
public func endWith<S>(_ endingElement: S.Element) -> Predicate<S> where S : Sequence, S.Element : Equatable
-
A Nimble matcher that succeeds when the actual collection’s last element is equal to the expected object.
Declaration
Swift
public func endWith(_ endingElement: Any) -> Predicate<NMBOrderedCollection>
-
A Nimble matcher that succeeds when the actual string contains the expected substring where the expected substring’s location is the actual string’s length minus the expected substring’s length.
Declaration
Swift
public func endWith(_ endingSubstring: String) -> Predicate<String>
-
A Nimble matcher that succeeds when the actual tuple is equal to the expected tuple. Values can support equal by supporting the Equatable protocol.
Declaration
Swift
public func equal<T1: Equatable, T2: Equatable>( _ expectedValue: (T1, T2)? ) -> Predicate<(T1, T2)>
-
Undocumented
Declaration
Swift
public func ==<T1: Equatable, T2: Equatable>( lhs: SyncExpectation<(T1, T2)>, rhs: (T1, T2)? )
-
Undocumented
Declaration
Swift
public func ==<T1: Equatable, T2: Equatable>( lhs: AsyncExpectation<(T1, T2)>, rhs: (T1, T2)? )
-
Undocumented
Declaration
Swift
public func !=<T1: Equatable, T2: Equatable>( lhs: SyncExpectation<(T1, T2)>, rhs: (T1, T2)? )
-
Undocumented
Declaration
Swift
public func !=<T1: Equatable, T2: Equatable>( lhs: AsyncExpectation<(T1, T2)>, rhs: (T1, T2)? )
-
A Nimble matcher that succeeds when the actual tuple is equal to the expected tuple. Values can support equal by supporting the Equatable protocol.
Declaration
Swift
public func equal<T1: Equatable, T2: Equatable, T3: Equatable>( _ expectedValue: (T1, T2, T3)? ) -> Predicate<(T1, T2, T3)>
-
Undocumented
Declaration
Swift
public func ==<T1: Equatable, T2: Equatable, T3: Equatable>( lhs: SyncExpectation<(T1, T2, T3)>, rhs: (T1, T2, T3)? )
-
Undocumented
Declaration
Swift
public func ==<T1: Equatable, T2: Equatable, T3: Equatable>( lhs: AsyncExpectation<(T1, T2, T3)>, rhs: (T1, T2, T3)? )
-
Undocumented
Declaration
Swift
public func !=<T1: Equatable, T2: Equatable, T3: Equatable>( lhs: SyncExpectation<(T1, T2, T3)>, rhs: (T1, T2, T3)? )
-
Undocumented
Declaration
Swift
public func !=<T1: Equatable, T2: Equatable, T3: Equatable>( lhs: AsyncExpectation<(T1, T2, T3)>, rhs: (T1, T2, T3)? )
-
A Nimble matcher that succeeds when the actual tuple is equal to the expected tuple. Values can support equal by supporting the Equatable protocol.
Declaration
Swift
public func equal<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable>( _ expectedValue: (T1, T2, T3, T4)? ) -> Predicate<(T1, T2, T3, T4)>
-
Undocumented
Declaration
Swift
public func ==<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable>( lhs: SyncExpectation<(T1, T2, T3, T4)>, rhs: (T1, T2, T3, T4)? )
-
Undocumented
Declaration
Swift
public func ==<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable>( lhs: AsyncExpectation<(T1, T2, T3, T4)>, rhs: (T1, T2, T3, T4)? )
-
Undocumented
Declaration
Swift
public func !=<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable>( lhs: SyncExpectation<(T1, T2, T3, T4)>, rhs: (T1, T2, T3, T4)? )
-
Undocumented
Declaration
Swift
public func !=<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable>( lhs: AsyncExpectation<(T1, T2, T3, T4)>, rhs: (T1, T2, T3, T4)? )
-
A Nimble matcher that succeeds when the actual tuple is equal to the expected tuple. Values can support equal by supporting the Equatable protocol.
Declaration
Swift
public func equal<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable, T5: Equatable>( _ expectedValue: (T1, T2, T3, T4, T5)? ) -> Predicate<(T1, T2, T3, T4, T5)>
-
Undocumented
Declaration
Swift
public func ==<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable, T5: Equatable>( lhs: SyncExpectation<(T1, T2, T3, T4, T5)>, rhs: (T1, T2, T3, T4, T5)? )
-
Undocumented
Declaration
Swift
public func ==<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable, T5: Equatable>( lhs: AsyncExpectation<(T1, T2, T3, T4, T5)>, rhs: (T1, T2, T3, T4, T5)? )
-
Undocumented
Declaration
Swift
public func !=<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable, T5: Equatable>( lhs: SyncExpectation<(T1, T2, T3, T4, T5)>, rhs: (T1, T2, T3, T4, T5)? )
-
Undocumented
Declaration
Swift
public func !=<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable, T5: Equatable>( lhs: AsyncExpectation<(T1, T2, T3, T4, T5)>, rhs: (T1, T2, T3, T4, T5)? )
-
A Nimble matcher that succeeds when the actual tuple is equal to the expected tuple. Values can support equal by supporting the Equatable protocol.
Declaration
Swift
public func equal<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable, T5: Equatable, T6: Equatable>( _ expectedValue: (T1, T2, T3, T4, T5, T6)? ) -> Predicate<(T1, T2, T3, T4, T5, T6)>
-
Undocumented
Declaration
Swift
public func ==<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable, T5: Equatable, T6: Equatable>( lhs: SyncExpectation<(T1, T2, T3, T4, T5, T6)>, rhs: (T1, T2, T3, T4, T5, T6)? )
-
Undocumented
Declaration
Swift
public func ==<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable, T5: Equatable, T6: Equatable>( lhs: AsyncExpectation<(T1, T2, T3, T4, T5, T6)>, rhs: (T1, T2, T3, T4, T5, T6)? )
-
Undocumented
Declaration
Swift
public func !=<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable, T5: Equatable, T6: Equatable>( lhs: SyncExpectation<(T1, T2, T3, T4, T5, T6)>, rhs: (T1, T2, T3, T4, T5, T6)? )
-
Undocumented
Declaration
Swift
public func !=<T1: Equatable, T2: Equatable, T3: Equatable, T4: Equatable, T5: Equatable, T6: Equatable>( lhs: AsyncExpectation<(T1, T2, T3, T4, T5, T6)>, rhs: (T1, T2, T3, T4, T5, T6)? )
-
A Nimble matcher that succeeds when the actual value is equal to the expected value. Values can support equal by supporting the Equatable protocol.
@see beCloseTo if you want to match imprecise types (eg - floats, doubles).
Declaration
Swift
public func equal<T>(_ expectedValue: T) -> Predicate<T> where T : Equatable
-
A Nimble matcher allowing comparison of collection with optional type
Declaration
Swift
public func equal<T>(_ expectedValue: [T?]) -> Predicate<[T?]> where T : Equatable
-
A Nimble matcher that succeeds when the actual value is equal to the expected value. Values can support equal by supporting the Equatable protocol.
@see beCloseTo if you want to match imprecise types (eg - floats, doubles).
Declaration
Swift
public func equal<T>(_ expectedValue: T?) -> Predicate<T> where T : Equatable
-
A Nimble matcher that succeeds when the actual set is equal to the expected set.
Declaration
Swift
public func equal<T>(_ expectedValue: Set<T>) -> Predicate<Set<T>> where T : Hashable
-
A Nimble matcher that succeeds when the actual set is equal to the expected set.
Declaration
Swift
public func equal<T>(_ expectedValue: Set<T>?) -> Predicate<Set<T>> where T : Hashable
-
A Nimble matcher that succeeds when the actual set is equal to the expected set.
Declaration
Swift
public func equal<T>(_ expectedValue: Set<T>) -> Predicate<Set<T>> where T : Comparable, T : Hashable
-
A Nimble matcher that succeeds when the actual set is equal to the expected set.
Declaration
Swift
public func equal<T>(_ expectedValue: Set<T>?) -> Predicate<Set<T>> where T : Comparable, T : Hashable
-
A Nimble matcher that succeeds when the actual dictionary is equal to the expected dictionary
Declaration
Swift
public func equal<K, V>(_ expectedValue: [K : V?]) -> Predicate<[K : V]> where K : Hashable, V : Equatable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: SyncExpectation<T>, rhs: T) where T : Equatable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: SyncExpectation<T>, rhs: T?) where T : Equatable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: SyncExpectation<T>, rhs: T) where T : Equatable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: SyncExpectation<T>, rhs: T?) where T : Equatable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: SyncExpectation<[T]>, rhs: [T]?) where T : Equatable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: SyncExpectation<[T]>, rhs: [T]?) where T : Equatable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: SyncExpectation<Set<T>>, rhs: Set<T>) where T : Hashable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: SyncExpectation<Set<T>>, rhs: Set<T>?) where T : Hashable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: SyncExpectation<Set<T>>, rhs: Set<T>) where T : Hashable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: SyncExpectation<Set<T>>, rhs: Set<T>?) where T : Hashable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: SyncExpectation<Set<T>>, rhs: Set<T>) where T : Comparable, T : Hashable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: SyncExpectation<Set<T>>, rhs: Set<T>?) where T : Comparable, T : Hashable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: SyncExpectation<Set<T>>, rhs: Set<T>) where T : Comparable, T : Hashable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: SyncExpectation<Set<T>>, rhs: Set<T>?) where T : Comparable, T : Hashable
-
Undocumented
Declaration
Swift
public func == <T, C>(lhs: SyncExpectation<[T : C]>, rhs: [T : C]?) where T : Hashable, C : Equatable
-
Undocumented
Declaration
Swift
public func != <T, C>(lhs: SyncExpectation<[T : C]>, rhs: [T : C]?) where T : Hashable, C : Equatable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: AsyncExpectation<T>, rhs: T) where T : Equatable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: AsyncExpectation<T>, rhs: T?) where T : Equatable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: AsyncExpectation<T>, rhs: T) where T : Equatable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: AsyncExpectation<T>, rhs: T?) where T : Equatable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: AsyncExpectation<[T]>, rhs: [T]?) where T : Equatable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: AsyncExpectation<[T]>, rhs: [T]?) where T : Equatable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: AsyncExpectation<Set<T>>, rhs: Set<T>) where T : Hashable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: AsyncExpectation<Set<T>>, rhs: Set<T>?) where T : Hashable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: AsyncExpectation<Set<T>>, rhs: Set<T>) where T : Hashable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: AsyncExpectation<Set<T>>, rhs: Set<T>?) where T : Hashable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: AsyncExpectation<Set<T>>, rhs: Set<T>) where T : Comparable, T : Hashable
-
Undocumented
Declaration
Swift
public func == <T>(lhs: AsyncExpectation<Set<T>>, rhs: Set<T>?) where T : Comparable, T : Hashable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: AsyncExpectation<Set<T>>, rhs: Set<T>) where T : Comparable, T : Hashable
-
Undocumented
Declaration
Swift
public func != <T>(lhs: AsyncExpectation<Set<T>>, rhs: Set<T>?) where T : Comparable, T : Hashable
-
Undocumented
Declaration
Swift
public func == <T, C>(lhs: AsyncExpectation<[T : C]>, rhs: [T : C]?) where T : Hashable, C : Equatable
-
Undocumented
Declaration
Swift
public func != <T, C>(lhs: AsyncExpectation<[T : C]>, rhs: [T : C]?) where T : Hashable, C : Equatable
-
A Nimble matcher that succeeds when the actual Collection’s count equals the expected value
Declaration
Swift
public func haveCount<T>(_ expectedValue: Int) -> Predicate<T> where T : Collection
-
A Nimble matcher that succeeds when the actual collection’s count equals the expected value
Declaration
Swift
public func haveCount(_ expectedValue: Int) -> Predicate<NMBCollection>
-
A Nimble matcher that succeeds when the actual string satisfies the regular expression described by the expected string.
Declaration
Swift
public func match(_ expectedValue: String?) -> Predicate<String>
-
A Nimble matcher that succeeds when the actual expression evaluates to an error from the specified case.
Errors are tried to be compared by their implementation of Equatable, otherwise they fallback to comparison by _domain and _code.
Declaration
Swift
public func matchError<T>(_ error: T) -> Predicate<Error> where T : Error
-
A Nimble matcher that succeeds when the actual expression evaluates to an error from the specified case.
Errors are tried to be compared by their implementation of Equatable, otherwise they fallback to comparision by _domain and _code.
Declaration
Swift
public func matchError<T>(_ error: T) -> Predicate<Error> where T : Equatable, T : Error
-
A Nimble matcher that succeeds when the actual expression evaluates to an error of the specified type
Declaration
Swift
public func matchError<T>(_ errorType: T.Type) -> Predicate<Error> where T : Error
-
A Nimble matcher that succeeds when the actual expression raises an exception with the specified name, reason, and/or userInfo.
Alternatively, you can pass a closure to do any arbitrary custom matching to the raised exception. The closure only gets called when an exception is raised.
nil arguments indicates that the matcher should not attempt to match against that parameter.
Declaration
Swift
public func raiseException<Out>( named: NSExceptionName? = nil, reason: String? = nil, userInfo: NSDictionary? = nil, closure: ((NSException) -> Void)? = nil ) -> Predicate<Out>
-
A Nimble matcher that succeeds when the actual expression raises an exception with the specified name, reason, and/or userInfo.
Alternatively, you can pass a closure to do any arbitrary custom matching to the raised exception. The closure only gets called when an exception is raised.
nil arguments indicates that the matcher should not attempt to match against that parameter.
Declaration
Swift
public func raiseException<Out>( named: String?, reason: String? = nil, userInfo: NSDictionary? = nil, closure: ((NSException) -> Void)? = nil ) -> Predicate<Out>
-
Run the provided block. If a POSIX SIGILL is received, handle it and return a BadInstructionException (which is just an empty object in this POSIX signal version). Otherwise return nil. NOTE: This function is only intended for use in test harnesses – use in a distributed build is almost certainly a bad choice. If a SIGILL is received, the block will be interrupted using a C
longjmp
. The risks associated with abrupt jumps apply here: most Swift functions are not interrupt-safe. Memory may be leaked and the program will not necessarily be left in a safe state. -
Undocumented
Declaration
Swift
public func throwAssertion<Out>() -> Predicate<Out>
-
A Nimble matcher that succeeds when the actual expression throws an error of the specified type or from the specified case.
Errors are tried to be compared by their implementation of Equatable, otherwise they fallback to comparison by _domain and _code.
Alternatively, you can pass a closure to do any arbitrary custom matching to the thrown error. The closure only gets called when an error was thrown.
nil arguments indicates that the matcher should not attempt to match against that parameter.
Declaration
Swift
public func throwError<Out>() -> Predicate<Out>
-
A Nimble matcher that succeeds when the actual expression throws an error of the specified type or from the specified case.
Errors are tried to be compared by their implementation of Equatable, otherwise they fallback to comparision by _domain and _code.
Alternatively, you can pass a closure to do any arbitrary custom matching to the thrown error. The closure only gets called when an error was thrown.
nil arguments indicates that the matcher should not attempt to match against that parameter.
Declaration
Swift
public func throwError<T, Out>(_ error: T, closure: ((Error) -> Void)? = nil) -> Predicate<Out> where T : Error
-
A Nimble matcher that succeeds when the actual expression throws an error of the specified type or from the specified case.
Errors are tried to be compared by their implementation of Equatable, otherwise they fallback to comparision by _domain and _code.
Alternatively, you can pass a closure to do any arbitrary custom matching to the thrown error. The closure only gets called when an error was thrown.
nil arguments indicates that the matcher should not attempt to match against that parameter.
Declaration
Swift
public func throwError<T, Out>(_ error: T, closure: ((T) -> Void)? = nil) -> Predicate<Out> where T : Equatable, T : Error
-
A Nimble matcher that succeeds when the actual expression throws an error of the specified type or from the specified case.
Errors are tried to be compared by their implementation of Equatable, otherwise they fallback to comparision by _domain and _code.
Alternatively, you can pass a closure to do any arbitrary custom matching to the thrown error. The closure only gets called when an error was thrown.
nil arguments indicates that the matcher should not attempt to match against that parameter.
Declaration
Swift
public func throwError<T: Error, Out>( errorType: T.Type, closure: ((T) -> Void)? = nil ) -> Predicate<Out>
-
A Nimble matcher that succeeds when the actual expression throws any error or when the passed closures’ arbitrary custom matching succeeds.
This duplication to it’s generic adequate is required to allow to receive values of the existential type
Error
in the closure.The closure only gets called when an error was thrown.
Declaration
Swift
public func throwError<Out>(closure: @escaping ((Error) -> Void)) -> Predicate<Out>
-
A Nimble matcher that succeeds when the actual expression throws any error or when the passed closures’ arbitrary custom matching succeeds.
This duplication to it’s generic adequate is required to allow to receive values of the existential type
Error
in the closure.The closure only gets called when an error was thrown.
Declaration
Swift
public func throwError<T, Out>(closure: @escaping ((T) -> Void)) -> Predicate<Out> where T : Error
-
A Nimble matcher that takes in a closure for validation.
Return
.succeeded
when the validation succeeds. Return.failed
with a failure reason when the validation fails.Declaration
Swift
public func succeed() -> Predicate<ToSucceedResult>
-
Returns a string appropriate for displaying in test output from the provided value.
See also
Declaration
Swift
public func stringify<T>(_ value: T?) -> String
Parameters
value
A value that will show up in a test’s output.
Return Value
The string that is returned can be customized per type by conforming a type to the
TestOutputStringConvertible
protocol. When stringifying a non-TestOutputStringConvertible
type, this function will return the value’s debug description and then its normal description if available and in that order. Otherwise it will return the result of constructing a string from the value.
-
Attempts to generate a pretty type string for a given value. If the value is of a Objective-C collection type, or a subclass thereof, (e.g.
NSArray
,NSDictionary
, etc.). This function will return the type name of the root class of the class cluster for better readability (e.g.NSArray
instead of__NSArrayI
).For values that don’t have a type of an Objective-C collection, this function returns the default type description.
Declaration
Swift
public func prettyCollectionType<T>(_ value: T) -> String
Parameters
value
A value that will be used to determine a type name.
Return Value
The name of the class cluster root class for Objective-C collection types, or the the
dynamicType
of the value for values of any other type. -
Returns the type name for a given collection type. This overload is used by Swift collection types.
Declaration
Swift
public func prettyCollectionType<T>(_ collection: T) -> String where T : Collection
Parameters
collection
A Swift
CollectionType
value.Return Value
A string representing the
dynamicType
of the value.