Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gardening] Remove unnecessary parentheses #667

Merged
merged 1 commit into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions Sources/Nimble/Adapters/NMBExpectation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,57 +54,57 @@ public class NMBExpectation: NSObject {
}

@objc public var withTimeout: (TimeInterval) -> NMBExpectation {
return ({ timeout in self._timeout = timeout
return { timeout in self._timeout = timeout
return self
})
}
}

@objc public var to: (NMBMatcher) -> Void {
return ({ matcher in
return { matcher in
if let pred = matcher as? NMBPredicate {
self.expectValue.to(from(objcPredicate: pred))
} else {
self.expectValue.to(ObjCMatcherWrapper(matcher: matcher))
}
})
}
}

@objc public var toWithDescription: (NMBMatcher, String) -> Void {
return ({ matcher, description in
return { matcher, description in
if let pred = matcher as? NMBPredicate {
self.expectValue.to(from(objcPredicate: pred), description: description)
} else {
self.expectValue.to(ObjCMatcherWrapper(matcher: matcher), description: description)
}
})
}
}

@objc public var toNot: (NMBMatcher) -> Void {
return ({ matcher in
return { matcher in
if let pred = matcher as? NMBPredicate {
self.expectValue.toNot(from(objcPredicate: pred))
} else {
self.expectValue.toNot(ObjCMatcherWrapper(matcher: matcher))
}
})
}
}

@objc public var toNotWithDescription: (NMBMatcher, String) -> Void {
return ({ matcher, description in
return { matcher, description in
if let pred = matcher as? NMBPredicate {
self.expectValue.toNot(from(objcPredicate: pred), description: description)
} else {
self.expectValue.toNot(ObjCMatcherWrapper(matcher: matcher), description: description)
}
})
}
}

@objc public var notTo: (NMBMatcher) -> Void { return toNot }

@objc public var notToWithDescription: (NMBMatcher, String) -> Void { return toNotWithDescription }

@objc public var toEventually: (NMBMatcher) -> Void {
return ({ matcher in
return { matcher in
if let pred = matcher as? NMBPredicate {
self.expectValue.toEventually(
from(objcPredicate: pred),
Expand All @@ -118,11 +118,11 @@ public class NMBExpectation: NSObject {
description: nil
)
}
})
}
}

@objc public var toEventuallyWithDescription: (NMBMatcher, String) -> Void {
return ({ matcher, description in
return { matcher, description in
if let pred = matcher as? NMBPredicate {
self.expectValue.toEventually(
from(objcPredicate: pred),
Expand All @@ -136,11 +136,11 @@ public class NMBExpectation: NSObject {
description: description
)
}
})
}
}

@objc public var toEventuallyNot: (NMBMatcher) -> Void {
return ({ matcher in
return { matcher in
if let pred = matcher as? NMBPredicate {
self.expectValue.toEventuallyNot(
from(objcPredicate: pred),
Expand All @@ -154,11 +154,11 @@ public class NMBExpectation: NSObject {
description: nil
)
}
})
}
}

@objc public var toEventuallyNotWithDescription: (NMBMatcher, String) -> Void {
return ({ matcher, description in
return { matcher, description in
if let pred = matcher as? NMBPredicate {
self.expectValue.toEventuallyNot(
from(objcPredicate: pred),
Expand All @@ -172,7 +172,7 @@ public class NMBExpectation: NSObject {
description: description
)
}
})
}
}

@objc public var toNotEventually: (NMBMatcher) -> Void {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Nimble/Expression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import Foundation
// closure once; even if repeat calls to the returned closure
internal func memoizedClosure<T>(_ closure: @escaping () throws -> T) -> (Bool) throws -> T {
var cache: T?
return ({ withoutCaching in
return { withoutCaching in
if withoutCaching || cache == nil {
cache = try closure()
}
return cache!
})
}
}

/// Expression represents the closure of the value inside expect(...).
Expand Down
4 changes: 2 additions & 2 deletions Sources/Nimble/Matchers/BeCloseTo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public class NMBObjCBeCloseToMatcher: NSObject, NMBMatcher {
}

@objc public var within: (CDouble) -> NMBObjCBeCloseToMatcher {
return ({ delta in
return { delta in
return NMBObjCBeCloseToMatcher(expected: self._expected, within: delta)
})
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Nimble/Matchers/MatcherProtocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ extension Matcher {
}

var toClosure: (Expression<ValueType>, FailureMessage, Bool) throws -> Bool {
return ({ expr, msg, expectedResult in
return { expr, msg, expectedResult in
if expectedResult {
return try self.matches(expr, failureMessage: msg)
} else {
return try self.doesNotMatch(expr, failureMessage: msg)
}
})
}
}
}

Expand Down
16 changes: 8 additions & 8 deletions Sources/Nimble/Matchers/RaisesException.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,47 +161,47 @@ public class NMBObjCRaiseExceptionMatcher: NSObject, NMBMatcher {
}

@objc public var named: (_ name: String) -> NMBObjCRaiseExceptionMatcher {
return ({ name in
return { name in
return NMBObjCRaiseExceptionMatcher(
name: name,
reason: self._reason,
userInfo: self._userInfo,
block: self._block
)
})
}
}

@objc public var reason: (_ reason: String?) -> NMBObjCRaiseExceptionMatcher {
return ({ reason in
return { reason in
return NMBObjCRaiseExceptionMatcher(
name: self._name,
reason: reason,
userInfo: self._userInfo,
block: self._block
)
})
}
}

@objc public var userInfo: (_ userInfo: NSDictionary?) -> NMBObjCRaiseExceptionMatcher {
return ({ userInfo in
return { userInfo in
return NMBObjCRaiseExceptionMatcher(
name: self._name,
reason: self._reason,
userInfo: userInfo,
block: self._block
)
})
}
}

@objc public var satisfyingBlock: (_ block: ((NSException) -> Void)?) -> NMBObjCRaiseExceptionMatcher {
return ({ block in
return { block in
return NMBObjCRaiseExceptionMatcher(
name: self._name,
reason: self._reason,
userInfo: self._userInfo,
block: block
)
})
}
}
}

Expand Down