From b08e22a797195047525a53ff2027565204095b56 Mon Sep 17 00:00:00 2001 From: Yurii Samsoniuk Date: Thu, 22 Dec 2016 21:51:17 +0100 Subject: [PATCH] % swiftlint autocorrect --- .../CwlBadInstructionException.swift | 18 ++++---- .../CwlCatchBadInstruction.swift | 41 +++++++++---------- .../CwlCatchBadInstructionPOSIX.swift | 6 +-- .../CwlDarwinDefinitions.swift | 2 +- .../Nimble/Adapters/AssertionDispatcher.swift | 1 - .../Nimble/Adapters/AssertionRecorder.swift | 2 +- Sources/Nimble/Adapters/NMBExpectation.swift | 6 +-- Sources/Nimble/Adapters/NMBObjCMatcher.swift | 2 +- .../Nimble/Adapters/NimbleXCTestHandler.swift | 5 +-- Sources/Nimble/Expectation.swift | 15 +++---- Sources/Nimble/FailureMessage.swift | 2 +- Sources/Nimble/Matchers/AllPass.swift | 29 ++++++------- .../Nimble/Matchers/AsyncMatcherWrapper.swift | 15 +++---- Sources/Nimble/Matchers/BeCloseTo.swift | 2 +- Sources/Nimble/Matchers/BeEmpty.swift | 1 - Sources/Nimble/Matchers/BeGreaterThan.swift | 1 - Sources/Nimble/Matchers/BeIdenticalTo.swift | 1 - Sources/Nimble/Matchers/BeVoid.swift | 2 +- Sources/Nimble/Matchers/BeginWith.swift | 4 +- Sources/Nimble/Matchers/Contain.swift | 6 +-- Sources/Nimble/Matchers/EndWith.swift | 7 +--- Sources/Nimble/Matchers/Equal.swift | 6 +-- Sources/Nimble/Matchers/Match.swift | 2 +- .../Nimble/Matchers/MatcherProtocols.swift | 4 +- Sources/Nimble/Matchers/RaisesException.swift | 4 +- Sources/Nimble/Matchers/SatisfyAnyOf.swift | 19 ++++----- Sources/Nimble/Matchers/ThrowAssertion.swift | 8 ++-- Sources/Nimble/Matchers/ThrowError.swift | 4 +- Sources/Nimble/Utils/Errors.swift | 3 +- Sources/Nimble/Utils/SourceLocation.swift | 2 +- Sources/Nimble/Utils/Stringers.swift | 11 +++-- Tests/NimbleTests/AsynchronousTest.swift | 12 +++--- .../Helpers/XCTestCaseProvider.swift | 2 +- Tests/NimbleTests/Helpers/utils.swift | 2 +- Tests/NimbleTests/Matchers/AllPassTest.swift | 30 +++++++------- .../NimbleTests/Matchers/BeCloseToTest.swift | 16 ++++---- Tests/NimbleTests/Matchers/BeEmptyTest.swift | 8 ++-- .../Matchers/BeGreaterThanTest.swift | 2 +- .../Matchers/BeIdenticalToObjectTest.swift | 8 ++-- .../NimbleTests/Matchers/BeLogicalTest.swift | 14 +++---- .../ContainElementSatisfyingTest.swift | 8 ++-- Tests/NimbleTests/Matchers/EqualTest.swift | 14 +++---- Tests/NimbleTests/Matchers/MatchTest.swift | 8 ++-- .../Matchers/RaisesExceptionTest.swift | 2 +- .../Matchers/SatisfyAnyOfTest.swift | 8 ++-- .../Matchers/ThrowAssertionTest.swift | 2 +- .../NimbleTests/Matchers/ThrowErrorTest.swift | 14 +++---- Tests/NimbleTests/SynchronousTests.swift | 25 ++++++----- Tests/NimbleTests/UserDescriptionTest.swift | 18 ++++---- 49 files changed, 195 insertions(+), 229 deletions(-) diff --git a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift index 2fa67c944..5bf2794dd 100644 --- a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift +++ b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift @@ -27,43 +27,43 @@ private func raiseBadInstructionException() { /// A simple NSException subclass. It's not required to subclass NSException (since the exception type is represented in the name) but this helps for identifying the exception through runtime type. @objc public class BadInstructionException: NSException { static var name: String = "com.cocoawithlove.BadInstruction" - + init() { super.init(name: NSExceptionName(rawValue: BadInstructionException.name), reason: nil, userInfo: nil) } - + required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } - + /// An Objective-C callable function, invoked from the `mach_exc_server` callback function `catch_mach_exception_raise_state` to push the `raiseBadInstructionException` function onto the stack. public class func catch_mach_exception_raise_state(_ exception_port: mach_port_t, exception: exception_type_t, code: UnsafePointer, codeCnt: mach_msg_type_number_t, flavor: UnsafeMutablePointer, old_state: UnsafePointer, old_stateCnt: mach_msg_type_number_t, new_state: thread_state_t, new_stateCnt: UnsafeMutablePointer) -> kern_return_t { - + #if arch(x86_64) // Make sure we've been given enough memory if old_stateCnt != x86_THREAD_STATE64_COUNT || new_stateCnt.pointee < x86_THREAD_STATE64_COUNT { return KERN_INVALID_ARGUMENT } - + // Read the old thread state var state = old_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { return $0.pointee } - + // 1. Decrement the stack pointer state.__rsp -= __uint64_t(MemoryLayout.size) - + // 2. Save the old Instruction Pointer to the stack. if let pointer = UnsafeMutablePointer<__uint64_t>(bitPattern: UInt(state.__rsp)) { pointer.pointee = state.__rip } else { return KERN_INVALID_ARGUMENT } - + // 3. Set the Instruction Pointer to the new function's address var f: @convention(c) () -> Void = raiseBadInstructionException withUnsafePointer(to: &f) { state.__rip = $0.withMemoryRebound(to: __uint64_t.self, capacity: 1) { return $0.pointee } } - + // Write the new thread state new_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { $0.pointee = state } new_stateCnt.pointee = x86_THREAD_STATE64_COUNT diff --git a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift index ab460b3b9..4d82f7ae2 100644 --- a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift +++ b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift @@ -21,10 +21,10 @@ import Foundation #if arch(x86_64) - + private enum PthreadError: Error { case code(Int32) } private enum MachExcServer: Error { case code(kern_return_t) } - + /// A quick function for converting Mach error results into Swift errors private func kernCheck(_ f: () -> Int32) throws { let r = f() @@ -32,7 +32,7 @@ import Foundation throw NSError(domain: NSMachErrorDomain, code: Int(r), userInfo: nil) } } - + extension execTypesCountTuple { mutating func pointer(in block: (UnsafeMutablePointer) -> R) -> R { return withUnsafeMutablePointer(to: &self) { p -> R in @@ -42,7 +42,7 @@ import Foundation } } } - + extension request_mach_exception_raise_t { mutating func withMsgHeaderPointer(in block: (UnsafeMutablePointer) -> R) -> R { return withUnsafeMutablePointer(to: &self) { p -> R in @@ -52,7 +52,7 @@ import Foundation } } } - + extension reply_mach_exception_raise_state_t { mutating func withMsgHeaderPointer(in block: (UnsafeMutablePointer) -> R) -> R { return withUnsafeMutablePointer(to: &self) { p -> R in @@ -62,7 +62,7 @@ import Foundation } } } - + /// A structure used to store context associated with the Mach message port private struct MachContext { var masks = execTypesCountTuple() @@ -72,7 +72,7 @@ import Foundation var flavors = execTypesCountTuple() var currentExceptionPort: mach_port_t = 0 var handlerThread: pthread_t? = nil - + mutating func withUnsafeMutablePointers(in block: (UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer) -> R) -> R { return masks.pointer { masksPtr in return ports.pointer { portsPtr in @@ -85,13 +85,13 @@ import Foundation } } } - + /// A function for receiving mach messages and parsing the first with mach_exc_server (and if any others are received, throwing them away). private func machMessageHandler(_ arg: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? { let context = arg.assumingMemoryBound(to: MachContext.self).pointee var request = request_mach_exception_raise_t() var reply = reply_mach_exception_raise_state_t() - + var handledfirstException = false repeat { do { // Request the next mach message from the port @@ -100,26 +100,26 @@ import Foundation try kernCheck { request.withMsgHeaderPointer { requestPtr in mach_msg(requestPtr, MACH_RCV_MSG | MACH_RCV_INTERRUPT, 0, request.Head.msgh_size, context.currentExceptionPort, 0, UInt32(MACH_PORT_NULL)) } } - + // Prepare the reply structure reply.Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(request.Head.msgh_bits), 0) reply.Head.msgh_local_port = UInt32(MACH_PORT_NULL) reply.Head.msgh_remote_port = request.Head.msgh_remote_port reply.Head.msgh_size = UInt32(MemoryLayout.size) reply.NDR = NDR_record - + if !handledfirstException { // Use the MiG generated server to invoke our handler for the request and fill in the rest of the reply structure guard request.withMsgHeaderPointer(in: { requestPtr in reply.withMsgHeaderPointer { replyPtr in mach_exc_server(requestPtr, replyPtr) } }) != 0 else { throw MachExcServer.code(reply.RetCode) } - + handledfirstException = true } else { // If multiple fatal errors occur, don't handle subsquent errors (let the program crash) reply.RetCode = KERN_FAILURE } - + // Send the reply try kernCheck { reply.withMsgHeaderPointer { replyPtr in mach_msg(replyPtr, MACH_SEND_MSG, reply.Head.msgh_size, 0, UInt32(MACH_PORT_NULL), 0, UInt32(MACH_PORT_NULL)) @@ -133,7 +133,7 @@ import Foundation fatalError("Mach message error: \(error)") } } while true } - + /// 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. /// - parameter block: a function without parameters that will be run @@ -150,7 +150,7 @@ import Foundation pthread_join(handlerThread!, nil) } } - + try kernCheck { // 1. Create the mach port mach_port_allocate(mach_task_self_, MACH_PORT_RIGHT_RECEIVE, &context.currentExceptionPort) @@ -159,27 +159,27 @@ import Foundation // 7. Cleanup the mach port mach_port_destroy(mach_task_self_, context.currentExceptionPort) } - + try kernCheck { // 2. Configure the mach port mach_port_insert_right(mach_task_self_, context.currentExceptionPort, context.currentExceptionPort, MACH_MSG_TYPE_MAKE_SEND) } - + try kernCheck { context.withUnsafeMutablePointers { masksPtr, portsPtr, behaviorsPtr, flavorsPtr in // 3. Apply the mach port as the handler for this thread thread_swap_exception_ports(mach_thread_self(), EXC_MASK_BAD_INSTRUCTION, context.currentExceptionPort, Int32(bitPattern: UInt32(EXCEPTION_STATE) | MACH_EXCEPTION_CODES), x86_THREAD_STATE64, masksPtr, &context.count, portsPtr, behaviorsPtr, flavorsPtr) } } - + defer { context.withUnsafeMutablePointers { masksPtr, portsPtr, behaviorsPtr, flavorsPtr in // 6. Unapply the mach port _ = thread_swap_exception_ports(mach_thread_self(), EXC_MASK_BAD_INSTRUCTION, 0, EXCEPTION_DEFAULT, THREAD_STATE_NONE, masksPtr, &context.count, portsPtr, behaviorsPtr, flavorsPtr) } } - + try withUnsafeMutablePointer(to: &context) { c throws in // 4. Create the thread let e = pthread_create(&handlerThread, nil, machMessageHandler, c) guard e == 0 else { throw PthreadError.code(e) } - + // 5. Run the block result = BadInstructionException.catchException(in: block) } @@ -191,4 +191,3 @@ import Foundation } #endif - diff --git a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift index b3afb1296..bf3090811 100644 --- a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift +++ b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift @@ -34,7 +34,7 @@ import Foundation // * Plus all of the same caveats as the Mach exceptions version (doesn't play well with other handlers, probably leaks ARC memory, etc) // Treat it like a loaded shotgun. Don't point it at your face. -private var env = jmp_buf(0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0) +private var env = jmp_buf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) private func triggerLongJmp() { longjmp(&env.0, 1) @@ -72,7 +72,7 @@ public func catchBadInstruction( block: () -> Void) -> BadInstructionException? var sigActionPrev = sigaction() let action = __sigaction_u(__sa_sigaction: sigIllHandler) var sigActionNew = sigaction(__sigaction_u: action, sa_mask: sigset_t(), sa_flags: SA_SIGINFO) - + // Install the signal action if sigaction(SIGILL, &sigActionNew, &sigActionPrev) != 0 { fatalError("Sigaction error: \(errno)") @@ -93,7 +93,7 @@ public func catchBadInstruction( block: () -> Void) -> BadInstructionException? // Run the block block() - + return nil } diff --git a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift index 12a6b9f70..35e1ad558 100644 --- a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift +++ b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift @@ -55,7 +55,7 @@ let EXC_TYPES_COUNT = 14 struct execTypesCountTuple { // From /usr/include/mach/i386/exception.h // #define EXC_TYPES_COUNT 14 /* incl. illegal exception 0 */ - var value: (T,T,T,T,T,T,T,T,T,T,T,T,T,T) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + var value: (T, T, T, T, T, T, T, T, T, T, T, T, T, T) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) init() { } } diff --git a/Sources/Nimble/Adapters/AssertionDispatcher.swift b/Sources/Nimble/Adapters/AssertionDispatcher.swift index 2e30f61c1..94a9030eb 100644 --- a/Sources/Nimble/Adapters/AssertionDispatcher.swift +++ b/Sources/Nimble/Adapters/AssertionDispatcher.swift @@ -1,4 +1,3 @@ - /// AssertionDispatcher allows multiple AssertionHandlers to receive /// assertion messages. /// diff --git a/Sources/Nimble/Adapters/AssertionRecorder.swift b/Sources/Nimble/Adapters/AssertionRecorder.swift index 114782657..740c3923d 100644 --- a/Sources/Nimble/Adapters/AssertionRecorder.swift +++ b/Sources/Nimble/Adapters/AssertionRecorder.swift @@ -22,7 +22,7 @@ public struct AssertionRecord: CustomStringConvertible { /// This is useful for testing failure messages for matchers. /// /// @see AssertionHandler -public class AssertionRecorder : AssertionHandler { +public class AssertionRecorder: AssertionHandler { /// All the assertions that were captured by this recorder public var assertions = [AssertionRecord]() diff --git a/Sources/Nimble/Adapters/NMBExpectation.swift b/Sources/Nimble/Adapters/NMBExpectation.swift index 47d4eed9d..1c51cd7f4 100644 --- a/Sources/Nimble/Adapters/NMBExpectation.swift +++ b/Sources/Nimble/Adapters/NMBExpectation.swift @@ -2,7 +2,7 @@ import Foundation #if _runtime(_ObjC) -internal struct ObjCMatcherWrapper : Matcher { +internal struct ObjCMatcherWrapper: Matcher { let matcher: NMBMatcher func matches(_ actualExpression: Expression, failureMessage: FailureMessage) -> Bool { @@ -21,7 +21,7 @@ internal struct ObjCMatcherWrapper : Matcher { } // Equivalent to Expectation, but for Nimble's Objective-C interface -public class NMBExpectation : NSObject { +public class NMBExpectation: NSObject { internal let _actualBlock: () -> NSObject! internal var _negative: Bool internal let _file: FileString @@ -36,7 +36,7 @@ public class NMBExpectation : NSObject { } private var expectValue: Expectation { - return expect(_file, line: _line){ + return expect(_file, line: _line) { self._actualBlock() as NSObject? } } diff --git a/Sources/Nimble/Adapters/NMBObjCMatcher.swift b/Sources/Nimble/Adapters/NMBObjCMatcher.swift index c609f69bd..19a4567bc 100644 --- a/Sources/Nimble/Adapters/NMBObjCMatcher.swift +++ b/Sources/Nimble/Adapters/NMBObjCMatcher.swift @@ -5,7 +5,7 @@ import Foundation public typealias MatcherBlock = (_ actualExpression: Expression, _ failureMessage: FailureMessage) -> Bool public typealias FullMatcherBlock = (_ actualExpression: Expression, _ failureMessage: FailureMessage, _ shouldNotMatch: Bool) -> Bool -public class NMBObjCMatcher : NSObject, NMBMatcher { +public class NMBObjCMatcher: NSObject, NMBMatcher { let _match: MatcherBlock let _doesNotMatch: MatcherBlock let canMatchNil: Bool diff --git a/Sources/Nimble/Adapters/NimbleXCTestHandler.swift b/Sources/Nimble/Adapters/NimbleXCTestHandler.swift index 1503b4430..952c84758 100644 --- a/Sources/Nimble/Adapters/NimbleXCTestHandler.swift +++ b/Sources/Nimble/Adapters/NimbleXCTestHandler.swift @@ -3,7 +3,7 @@ import XCTest /// Default handler for Nimble. This assertion handler passes failures along to /// XCTest. -public class NimbleXCTestHandler : AssertionHandler { +public class NimbleXCTestHandler: AssertionHandler { public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { if !assertion { recordFailure("\(message.stringValue)\n", location: location) @@ -29,7 +29,7 @@ public class NimbleShortXCTestHandler: AssertionHandler { /// Fallback handler in case XCTest is unavailable. This assertion handler will abort /// the program if it is invoked. -class NimbleXCTestUnavailableHandler : AssertionHandler { +class NimbleXCTestUnavailableHandler: AssertionHandler { func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { fatalError("XCTest is not available and no custom assertion handler was configured. Aborting.") } @@ -61,7 +61,6 @@ class NimbleXCTestUnavailableHandler : AssertionHandler { } #endif - func isXCTestAvailable() -> Bool { #if _runtime(_ObjC) // XCTest is weakly linked and so may not be present diff --git a/Sources/Nimble/Expectation.swift b/Sources/Nimble/Expectation.swift index 16d7c3bb6..c5978f4f8 100644 --- a/Sources/Nimble/Expectation.swift +++ b/Sources/Nimble/Expectation.swift @@ -1,8 +1,7 @@ import Foundation internal func expressionMatches(_ expression: Expression, matcher: U, to: String, description: String?) -> (Bool, FailureMessage) - where U: Matcher, U.ValueType == T -{ + where U: Matcher, U.ValueType == T { let msg = FailureMessage() msg.userDescription = description msg.to = to @@ -19,8 +18,7 @@ internal func expressionMatches(_ expression: Expression, matcher: U, t } internal func expressionDoesNotMatch(_ expression: Expression, matcher: U, toNot: String, description: String?) -> (Bool, FailureMessage) - where U: Matcher, U.ValueType == T -{ + where U: Matcher, U.ValueType == T { let msg = FailureMessage() msg.userDescription = description msg.to = toNot @@ -47,16 +45,14 @@ public struct Expectation { /// Tests the actual value using a matcher to match. public func to(_ matcher: U, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { let (pass, msg) = expressionMatches(expression, matcher: matcher, to: "to", description: description) verify(pass, msg) } /// Tests the actual value using a matcher to not match. public func toNot(_ matcher: U, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { let (pass, msg) = expressionDoesNotMatch(expression, matcher: matcher, toNot: "to not", description: description) verify(pass, msg) } @@ -65,8 +61,7 @@ public struct Expectation { /// /// Alias to toNot(). public func notTo(_ matcher: U, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { toNot(matcher, description: description) } diff --git a/Sources/Nimble/FailureMessage.swift b/Sources/Nimble/FailureMessage.swift index 2d245e52e..24b6c8fd6 100644 --- a/Sources/Nimble/FailureMessage.swift +++ b/Sources/Nimble/FailureMessage.swift @@ -59,7 +59,7 @@ public class FailureMessage: NSObject { if let userDescription = userDescription { return "\(userDescription)\n\(value)" } - + return value } } diff --git a/Sources/Nimble/Matchers/AllPass.swift b/Sources/Nimble/Matchers/AllPass.swift index 3a9258d89..9e1ac24cb 100644 --- a/Sources/Nimble/Matchers/AllPass.swift +++ b/Sources/Nimble/Matchers/AllPass.swift @@ -1,16 +1,14 @@ import Foundation -public func allPass +public func allPass (_ passFunc: @escaping (T?) -> Bool) -> NonNilMatcherFunc - where U: Sequence, U.Iterator.Element == T -{ + where U: Sequence, U.Iterator.Element == T { return allPass("pass a condition", passFunc) } -public func allPass +public func allPass (_ passName: String, _ passFunc: @escaping (T?) -> Bool) -> NonNilMatcherFunc - where U: Sequence, U.Iterator.Element == T -{ + where U: Sequence, U.Iterator.Element == T { return createAllPassMatcher() { expression, failureMessage in failureMessage.postfixMessage = passName @@ -18,19 +16,17 @@ public func allPass } } -public func allPass +public func allPass (_ matcher: V) -> NonNilMatcherFunc - where U: Sequence, V: Matcher, U.Iterator.Element == V.ValueType -{ + where U: Sequence, V: Matcher, U.Iterator.Element == V.ValueType { return createAllPassMatcher() { try matcher.matches($0, failureMessage: $1) } } -private func createAllPassMatcher +private func createAllPassMatcher (_ elementEvaluator: @escaping (Expression, FailureMessage) throws -> Bool) -> NonNilMatcherFunc - where U: Sequence, U.Iterator.Element == T -{ + where U: Sequence, U.Iterator.Element == T { return NonNilMatcherFunc { actualExpression, failureMessage in failureMessage.actualValue = nil if let actualValue = try actualExpression.evaluate() { @@ -62,7 +58,7 @@ extension NMBObjCMatcher { let location = actualExpression.location let actualValue = try! actualExpression.evaluate() var nsObjects = [NSObject]() - + var collectionIsUsable = true if let value = actualValue as? NSFastEnumeration { let generator = NSFastEnumerationIterator(value) @@ -77,7 +73,7 @@ extension NMBObjCMatcher { } else { collectionIsUsable = false } - + if !collectionIsUsable { failureMessage.postfixMessage = "allPass only works with NSFastEnumeration (NSArray, NSSet, ...) of NSObjects" @@ -85,12 +81,11 @@ extension NMBObjCMatcher { failureMessage.to = "" return false } - + let expr = Expression(expression: ({ nsObjects }), location: location) let elementEvaluator: (Expression, FailureMessage) -> Bool = { expression, failureMessage in - return matcher.matches( - {try! expression.evaluate()}, failureMessage: failureMessage, location: expr.location) + return matcher.matches({try! expression.evaluate()}, failureMessage: failureMessage, location: expr.location) } return try! createAllPassMatcher(elementEvaluator).matches( expr, failureMessage: failureMessage) diff --git a/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift b/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift index 6b89c76d1..aba101540 100644 --- a/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift +++ b/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift @@ -8,8 +8,7 @@ public struct AsyncDefaults { } internal struct AsyncMatcherWrapper: Matcher - where U: Matcher, U.ValueType == T -{ + where U: Matcher, U.ValueType == T { let fullMatcher: U let timeoutInterval: TimeInterval let pollInterval: TimeInterval @@ -48,7 +47,7 @@ internal struct AsyncMatcherWrapper: Matcher } } - func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) -> Bool { + func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) -> Bool { let uncachedExpression = actualExpression.withoutCaching() let result = pollBlock( pollInterval: pollInterval, @@ -78,7 +77,6 @@ internal struct AsyncMatcherWrapper: Matcher private let toEventuallyRequiresClosureError = FailureMessage(stringValue: "expect(...).toEventually(...) requires an explicit closure (eg - expect { ... }.toEventually(...) )\nSwift 1.2 @autoclosure behavior has changed in an incompatible way for Nimble to function") - extension Expectation { /// Tests the actual value using a matcher to match by checking continuously /// at each pollInterval until the timeout is reached. @@ -87,8 +85,7 @@ extension Expectation { /// 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. public func toEventually(_ matcher: U, timeout: TimeInterval = AsyncDefaults.Timeout, pollInterval: TimeInterval = AsyncDefaults.PollInterval, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { if expression.isClosure { let (pass, msg) = expressionMatches( expression, @@ -112,8 +109,7 @@ extension Expectation { /// 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. public func toEventuallyNot(_ matcher: U, timeout: TimeInterval = AsyncDefaults.Timeout, pollInterval: TimeInterval = AsyncDefaults.PollInterval, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { if expression.isClosure { let (pass, msg) = expressionDoesNotMatch( expression, @@ -139,8 +135,7 @@ extension Expectation { /// 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. public func toNotEventually(_ matcher: U, timeout: TimeInterval = AsyncDefaults.Timeout, pollInterval: TimeInterval = AsyncDefaults.PollInterval, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { return toEventuallyNot(matcher, timeout: timeout, pollInterval: pollInterval, description: description) } } diff --git a/Sources/Nimble/Matchers/BeCloseTo.swift b/Sources/Nimble/Matchers/BeCloseTo.swift index 48e989578..6bdd72928 100644 --- a/Sources/Nimble/Matchers/BeCloseTo.swift +++ b/Sources/Nimble/Matchers/BeCloseTo.swift @@ -29,7 +29,7 @@ public func beCloseTo(_ expectedValue: NMBDoubleConvertible, within delta: Doubl } #if _runtime(_ObjC) -public class NMBObjCBeCloseToMatcher : NSObject, NMBMatcher { +public class NMBObjCBeCloseToMatcher: NSObject, NMBMatcher { var _expected: NSNumber var _delta: CDouble init(expected: NSNumber, within: CDouble) { diff --git a/Sources/Nimble/Matchers/BeEmpty.swift b/Sources/Nimble/Matchers/BeEmpty.swift index 19df0d29c..2ea2cdb09 100644 --- a/Sources/Nimble/Matchers/BeEmpty.swift +++ b/Sources/Nimble/Matchers/BeEmpty.swift @@ -1,6 +1,5 @@ import Foundation - /// 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. public func beEmpty() -> NonNilMatcherFunc { diff --git a/Sources/Nimble/Matchers/BeGreaterThan.swift b/Sources/Nimble/Matchers/BeGreaterThan.swift index 134519948..4d77ea632 100644 --- a/Sources/Nimble/Matchers/BeGreaterThan.swift +++ b/Sources/Nimble/Matchers/BeGreaterThan.swift @@ -1,6 +1,5 @@ import Foundation - /// A Nimble matcher that succeeds when the actual value is greater than the expected value. public func beGreaterThan(_ expectedValue: T?) -> NonNilMatcherFunc { return NonNilMatcherFunc { actualExpression, failureMessage in diff --git a/Sources/Nimble/Matchers/BeIdenticalTo.swift b/Sources/Nimble/Matchers/BeIdenticalTo.swift index ca3357bb1..3052231aa 100644 --- a/Sources/Nimble/Matchers/BeIdenticalTo.swift +++ b/Sources/Nimble/Matchers/BeIdenticalTo.swift @@ -1,6 +1,5 @@ import Foundation - /// A Nimble matcher that succeeds when the actual value is the same instance /// as the expected instance. public func beIdenticalTo(_ expected: Any?) -> NonNilMatcherFunc { diff --git a/Sources/Nimble/Matchers/BeVoid.swift b/Sources/Nimble/Matchers/BeVoid.swift index 8f8626525..bfe00403b 100644 --- a/Sources/Nimble/Matchers/BeVoid.swift +++ b/Sources/Nimble/Matchers/BeVoid.swift @@ -15,4 +15,4 @@ public func ==(lhs: Expectation<()>, rhs: ()) { public func !=(lhs: Expectation<()>, rhs: ()) { lhs.toNot(beVoid()) -} \ No newline at end of file +} diff --git a/Sources/Nimble/Matchers/BeginWith.swift b/Sources/Nimble/Matchers/BeginWith.swift index ef6c60350..31cbe5dfc 100644 --- a/Sources/Nimble/Matchers/BeginWith.swift +++ b/Sources/Nimble/Matchers/BeginWith.swift @@ -1,11 +1,9 @@ import Foundation - /// A Nimble matcher that succeeds when the actual sequence's first element /// is equal to the expected value. public func beginWith(_ startingElement: T) -> NonNilMatcherFunc - where S.Iterator.Element == T -{ + where S.Iterator.Element == T { return NonNilMatcherFunc { actualExpression, failureMessage in failureMessage.postfixMessage = "begin with <\(startingElement)>" if let actualValue = try actualExpression.evaluate() { diff --git a/Sources/Nimble/Matchers/Contain.swift b/Sources/Nimble/Matchers/Contain.swift index 4400d3053..50536422f 100644 --- a/Sources/Nimble/Matchers/Contain.swift +++ b/Sources/Nimble/Matchers/Contain.swift @@ -2,14 +2,12 @@ import Foundation /// A Nimble matcher that succeeds when the actual sequence contains the expected value. public func contain(_ items: T...) -> NonNilMatcherFunc - where S.Iterator.Element == T -{ + where S.Iterator.Element == T { return contain(items) } public func contain(_ items: [T]) -> NonNilMatcherFunc - where S.Iterator.Element == T -{ + where S.Iterator.Element == T { return NonNilMatcherFunc { actualExpression, failureMessage in failureMessage.postfixMessage = "contain <\(arrayAsString(items))>" if let actual = try actualExpression.evaluate() { diff --git a/Sources/Nimble/Matchers/EndWith.swift b/Sources/Nimble/Matchers/EndWith.swift index b96e96cc1..00c7e2024 100644 --- a/Sources/Nimble/Matchers/EndWith.swift +++ b/Sources/Nimble/Matchers/EndWith.swift @@ -1,11 +1,9 @@ import Foundation - /// A Nimble matcher that succeeds when the actual sequence's last element /// is equal to the expected value. public func endWith(_ endingElement: T) -> NonNilMatcherFunc - where S.Iterator.Element == T -{ + where S.Iterator.Element == T { return NonNilMatcherFunc { actualExpression, failureMessage in failureMessage.postfixMessage = "end with <\(endingElement)>" @@ -17,7 +15,7 @@ public func endWith(_ endingElement: T) -> NonNilMatc lastItem = item item = actualGenerator.next() } while(item != nil) - + return lastItem == endingElement } return false @@ -43,7 +41,6 @@ public func endWith(_ endingElement: Any) -> NonNilMatcherFunc(_ expectedValue: [T?]) -> NonNilMatcherFunc<[T?] if expectedValue.count != actualValue.count { return false } - + for (index, item) in actualValue.enumerated() { let otherItem = expectedValue[index] if item == nil && otherItem == nil { @@ -74,12 +74,12 @@ public func equal(_ expectedValue: [T?]) -> NonNilMatcherFunc<[T?] return false } } - + return true } else { failureMessage.postfixActual = " (use beNil() to match nils)" } - + return false } } diff --git a/Sources/Nimble/Matchers/Match.swift b/Sources/Nimble/Matchers/Match.swift index 3ad5fb5c1..7e803318d 100644 --- a/Sources/Nimble/Matchers/Match.swift +++ b/Sources/Nimble/Matchers/Match.swift @@ -5,7 +5,7 @@ import Foundation public func match(_ expectedValue: String?) -> NonNilMatcherFunc { return NonNilMatcherFunc { actualExpression, failureMessage in failureMessage.postfixMessage = "match <\(stringify(expectedValue))>" - + if let actual = try actualExpression.evaluate() { if let regexp = expectedValue { return actual.range(of: regexp, options: .regularExpression) != nil diff --git a/Sources/Nimble/Matchers/MatcherProtocols.swift b/Sources/Nimble/Matchers/MatcherProtocols.swift index ac1eb9ddc..3f27ec1e9 100644 --- a/Sources/Nimble/Matchers/MatcherProtocols.swift +++ b/Sources/Nimble/Matchers/MatcherProtocols.swift @@ -57,12 +57,12 @@ extension NSDictionary : NMBCollection {} #if _runtime(_ObjC) /// Protocol for types that support beginWith(), endWith(), beEmpty() matchers -@objc public protocol NMBOrderedCollection : NMBCollection { +@objc public protocol NMBOrderedCollection: NMBCollection { @objc(objectAtIndex:) func object(at index: Int) -> Any } #else -public protocol NMBOrderedCollection : NMBCollection { +public protocol NMBOrderedCollection: NMBCollection { func object(at index: Int) -> Any } #endif diff --git a/Sources/Nimble/Matchers/RaisesException.swift b/Sources/Nimble/Matchers/RaisesException.swift index 09e28c763..2867a1b16 100644 --- a/Sources/Nimble/Matchers/RaisesException.swift +++ b/Sources/Nimble/Matchers/RaisesException.swift @@ -97,11 +97,11 @@ internal func exceptionMatchesNonNilFieldsOrClosure( } } } - + return matches } -public class NMBObjCRaiseExceptionMatcher : NSObject, NMBMatcher { +public class NMBObjCRaiseExceptionMatcher: NSObject, NMBMatcher { internal var _name: String? internal var _reason: String? internal var _userInfo: NSDictionary? diff --git a/Sources/Nimble/Matchers/SatisfyAnyOf.swift b/Sources/Nimble/Matchers/SatisfyAnyOf.swift index b24b3ece9..4e879b3ff 100644 --- a/Sources/Nimble/Matchers/SatisfyAnyOf.swift +++ b/Sources/Nimble/Matchers/SatisfyAnyOf.swift @@ -2,15 +2,13 @@ import Foundation /// A Nimble matcher that succeeds when the actual value matches with any of the matchers /// provided in the variable list of matchers. -public func satisfyAnyOf(_ matchers: U...) -> NonNilMatcherFunc - where U: Matcher, U.ValueType == T -{ +public func satisfyAnyOf(_ matchers: U...) -> NonNilMatcherFunc + where U: Matcher, U.ValueType == T { return satisfyAnyOf(matchers) } -internal func satisfyAnyOf(_ matchers: [U]) -> NonNilMatcherFunc - where U: Matcher, U.ValueType == T -{ +internal func satisfyAnyOf(_ matchers: [U]) -> NonNilMatcherFunc + where U: Matcher, U.ValueType == T { return NonNilMatcherFunc { actualExpression, failureMessage in let postfixMessages = NSMutableArray() var matches = false @@ -46,18 +44,17 @@ extension NMBObjCMatcher { failureMessage.stringValue = "satisfyAnyOf must be called with at least one matcher" return false } - + var elementEvaluators = [NonNilMatcherFunc]() for matcher in matchers { let elementEvaluator: (Expression, FailureMessage) -> Bool = { expression, failureMessage in - return matcher.matches( - {try! expression.evaluate()}, failureMessage: failureMessage, location: actualExpression.location) + return matcher.matches({try! expression.evaluate()}, failureMessage: failureMessage, location: actualExpression.location) } - + elementEvaluators.append(NonNilMatcherFunc(elementEvaluator)) } - + return try! satisfyAnyOf(elementEvaluators).matches(actualExpression, failureMessage: failureMessage) } } diff --git a/Sources/Nimble/Matchers/ThrowAssertion.swift b/Sources/Nimble/Matchers/ThrowAssertion.swift index 67f9cf63e..f75975023 100644 --- a/Sources/Nimble/Matchers/ThrowAssertion.swift +++ b/Sources/Nimble/Matchers/ThrowAssertion.swift @@ -5,9 +5,9 @@ public func throwAssertion() -> MatcherFunc { #if arch(x86_64) && _runtime(_ObjC) && !SWIFT_PACKAGE failureMessage.postfixMessage = "throw an assertion" failureMessage.actualValue = nil - + var succeeded = true - + let caughtException: BadInstructionException? = catchBadInstruction { #if os(tvOS) if (!NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning) { @@ -36,11 +36,11 @@ public func throwAssertion() -> MatcherFunc { if !succeeded { return false } - + if caughtException == nil { return false } - + return true #elseif SWIFT_PACKAGE fatalError("The throwAssertion Nimble matcher does not currently support Swift CLI." + diff --git a/Sources/Nimble/Matchers/ThrowError.swift b/Sources/Nimble/Matchers/ThrowError.swift index 8c9b91bd1..151eb9adc 100644 --- a/Sources/Nimble/Matchers/ThrowError.swift +++ b/Sources/Nimble/Matchers/ThrowError.swift @@ -39,14 +39,14 @@ public func throwError( public func throwError( closure: ((Error) -> Void)? = nil) -> MatcherFunc { return MatcherFunc { actualExpression, failureMessage in - + var actualError: Error? do { _ = try actualExpression.evaluate() } catch let catchedError { actualError = catchedError } - + setFailureMessageForError(failureMessage, actualError: actualError, closure: closure) return errorMatchesNonNilFieldsOrClosure(actualError, closure: closure) } diff --git a/Sources/Nimble/Utils/Errors.swift b/Sources/Nimble/Utils/Errors.swift index d424c98ae..f3765056f 100644 --- a/Sources/Nimble/Utils/Errors.swift +++ b/Sources/Nimble/Utils/Errors.swift @@ -44,8 +44,7 @@ internal func errorMatchesExpectedError( internal func errorMatchesExpectedError( _ actualError: Error, expectedError: T) -> Bool - where T: Equatable -{ + where T: Equatable { if let actualError = actualError as? T { return actualError == expectedError } diff --git a/Sources/Nimble/Utils/SourceLocation.swift b/Sources/Nimble/Utils/SourceLocation.swift index a7279aa2a..c4351e68e 100644 --- a/Sources/Nimble/Utils/SourceLocation.swift +++ b/Sources/Nimble/Utils/SourceLocation.swift @@ -11,7 +11,7 @@ public typealias FileString = String public typealias FileString = StaticString #endif -public final class SourceLocation : NSObject { +public final class SourceLocation: NSObject { public let file: FileString public let line: UInt diff --git a/Sources/Nimble/Utils/Stringers.swift b/Sources/Nimble/Utils/Stringers.swift index 012e1e36f..8a15c4cf7 100644 --- a/Sources/Nimble/Utils/Stringers.swift +++ b/Sources/Nimble/Utils/Stringers.swift @@ -1,6 +1,5 @@ import Foundation - internal func identityAsString(_ value: Any?) -> String { let anyObject: AnyObject? #if os(Linux) @@ -51,7 +50,7 @@ extension NSNumber: TestOutputStringConvertible { // the travis CI build on linux. public var testDescription: String { let description = self.description - + if description.contains(".") { // Travis linux swiftpm build doesn't like casting String to NSString, // which is why this annoying nested initializer thing is here. @@ -87,14 +86,14 @@ extension AnySequence: TestOutputStringConvertible { let generator = self.makeIterator() var strings = [String]() var value: AnySequence.Iterator.Element? - + repeat { value = generator.next() if let value = value { strings.append(stringify(value)) } } while value != nil - + let list = strings.joined(separator: ", ") return "[\(list)]" } @@ -149,11 +148,11 @@ public func stringify(_ value: T) -> String { if let value = value as? TestOutputStringConvertible { return value.testDescription } - + if let value = value as? CustomDebugStringConvertible { return value.debugDescription } - + return String(describing: value) } diff --git a/Tests/NimbleTests/AsynchronousTest.swift b/Tests/NimbleTests/AsynchronousTest.swift index ff78d47b5..cafa67e1e 100644 --- a/Tests/NimbleTests/AsynchronousTest.swift +++ b/Tests/NimbleTests/AsynchronousTest.swift @@ -61,12 +61,12 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { var value = 0 - let sleepThenSetValueTo: (Int) -> () = { newValue in + let sleepThenSetValueTo: (Int) -> Void = { newValue in Thread.sleep(forTimeInterval: 1.1) value = newValue } - var asyncOperation: () -> () = { sleepThenSetValueTo(1) } + var asyncOperation: () -> Void = { sleepThenSetValueTo(1) } if #available(OSX 10.10, *) { DispatchQueue.global().async(execute: asyncOperation) @@ -98,7 +98,7 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { func testWaitUntilTimesOutIfNotCalled() { failsWithErrorMessage("Waited more than 1.0 second") { - waitUntil(timeout: 1) { done in return } + waitUntil(timeout: 1) { _ in return } } } @@ -106,7 +106,7 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { var waiting = true failsWithErrorMessage("Waited more than 0.01 seconds") { waitUntil(timeout: 0.01) { done in - let asyncOperation: () -> () = { + let asyncOperation: () -> Void = { Thread.sleep(forTimeInterval: 0.1) done() waiting = false @@ -187,7 +187,7 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { func testWaitUntilMustBeInMainThread() { #if !SWIFT_PACKAGE var executedAsyncBlock: Bool = false - let asyncOperation: () -> () = { + let asyncOperation: () -> Void = { expect { waitUntil { done in done() } }.to(raiseException(named: "InvalidNimbleAPIUsage")) @@ -205,7 +205,7 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { func testToEventuallyMustBeInMainThread() { #if !SWIFT_PACKAGE var executedAsyncBlock: Bool = false - let asyncOperation: () -> () = { + let asyncOperation: () -> Void = { expect { expect(1).toEventually(equal(2)) }.to(raiseException(named: "InvalidNimbleAPIUsage")) diff --git a/Tests/NimbleTests/Helpers/XCTestCaseProvider.swift b/Tests/NimbleTests/Helpers/XCTestCaseProvider.swift index f300d475a..40d976019 100644 --- a/Tests/NimbleTests/Helpers/XCTestCaseProvider.swift +++ b/Tests/NimbleTests/Helpers/XCTestCaseProvider.swift @@ -24,7 +24,7 @@ public protocol XCTestCaseProvider: XCTestCaseProviderStatic, XCTestCaseNameProv extension XCTestCaseProvider where Self: XCTestCaseProviderStatic { var allTestNames: [String] { - return type(of: self).allTests.map({ name, test in + return type(of: self).allTests.map({ name, _ in return name }) } diff --git a/Tests/NimbleTests/Helpers/utils.swift b/Tests/NimbleTests/Helpers/utils.swift index 0b33ea634..bb552efe6 100644 --- a/Tests/NimbleTests/Helpers/utils.swift +++ b/Tests/NimbleTests/Helpers/utils.swift @@ -66,7 +66,7 @@ func failsWithErrorMessageForNil(_ message: String, file: FileString = #file, li } } -public class NimbleHelper : NSObject { +public class NimbleHelper: NSObject { public class func expectFailureMessage(_ message: NSString, block: @escaping () -> Void, file: FileString, line: UInt) { failsWithErrorMessage(String(describing: message), file: file, line: line, preferOriginalSourceLocation: true, closure: block) } diff --git a/Tests/NimbleTests/Matchers/AllPassTest.swift b/Tests/NimbleTests/Matchers/AllPassTest.swift index 0f4327a19..20508817f 100644 --- a/Tests/NimbleTests/Matchers/AllPassTest.swift +++ b/Tests/NimbleTests/Matchers/AllPassTest.swift @@ -55,35 +55,35 @@ final class AllPassTest: XCTestCase, XCTestCaseProvider { } func testAllPassArray() { - expect([1,2,3,4]).to(allPass({$0 < 5})) - expect([1,2,3,4]).toNot(allPass({$0 > 5})) + expect([1, 2, 3, 4]).to(allPass({$0 < 5})) + expect([1, 2, 3, 4]).toNot(allPass({$0 > 5})) failsWithErrorMessage( "expected to all pass a condition, but failed first at element <3> in <[1, 2, 3, 4]>") { - expect([1,2,3,4]).to(allPass({$0 < 3})) + expect([1, 2, 3, 4]).to(allPass({$0 < 3})) } failsWithErrorMessage("expected to not all pass a condition") { - expect([1,2,3,4]).toNot(allPass({$0 < 5})) + expect([1, 2, 3, 4]).toNot(allPass({$0 < 5})) } failsWithErrorMessage( "expected to all be something, but failed first at element <3> in <[1, 2, 3, 4]>") { - expect([1,2,3,4]).to(allPass("be something", {$0 < 3})) + expect([1, 2, 3, 4]).to(allPass("be something", {$0 < 3})) } failsWithErrorMessage("expected to not all be something") { - expect([1,2,3,4]).toNot(allPass("be something", {$0 < 5})) + expect([1, 2, 3, 4]).toNot(allPass("be something", {$0 < 5})) } } func testAllPassMatcher() { - expect([1,2,3,4]).to(allPass(beLessThan(5))) - expect([1,2,3,4]).toNot(allPass(beGreaterThan(5))) - + expect([1, 2, 3, 4]).to(allPass(beLessThan(5))) + expect([1, 2, 3, 4]).toNot(allPass(beGreaterThan(5))) + failsWithErrorMessage( "expected to all be less than <3>, but failed first at element <3> in <[1, 2, 3, 4]>") { - expect([1,2,3,4]).to(allPass(beLessThan(3))) + expect([1, 2, 3, 4]).to(allPass(beLessThan(3))) } failsWithErrorMessage("expected to not all be less than <5>") { - expect([1,2,3,4]).toNot(allPass(beLessThan(5))) + expect([1, 2, 3, 4]).toNot(allPass(beLessThan(5))) } } @@ -107,14 +107,14 @@ final class AllPassTest: XCTestCase, XCTestCaseProvider { } func testAllPassSet() { - expect(Set([1,2,3,4])).to(allPass({$0 < 5})) - expect(Set([1,2,3,4])).toNot(allPass({$0 > 5})) + expect(Set([1, 2, 3, 4])).to(allPass({$0 < 5})) + expect(Set([1, 2, 3, 4])).toNot(allPass({$0 > 5})) failsWithErrorMessage("expected to not all pass a condition") { - expect(Set([1,2,3,4])).toNot(allPass({$0 < 5})) + expect(Set([1, 2, 3, 4])).toNot(allPass({$0 < 5})) } failsWithErrorMessage("expected to not all be something") { - expect(Set([1,2,3,4])).toNot(allPass("be something", {$0 < 5})) + expect(Set([1, 2, 3, 4])).toNot(allPass("be something", {$0 < 5})) } } diff --git a/Tests/NimbleTests/Matchers/BeCloseToTest.swift b/Tests/NimbleTests/Matchers/BeCloseToTest.swift index c9e9c48a5..7a7e508c9 100644 --- a/Tests/NimbleTests/Matchers/BeCloseToTest.swift +++ b/Tests/NimbleTests/Matchers/BeCloseToTest.swift @@ -43,12 +43,12 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { expect(NSNumber(value:1.2)).to(beCloseTo(9.300, within: 10)) expect(NSNumber(value:1.2)).to(beCloseTo(NSNumber(value:9.300), within: 10)) expect(1.2).to(beCloseTo(NSNumber(value:9.300), within: 10)) - + failsWithErrorMessage("expected to not be close to <1.2001> (within 1), got <1.2>") { expect(NSNumber(value:1.2)).toNot(beCloseTo(1.2001, within: 1.0)) } } - + func testBeCloseToWithCGFloat() { expect(CGFloat(1.2)).to(beCloseTo(1.2001)) expect(CGFloat(1.2)).to(beCloseTo(CGFloat(1.2001))) @@ -60,7 +60,7 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { func testBeCloseToWithDate() { expect(Date(dateTimeString: "2015-08-26 11:43:00")).to(beCloseTo(Date(dateTimeString: "2015-08-26 11:43:05"), within: 10)) - + failsWithErrorMessage("expected to not be close to <2015-08-26 11:43:00.0050> (within 0.004), got <2015-08-26 11:43:00.0000>") { let expectedDate = Date(dateTimeString: "2015-08-26 11:43:00").addingTimeInterval(0.005) expect(Date(dateTimeString: "2015-08-26 11:43:00")).toNot(beCloseTo(expectedDate, within: 0.004)) @@ -79,7 +79,7 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { func testBeCloseToOperator() { expect(1.2) ≈ 1.2001 expect(1.2 as CDouble) ≈ 1.2001 - + failsWithErrorMessage("expected to be close to <1.2002> (within 0.0001), got <1.2>") { expect(1.2) ≈ 1.2002 } @@ -88,7 +88,7 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { func testBeCloseToWithinOperator() { expect(1.2) ≈ (9.300, 10) expect(1.2) == (9.300, 10) - + failsWithErrorMessage("expected to be close to <1> (within 0.1), got <1.2>") { expect(1.2) ≈ (1.0, 0.1) } @@ -96,11 +96,11 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { expect(1.2) == (1.0, 0.1) } } - + func testPlusMinusOperator() { expect(1.2) ≈ 9.300 ± 10 expect(1.2) == 9.300 ± 10 - + failsWithErrorMessage("expected to be close to <1> (within 0.1), got <1.2>") { expect(1.2) ≈ 1.0 ± 0.1 } @@ -149,7 +149,7 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { func testBeCloseToArray() { expect([0.0, 1.1, 2.2]) ≈ [0.0001, 1.1001, 2.2001] expect([0.0, 1.1, 2.2]).to(beCloseTo([0.1, 1.2, 2.3], within: 0.1)) - + failsWithErrorMessage("expected to be close to <[0, 1]> (each within 0.0001), got <[0, 1.1]>") { expect([0.0, 1.1]) ≈ [0.0, 1.0] } diff --git a/Tests/NimbleTests/Matchers/BeEmptyTest.swift b/Tests/NimbleTests/Matchers/BeEmptyTest.swift index d7f35aa40..d520d4930 100644 --- a/Tests/NimbleTests/Matchers/BeEmptyTest.swift +++ b/Tests/NimbleTests/Matchers/BeEmptyTest.swift @@ -59,17 +59,17 @@ final class BeEmptyTest: XCTestCase, XCTestCaseProvider { } failsWithErrorMessage("expected to not be empty, got <{()}>") { - expect(NSSet()).toNot(beEmpty()); + expect(NSSet()).toNot(beEmpty()) } failsWithErrorMessage("expected to be empty, got <{(1)}>") { - expect(NSSet(object: NSNumber(value: 1))).to(beEmpty()); + expect(NSSet(object: NSNumber(value: 1))).to(beEmpty()) } failsWithErrorMessage("expected to not be empty, got <()>") { - expect(NSIndexSet()).toNot(beEmpty()); + expect(NSIndexSet()).toNot(beEmpty()) } failsWithErrorMessage("expected to be empty, got <(1)>") { - expect(NSIndexSet(index: 1)).to(beEmpty()); + expect(NSIndexSet(index: 1)).to(beEmpty()) } failsWithErrorMessage("expected to not be empty, got <>") { diff --git a/Tests/NimbleTests/Matchers/BeGreaterThanTest.swift b/Tests/NimbleTests/Matchers/BeGreaterThanTest.swift index b7dbf47f8..6da2c0c24 100644 --- a/Tests/NimbleTests/Matchers/BeGreaterThanTest.swift +++ b/Tests/NimbleTests/Matchers/BeGreaterThanTest.swift @@ -9,7 +9,7 @@ final class BeGreaterThanTest: XCTestCase, XCTestCaseProvider { ("testGreaterThanOperator", testGreaterThanOperator), ] } - + func testGreaterThan() { expect(10).to(beGreaterThan(2)) expect(1).toNot(beGreaterThan(2)) diff --git a/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift b/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift index a598bfbfd..923fa7655 100644 --- a/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift +++ b/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift @@ -21,11 +21,11 @@ final class BeIdenticalToObjectTest: XCTestCase, XCTestCaseProvider { func testBeIdenticalToPositive() { expect(self.testObjectA).to(beIdenticalTo(testObjectA)) } - + func testBeIdenticalToNegative() { expect(self.testObjectA).toNot(beIdenticalTo(testObjectB)) } - + func testBeIdenticalToPositiveMessage() { let message = String(describing: NSString(format: "expected to be identical to <%p>, got <%p>", unsafeBitCast(testObjectB, to: Int.self), unsafeBitCast(testObjectA, to: Int.self))) @@ -33,7 +33,7 @@ final class BeIdenticalToObjectTest: XCTestCase, XCTestCaseProvider { expect(self.testObjectA).to(beIdenticalTo(self.testObjectB)) } } - + func testBeIdenticalToNegativeMessage() { let message = String(describing: NSString(format: "expected to not be identical to <%p>, got <%p>", unsafeBitCast(testObjectA, to: Int.self), unsafeBitCast(testObjectA, to: Int.self))) @@ -55,7 +55,7 @@ final class BeIdenticalToObjectTest: XCTestCase, XCTestCaseProvider { expect(nil as BeIdenticalToObjectTester?).toNot(beIdenticalTo(self.testObjectA)) } } - + func testOperators() { expect(self.testObjectA) === testObjectA expect(self.testObjectA) !== testObjectB diff --git a/Tests/NimbleTests/Matchers/BeLogicalTest.swift b/Tests/NimbleTests/Matchers/BeLogicalTest.swift index 9b8735cc1..947a1b4a3 100644 --- a/Tests/NimbleTests/Matchers/BeLogicalTest.swift +++ b/Tests/NimbleTests/Matchers/BeLogicalTest.swift @@ -2,7 +2,7 @@ import XCTest import Nimble import Foundation -enum ConvertsToBool : ExpressibleByBooleanLiteral, CustomStringConvertible { +enum ConvertsToBool: ExpressibleByBooleanLiteral, CustomStringConvertible { case trueLike, falseLike typealias BooleanLiteralType = Bool @@ -14,14 +14,14 @@ enum ConvertsToBool : ExpressibleByBooleanLiteral, CustomStringConvertible { } } - var boolValue : Bool { + var boolValue: Bool { switch self { case .trueLike: return true case .falseLike: return false } } - var description : String { + var description: String { switch self { case .trueLike: return "TrueLike" case .falseLike: return "FalseLike" @@ -29,7 +29,7 @@ enum ConvertsToBool : ExpressibleByBooleanLiteral, CustomStringConvertible { } } -final class BeTruthyTest : XCTestCase, XCTestCaseProvider { +final class BeTruthyTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (BeTruthyTest) -> () throws -> Void)] { return [ ("testShouldMatchNonNilTypes", testShouldMatchNonNilTypes), @@ -122,7 +122,7 @@ final class BeTruthyTest : XCTestCase, XCTestCaseProvider { } } -final class BeTrueTest : XCTestCase, XCTestCaseProvider { +final class BeTrueTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (BeTrueTest) -> () throws -> Void)] { return [ ("testShouldMatchTrue", testShouldMatchTrue), @@ -158,7 +158,7 @@ final class BeTrueTest : XCTestCase, XCTestCaseProvider { } } -final class BeFalsyTest : XCTestCase, XCTestCaseProvider { +final class BeFalsyTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (BeFalsyTest) -> () throws -> Void)] { return [ ("testShouldMatchNilTypes", testShouldMatchNilTypes), @@ -233,7 +233,7 @@ final class BeFalsyTest : XCTestCase, XCTestCaseProvider { } } -final class BeFalseTest : XCTestCase, XCTestCaseProvider { +final class BeFalseTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (BeFalseTest) -> () throws -> Void)] { return [ ("testShouldNotMatchTrue", testShouldNotMatchTrue), diff --git a/Tests/NimbleTests/Matchers/ContainElementSatisfyingTest.swift b/Tests/NimbleTests/Matchers/ContainElementSatisfyingTest.swift index 11eea955e..37a9c669d 100644 --- a/Tests/NimbleTests/Matchers/ContainElementSatisfyingTest.swift +++ b/Tests/NimbleTests/Matchers/ContainElementSatisfyingTest.swift @@ -18,7 +18,7 @@ final class ContainElementSatisfyingTest: XCTestCase, XCTestCaseProvider { } func testContainElementSatisfying() { - var orderIndifferentArray = [1,2,3] + var orderIndifferentArray = [1, 2, 3] expect(orderIndifferentArray).to(containElementSatisfying({ number in return number == 1 })) @@ -29,7 +29,7 @@ final class ContainElementSatisfyingTest: XCTestCase, XCTestCaseProvider { return number == 3 })) - orderIndifferentArray = [3,1,2] + orderIndifferentArray = [3, 1, 2] expect(orderIndifferentArray).to(containElementSatisfying({ number in return number == 1 })) @@ -42,7 +42,7 @@ final class ContainElementSatisfyingTest: XCTestCase, XCTestCaseProvider { } func testContainElementSatisfyingDefaultErrorMessage() { - let orderIndifferentArray = [1,2,3] + let orderIndifferentArray = [1, 2, 3] failsWithErrorMessage("expected to find object in collection that satisfies predicate") { expect(orderIndifferentArray).to(containElementSatisfying({ number in return number == 4 @@ -51,7 +51,7 @@ final class ContainElementSatisfyingTest: XCTestCase, XCTestCaseProvider { } func testContainElementSatisfyingSpecificErrorMessage() { - let orderIndifferentArray = [1,2,3] + let orderIndifferentArray = [1, 2, 3] failsWithErrorMessage("expected to find object in collection equal to 4") { expect(orderIndifferentArray).to(containElementSatisfying({ number in return number == 4 diff --git a/Tests/NimbleTests/Matchers/EqualTest.swift b/Tests/NimbleTests/Matchers/EqualTest.swift index a66a78444..29b3a475f 100644 --- a/Tests/NimbleTests/Matchers/EqualTest.swift +++ b/Tests/NimbleTests/Matchers/EqualTest.swift @@ -203,28 +203,28 @@ final class EqualTest: XCTestCase, XCTestCaseProvider { expect(1).toNot(equal(nil)) } - + func testArrayOfOptionalsEquality() { let array1: Array = [1, nil, 3] let array2: Array = [nil, 2, 3] let array3: Array = [1, nil, 3] - + expect(array1).toNot(equal(array2)) expect(array1).to(equal(array3)) expect(array2).toNot(equal(array3)) - + let allNils1: Array = [nil, nil, nil, nil] let allNils2: Array = [nil, nil, nil, nil] let notReallyAllNils: Array = [nil, nil, nil, "turtles"] - + expect(allNils1).to(equal(allNils2)) expect(allNils1).toNot(equal(notReallyAllNils)) - + let noNils1: Array = [1, 2, 3, 4, 5] let noNils2: Array = [1, 3, 5, 7, 9] - + expect(noNils1).toNot(equal(noNils2)) - + failsWithErrorMessage("expected to equal <[Optional(1), nil]>, got <[nil, Optional(2)]>") { let arrayOfOptionalInts: Array = [nil, 2] let anotherArrayOfOptionalInts: Array = [1, nil] diff --git a/Tests/NimbleTests/Matchers/MatchTest.swift b/Tests/NimbleTests/Matchers/MatchTest.swift index 5b6d77f6b..a95ba5610 100644 --- a/Tests/NimbleTests/Matchers/MatchTest.swift +++ b/Tests/NimbleTests/Matchers/MatchTest.swift @@ -1,7 +1,7 @@ import XCTest import Nimble -final class MatchTest:XCTestCase, XCTestCaseProvider { +final class MatchTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (MatchTest) -> () throws -> Void)] { return [ ("testMatchPositive", testMatchPositive), @@ -15,18 +15,18 @@ final class MatchTest:XCTestCase, XCTestCaseProvider { func testMatchPositive() { expect("11:14").to(match("\\d{2}:\\d{2}")) } - + func testMatchNegative() { expect("hello").toNot(match("\\d{2}:\\d{2}")) } - + func testMatchPositiveMessage() { let message = "expected to match <\\d{2}:\\d{2}>, got " failsWithErrorMessage(message) { expect("hello").to(match("\\d{2}:\\d{2}")) } } - + func testMatchNegativeMessage() { let message = "expected to not match <\\d{2}:\\d{2}>, got <11:14>" failsWithErrorMessage(message) { diff --git a/Tests/NimbleTests/Matchers/RaisesExceptionTest.swift b/Tests/NimbleTests/Matchers/RaisesExceptionTest.swift index 302a2f5c9..20461d912 100644 --- a/Tests/NimbleTests/Matchers/RaisesExceptionTest.swift +++ b/Tests/NimbleTests/Matchers/RaisesExceptionTest.swift @@ -93,7 +93,7 @@ final class RaisesExceptionTest: XCTestCase, XCTestCaseProvider { expect(exception.name).to(equal(NSExceptionName(rawValue:"foo"))) }) } - + failsWithErrorMessage("expected to raise exception with name that satisfies block, got no exception") { expect { self.anException }.to(raiseException(named: "foo") { (exception: NSException) in expect(exception.name.rawValue).to(equal("foo")) diff --git a/Tests/NimbleTests/Matchers/SatisfyAnyOfTest.swift b/Tests/NimbleTests/Matchers/SatisfyAnyOfTest.swift index 937895695..0bd9495a4 100644 --- a/Tests/NimbleTests/Matchers/SatisfyAnyOfTest.swift +++ b/Tests/NimbleTests/Matchers/SatisfyAnyOfTest.swift @@ -17,19 +17,19 @@ final class SatisfyAnyOfTest: XCTestCase, XCTestCaseProvider { #else expect(2 as NSNumber).toNot(satisfyAnyOf(equal(3 as NSNumber), equal("turtles" as NSString))) #endif - expect([1,2,3]).to(satisfyAnyOf(equal([1,2,3]), allPass({$0 < 4}), haveCount(3))) + expect([1, 2, 3]).to(satisfyAnyOf(equal([1, 2, 3]), allPass({$0 < 4}), haveCount(3))) expect("turtle").toNot(satisfyAnyOf(contain("a"), endWith("magic"))) expect(82.0).toNot(satisfyAnyOf(beLessThan(10.5), beGreaterThan(100.75), beCloseTo(50.1))) expect(false).to(satisfyAnyOf(beTrue(), beFalse())) expect(true).to(satisfyAnyOf(beTruthy(), beFalsy())) - + failsWithErrorMessage( "expected to match one of: {equal <3>}, or {equal <4>}, or {equal <5>}, got 2") { expect(2).to(satisfyAnyOf(equal(3), equal(4), equal(5))) } failsWithErrorMessage( "expected to match one of: {all be less than 4, but failed first at element <5> in <[5, 6, 7]>}, or {equal <[1, 2, 3, 4]>}, got [5, 6, 7]") { - expect([5,6,7]).to(satisfyAnyOf(allPass("be less than 4", {$0 < 4}), equal([1,2,3,4]))) + expect([5, 6, 7]).to(satisfyAnyOf(allPass("be less than 4", {$0 < 4}), equal([1, 2, 3, 4]))) } failsWithErrorMessage( "expected to match one of: {be true}, got false") { @@ -40,7 +40,7 @@ final class SatisfyAnyOfTest: XCTestCase, XCTestCaseProvider { expect(50.10001).toNot(satisfyAnyOf(beLessThan(10.5), beGreaterThan(100.75), beCloseTo(50.1))) } } - + func testOperatorOr() { expect(2).to(equal(2) || equal(3)) #if SUPPORT_IMPLICIT_BRIDGING_CONVERSION diff --git a/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift b/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift index c227b1b6d..9c66fe6b1 100644 --- a/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift +++ b/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift @@ -42,7 +42,7 @@ final class ThrowAssertionTest: XCTestCase, XCTestCaseProvider { var reachedPoint1 = false expect { reachedPoint1 = true }.toNot(throwAssertion()) - + expect(reachedPoint1) == true } diff --git a/Tests/NimbleTests/Matchers/ThrowErrorTest.swift b/Tests/NimbleTests/Matchers/ThrowErrorTest.swift index d7cd3121f..070d0f98b 100644 --- a/Tests/NimbleTests/Matchers/ThrowErrorTest.swift +++ b/Tests/NimbleTests/Matchers/ThrowErrorTest.swift @@ -1,12 +1,12 @@ import XCTest import Nimble -enum NimbleError : Error { +enum NimbleError: Error { case laugh case cry } -enum EquatableError : Error { +enum EquatableError: Error { case parameterized(x: Int) } @@ -20,13 +20,13 @@ func ==(lhs: EquatableError, rhs: EquatableError) -> Bool { } } -enum CustomDebugStringConvertibleError : Error { +enum CustomDebugStringConvertibleError: Error { case a case b } extension CustomDebugStringConvertibleError : CustomDebugStringConvertible { - var debugDescription : String { + var debugDescription: String { return "code=\(_code)" } } @@ -120,13 +120,13 @@ final class ThrowErrorTest: XCTestCase, XCTestCaseProvider { func testNegativeMatchesDoNotCallClosureWithoutError() { failsWithErrorMessage("expected to throw error that satisfies block, got no error") { - expect { return }.to(throwError { error in + expect { return }.to(throwError { _ in fail() }) } - + failsWithErrorMessage("expected to throw error that satisfies block, got no error") { - expect { return }.to(throwError(NimbleError.laugh) { error in + expect { return }.to(throwError(NimbleError.laugh) { _ in fail() }) } diff --git a/Tests/NimbleTests/SynchronousTests.swift b/Tests/NimbleTests/SynchronousTests.swift index 6234932d4..eefd178a0 100644 --- a/Tests/NimbleTests/SynchronousTests.swift +++ b/Tests/NimbleTests/SynchronousTests.swift @@ -47,19 +47,19 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { } func testToMatchesIfMatcherReturnsTrue() { - expect(1).to(MatcherFunc { expr, failure in true }) - expect{1}.to(MatcherFunc { expr, failure in true }) + expect(1).to(MatcherFunc { _, _ in true }) + expect {1}.to(MatcherFunc { _, _ in true }) } func testToProvidesActualValueExpression() { var value: Int? - expect(1).to(MatcherFunc { expr, failure in value = try expr.evaluate(); return true }) + expect(1).to(MatcherFunc { expr, _ in value = try expr.evaluate(); return true }) expect(value).to(equal(1)) } func testToProvidesAMemoizedActualValueExpression() { var callCount = 0 - expect{ callCount += 1 }.to(MatcherFunc { expr, failure in + expect { callCount += 1 }.to(MatcherFunc { expr, _ in _ = try expr.evaluate() _ = try expr.evaluate() return true @@ -69,7 +69,7 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { func testToProvidesAMemoizedActualValueExpressionIsEvaluatedAtMatcherControl() { var callCount = 0 - expect{ callCount += 1 }.to(MatcherFunc { expr, failure in + expect { callCount += 1 }.to(MatcherFunc { expr, _ in expect(callCount).to(equal(0)) _ = try expr.evaluate() return true @@ -86,19 +86,19 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { // repeated tests from to() for toNot() func testToNotMatchesIfMatcherReturnsTrue() { - expect(1).toNot(MatcherFunc { expr, failure in false }) - expect{1}.toNot(MatcherFunc { expr, failure in false }) + expect(1).toNot(MatcherFunc { _, _ in false }) + expect {1}.toNot(MatcherFunc { _, _ in false }) } func testToNotProvidesActualValueExpression() { var value: Int? - expect(1).toNot(MatcherFunc { expr, failure in value = try expr.evaluate(); return false }) + expect(1).toNot(MatcherFunc { expr, _ in value = try expr.evaluate(); return false }) expect(value).to(equal(1)) } func testToNotProvidesAMemoizedActualValueExpression() { var callCount = 0 - expect{ callCount += 1 }.toNot(MatcherFunc { expr, failure in + expect { callCount += 1 }.toNot(MatcherFunc { expr, _ in _ = try expr.evaluate() _ = try expr.evaluate() return false @@ -108,7 +108,7 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { func testToNotProvidesAMemoizedActualValueExpressionIsEvaluatedAtMatcherControl() { var callCount = 0 - expect{ callCount += 1 }.toNot(MatcherFunc { expr, failure in + expect { callCount += 1 }.toNot(MatcherFunc { expr, _ in expect(callCount).to(equal(0)) _ = try expr.evaluate() return false @@ -118,12 +118,11 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { func testToNotNegativeMatches() { failsWithErrorMessage("expected to not match, got <1>") { - expect(1).toNot(MatcherFunc { expr, failure in true }) + expect(1).toNot(MatcherFunc { _, _ in true }) } } - func testNotToMatchesLikeToNot() { - expect(1).notTo(MatcherFunc { expr, failure in false }) + expect(1).notTo(MatcherFunc { _, _ in false }) } } diff --git a/Tests/NimbleTests/UserDescriptionTest.swift b/Tests/NimbleTests/UserDescriptionTest.swift index e22d64e84..9bb64b623 100644 --- a/Tests/NimbleTests/UserDescriptionTest.swift +++ b/Tests/NimbleTests/UserDescriptionTest.swift @@ -12,31 +12,31 @@ final class UserDescriptionTest: XCTestCase, XCTestCaseProvider { ("testToNotEventuallyMatch_CustomFailureMessage", testToNotEventuallyMatch_CustomFailureMessage), ] } - + func testToMatcher_CustomFailureMessage() { failsWithErrorMessage( "These aren't equal!\n" + "expected to match, got <1>") { - expect(1).to(MatcherFunc { expr, failure in false }, description: "These aren't equal!") + expect(1).to(MatcherFunc { _, _ in false }, description: "These aren't equal!") } } - + func testNotToMatcher_CustomFailureMessage() { failsWithErrorMessage( "These aren't equal!\n" + "expected to not match, got <1>") { - expect(1).notTo(MatcherFunc { expr, failure in true }, description: "These aren't equal!") + expect(1).notTo(MatcherFunc { _, _ in true }, description: "These aren't equal!") } } - + func testToNotMatcher_CustomFailureMessage() { failsWithErrorMessage( "These aren't equal!\n" + "expected to not match, got <1>") { - expect(1).toNot(MatcherFunc { expr, failure in true }, description: "These aren't equal!") + expect(1).toNot(MatcherFunc { _, _ in true }, description: "These aren't equal!") } } - + func testToEventuallyMatch_CustomFailureMessage() { failsWithErrorMessage( "These aren't eventually equal!\n" + @@ -44,7 +44,7 @@ final class UserDescriptionTest: XCTestCase, XCTestCaseProvider { expect { 0 }.toEventually(equal(1), description: "These aren't eventually equal!") } } - + func testToEventuallyNotMatch_CustomFailureMessage() { failsWithErrorMessage( "These are eventually equal!\n" + @@ -52,7 +52,7 @@ final class UserDescriptionTest: XCTestCase, XCTestCaseProvider { expect { 1 }.toEventuallyNot(equal(1), description: "These are eventually equal!") } } - + func testToNotEventuallyMatch_CustomFailureMessage() { failsWithErrorMessage( "These are eventually equal!\n" +