diff --git a/.travis.yml b/.travis.yml index d7be7839e..0b64ea7d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,14 @@ matrix: env: TYPE=tvos NIMBLE_RUNTIME_TVOS_SDK_VERSION=10.0 - os: osx env: TYPE=macos + - os: osx + env: TYPE=macos + osx_image: xcode9 + - os: osx + env: TYPE=swiftpm - os: osx env: TYPE=swiftpm + osx_image: xcode9 - os: linux dist: trusty sudo: required diff --git a/Nimble.xcodeproj/project.pbxproj b/Nimble.xcodeproj/project.pbxproj index 3dfcaeff2..ed0beab80 100644 --- a/Nimble.xcodeproj/project.pbxproj +++ b/Nimble.xcodeproj/project.pbxproj @@ -164,7 +164,6 @@ 1F5DF1851BDCA0F500C3A531 /* Equal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1C1968AB07008ED995 /* Equal.swift */; }; 1F5DF1861BDCA0F500C3A531 /* HaveCount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472FD1341B9E085700C7B8DA /* HaveCount.swift */; }; 1F5DF1871BDCA0F500C3A531 /* Match.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB4D5EC19FE43C200E9D9FE /* Match.swift */; }; - 1F5DF1881BDCA0F500C3A531 /* MatcherProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */; }; 1F5DF1891BDCA0F500C3A531 /* RaisesException.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1E1968AB07008ED995 /* RaisesException.swift */; }; 1F5DF18A1BDCA0F500C3A531 /* ThrowError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29EA59651B551EE6002D767E /* ThrowError.swift */; }; 1F5DF18B1BDCA0F500C3A531 /* Functional.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD251968AB07008ED995 /* Functional.swift */; }; @@ -296,8 +295,6 @@ 1FD8CD591968AB07008ED995 /* EndWith.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1B1968AB07008ED995 /* EndWith.swift */; }; 1FD8CD5A1968AB07008ED995 /* Equal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1C1968AB07008ED995 /* Equal.swift */; }; 1FD8CD5B1968AB07008ED995 /* Equal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1C1968AB07008ED995 /* Equal.swift */; }; - 1FD8CD5C1968AB07008ED995 /* MatcherProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */; }; - 1FD8CD5D1968AB07008ED995 /* MatcherProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */; }; 1FD8CD5E1968AB07008ED995 /* RaisesException.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1E1968AB07008ED995 /* RaisesException.swift */; }; 1FD8CD5F1968AB07008ED995 /* RaisesException.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1E1968AB07008ED995 /* RaisesException.swift */; }; 1FD8CD6A1968AB07008ED995 /* Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD261968AB07008ED995 /* Async.swift */; }; @@ -386,6 +383,9 @@ CD79C9B51D2CC848004B6F9A /* ObjCUserDescriptionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 965B0D081B62B8ED0005AE66 /* ObjCUserDescriptionTest.m */; }; CD79C9B61D2CC848004B6F9A /* ObjCAllPassTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEFAEB31A93CBE6005CA37A /* ObjCAllPassTest.m */; }; CD79C9B71D2CC848004B6F9A /* ObjCSatisfyAnyOfTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B5358C11C39155600A23FAA /* ObjCSatisfyAnyOfTest.m */; }; + CDD80B831F2030790002CD65 /* MatcherProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */; }; + CDD80B841F20307A0002CD65 /* MatcherProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */; }; + CDD80B851F20307B0002CD65 /* MatcherProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */; }; DA9E8C821A414BB9002633C2 /* DSL+Wait.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9E8C811A414BB9002633C2 /* DSL+Wait.swift */; }; DA9E8C831A414BB9002633C2 /* DSL+Wait.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9E8C811A414BB9002633C2 /* DSL+Wait.swift */; }; DD72EC641A93874A002F7651 /* AllPassTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD72EC631A93874A002F7651 /* AllPassTest.swift */; }; @@ -1170,33 +1170,33 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0820; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Jeff Hui"; TargetAttributes = { 1F1A74281940169200FFFC47 = { CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 1F1A74331940169200FFFC47 = { CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; TestTargetID = 1F1A74281940169200FFFC47; }; 1F5DF1541BDCA0CE00C3A531 = { CreatedOnToolsVersion = 7.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 1F5DF15D1BDCA0CE00C3A531 = { CreatedOnToolsVersion = 7.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 1F925EAC195C0D6300ED456B = { CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 1F925EB6195C0D6300ED456B = { CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; TestTargetID = 1F925EAC195C0D6300ED456B; }; A8F2B2541E79A4AB005BDD17 = { @@ -1332,6 +1332,7 @@ 1F12BEE01E7791B9006952EC /* CwlCatchException.m in Sources */, AE7ADE451C80BF8000B94CD3 /* MatchError.swift in Sources */, 1FC494AA1C29CBA40010975C /* NimbleEnvironment.swift in Sources */, + CDD80B841F20307A0002CD65 /* MatcherProtocols.swift in Sources */, 1FD8CD5E1968AB07008ED995 /* RaisesException.swift in Sources */, 1FD8CD561968AB07008ED995 /* Contain.swift in Sources */, 1FD8CD481968AB07008ED995 /* BeGreaterThanOrEqualTo.swift in Sources */, @@ -1345,7 +1346,6 @@ 1FD8CD521968AB07008ED995 /* BeNil.swift in Sources */, 1FD8CD6A1968AB07008ED995 /* Async.swift in Sources */, 1FD8CD581968AB07008ED995 /* EndWith.swift in Sources */, - 1FD8CD5C1968AB07008ED995 /* MatcherProtocols.swift in Sources */, 1FD8CD341968AB07008ED995 /* DSL.swift in Sources */, 1F12BEDD1E7791B9006952EC /* CwlCatchException.swift in Sources */, 7B5358BE1C38479700A23FAA /* SatisfyAnyOf.swift in Sources */, @@ -1432,7 +1432,6 @@ 1F5DF1791BDCA0F500C3A531 /* BeCloseTo.swift in Sources */, 1F5DF16C1BDCA0F500C3A531 /* AssertionRecorder.swift in Sources */, 1F1871D71CA89EEF00A34BF2 /* NMBExceptionCapture.m in Sources */, - 1F5DF1881BDCA0F500C3A531 /* MatcherProtocols.swift in Sources */, 1F5DF16E1BDCA0F500C3A531 /* NimbleXCTestHandler.swift in Sources */, 7A6AB2C61E7F628A00A2F694 /* ToSucceed.swift in Sources */, 1F5DF1751BDCA0F500C3A531 /* FailureMessage.swift in Sources */, @@ -1478,6 +1477,7 @@ 1F5DF1841BDCA0F500C3A531 /* EndWith.swift in Sources */, 1F5DF18D1BDCA0F500C3A531 /* SourceLocation.swift in Sources */, 1F5DF1701BDCA0F500C3A531 /* DSL.swift in Sources */, + CDD80B851F20307B0002CD65 /* MatcherProtocols.swift in Sources */, 1F5DF1721BDCA0F500C3A531 /* Expectation.swift in Sources */, 7B5358C01C38479700A23FAA /* SatisfyAnyOf.swift in Sources */, 7B13BA0C1DD361D300C9098C /* ContainElementSatisfying.swift in Sources */, @@ -1598,6 +1598,7 @@ AE7ADE461C80BF8000B94CD3 /* MatchError.swift in Sources */, 1FC494AB1C29CBA40010975C /* NimbleEnvironment.swift in Sources */, 1FD8CD5F1968AB07008ED995 /* RaisesException.swift in Sources */, + CDD80B831F2030790002CD65 /* MatcherProtocols.swift in Sources */, 1FD8CD571968AB07008ED995 /* Contain.swift in Sources */, 7A0A26231E7F52360092A34E /* ToSucceed.swift in Sources */, 1FD8CD491968AB07008ED995 /* BeGreaterThanOrEqualTo.swift in Sources */, @@ -1612,7 +1613,6 @@ 1FD8CD6B1968AB07008ED995 /* Async.swift in Sources */, 964CFEFE1C4FF48900513336 /* ThrowAssertion.swift in Sources */, 1FD8CD591968AB07008ED995 /* EndWith.swift in Sources */, - 1FD8CD5D1968AB07008ED995 /* MatcherProtocols.swift in Sources */, 1FD8CD351968AB07008ED995 /* DSL.swift in Sources */, 7B5358BF1C38479700A23FAA /* SatisfyAnyOf.swift in Sources */, 1F12BE9B1E778F70006952EC /* CwlDarwinDefinitions.swift in Sources */, @@ -1751,14 +1751,20 @@ CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_MODULES_AUTOLINK = NO; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -1807,14 +1813,20 @@ CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_MODULES_AUTOLINK = NO; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; diff --git a/Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-iOS.xcscheme b/Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-iOS.xcscheme index ef8ccf699..0cbad8421 100644 --- a/Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-iOS.xcscheme +++ b/Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-iOS.xcscheme @@ -1,6 +1,6 @@ Predicate { return Predicate { actualExpression in @@ -36,7 +36,7 @@ public class NMBExpectation: NSObject { internal let _line: UInt internal var _timeout: TimeInterval = 1.0 - public init(actualBlock: @escaping () -> NSObject!, negative: Bool, file: FileString, line: UInt) { + @objc public init(actualBlock: @escaping () -> NSObject!, negative: Bool, file: FileString, line: UInt) { self._actualBlock = actualBlock self._negative = negative self._file = file @@ -175,7 +175,7 @@ public class NMBExpectation: NSObject { public var toNotEventuallyWithDescription: (NMBMatcher, String) -> Void { return toEventuallyNotWithDescription } - public class func failWithMessage(_ message: String, file: FileString, line: UInt) { + @objc public class func failWithMessage(_ message: String, file: FileString, line: UInt) { fail(message, location: SourceLocation(file: file, line: line)) } } diff --git a/Sources/Nimble/Adapters/NimbleXCTestHandler.swift b/Sources/Nimble/Adapters/NimbleXCTestHandler.swift index b311a6e9e..0ad85909b 100644 --- a/Sources/Nimble/Adapters/NimbleXCTestHandler.swift +++ b/Sources/Nimble/Adapters/NimbleXCTestHandler.swift @@ -66,7 +66,12 @@ private func recordFailure(_ message: String, location: SourceLocation) { XCTFail("\(message)", file: location.file, line: location.line) #else if let testCase = CurrentTestCaseTracker.sharedInstance.currentTestCase { - testCase.recordFailure(withDescription: message, inFile: location.file, atLine: location.line, expected: true) + #if swift(>=4) + let line = Int(location.line) + #else + let line = location.line + #endif + testCase.recordFailure(withDescription: message, inFile: location.file, atLine: line, expected: true) } else { let msg = "Attempted to report a test failure to XCTest while no test case was running. " + "The failure was:\n\"\(message)\"\nIt occurred at: \(location.file):\(location.line)" diff --git a/Sources/Nimble/Matchers/AllPass.swift b/Sources/Nimble/Matchers/AllPass.swift index cde136b6f..24da9591b 100644 --- a/Sources/Nimble/Matchers/AllPass.swift +++ b/Sources/Nimble/Matchers/AllPass.swift @@ -65,7 +65,7 @@ private func createPredicate(_ elementMatcher: Predicate) #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func allPassMatcher(_ matcher: NMBMatcher) -> NMBPredicate { + @objc public class func allPassMatcher(_ matcher: NMBMatcher) -> NMBPredicate { return NMBPredicate { actualExpression in let location = actualExpression.location let actualValue = try! actualExpression.evaluate() diff --git a/Sources/Nimble/Matchers/BeAKindOf.swift b/Sources/Nimble/Matchers/BeAKindOf.swift index e1bfe0fac..567452515 100644 --- a/Sources/Nimble/Matchers/BeAKindOf.swift +++ b/Sources/Nimble/Matchers/BeAKindOf.swift @@ -58,7 +58,7 @@ public func beAKindOf(_ expectedClass: AnyClass) -> Predicate { } extension NMBObjCMatcher { - public class func beAKindOfMatcher(_ expected: AnyClass) -> NMBMatcher { + @objc public class func beAKindOfMatcher(_ expected: AnyClass) -> NMBMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in return try! beAKindOf(expected).matches(actualExpression, failureMessage: failureMessage) } diff --git a/Sources/Nimble/Matchers/BeAnInstanceOf.swift b/Sources/Nimble/Matchers/BeAnInstanceOf.swift index f34513a8f..70c566155 100644 --- a/Sources/Nimble/Matchers/BeAnInstanceOf.swift +++ b/Sources/Nimble/Matchers/BeAnInstanceOf.swift @@ -47,7 +47,7 @@ public func beAnInstanceOf(_ expectedClass: AnyClass) -> Predicate { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func beAnInstanceOfMatcher(_ expected: AnyClass) -> NMBMatcher { + @objc public class func beAnInstanceOfMatcher(_ expected: AnyClass) -> NMBMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in return try! beAnInstanceOf(expected).matches(actualExpression, failureMessage: failureMessage) } diff --git a/Sources/Nimble/Matchers/BeCloseTo.swift b/Sources/Nimble/Matchers/BeCloseTo.swift index 181e1dce8..cd43bd655 100644 --- a/Sources/Nimble/Matchers/BeCloseTo.swift +++ b/Sources/Nimble/Matchers/BeCloseTo.swift @@ -1,6 +1,6 @@ import Foundation -internal let DefaultDelta = 0.0001 +public let DefaultDelta = 0.0001 internal func isCloseTo(_ actualValue: NMBDoubleConvertible?, expectedValue: NMBDoubleConvertible, @@ -69,7 +69,7 @@ public class NMBObjCBeCloseToMatcher: NSObject, NMBMatcher { } extension NMBObjCMatcher { - public class func beCloseToMatcher(_ expected: NSNumber, within: CDouble) -> NMBObjCBeCloseToMatcher { + @objc public class func beCloseToMatcher(_ expected: NSNumber, within: CDouble) -> NMBObjCBeCloseToMatcher { return NMBObjCBeCloseToMatcher(expected: expected, within: within) } } diff --git a/Sources/Nimble/Matchers/BeEmpty.swift b/Sources/Nimble/Matchers/BeEmpty.swift index 13b7ccb2b..d27466e68 100644 --- a/Sources/Nimble/Matchers/BeEmpty.swift +++ b/Sources/Nimble/Matchers/BeEmpty.swift @@ -63,7 +63,7 @@ public func beEmpty() -> Predicate { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func beEmptyMatcher() -> NMBPredicate { + @objc public class func beEmptyMatcher() -> NMBPredicate { return NMBPredicate { actualExpression in let location = actualExpression.location let actualValue = try! actualExpression.evaluate() diff --git a/Sources/Nimble/Matchers/BeGreaterThan.swift b/Sources/Nimble/Matchers/BeGreaterThan.swift index 222c81ec6..7bd8814df 100644 --- a/Sources/Nimble/Matchers/BeGreaterThan.swift +++ b/Sources/Nimble/Matchers/BeGreaterThan.swift @@ -31,7 +31,7 @@ public func > (lhs: Expectation, rhs: NMBComparable?) { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func beGreaterThanMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { + @objc public class func beGreaterThanMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let expr = actualExpression.cast { $0 as? NMBComparable } return try! beGreaterThan(expected).matches(expr, failureMessage: failureMessage) diff --git a/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift b/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift index d8375afc8..55d8e7bc9 100644 --- a/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift +++ b/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift @@ -34,7 +34,7 @@ public func >=(lhs: Expectation, rhs: T) { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func beGreaterThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { + @objc public class func beGreaterThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let expr = actualExpression.cast { $0 as? NMBComparable } return try! beGreaterThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage) diff --git a/Sources/Nimble/Matchers/BeIdenticalTo.swift b/Sources/Nimble/Matchers/BeIdenticalTo.swift index 8e54f231a..ad19def17 100644 --- a/Sources/Nimble/Matchers/BeIdenticalTo.swift +++ b/Sources/Nimble/Matchers/BeIdenticalTo.swift @@ -36,7 +36,7 @@ public func be(_ expected: Any?) -> Predicate { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func beIdenticalToMatcher(_ expected: NSObject?) -> NMBObjCMatcher { + @objc public class func beIdenticalToMatcher(_ expected: NSObject?) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let aExpr = actualExpression.cast { $0 as Any? } return try! beIdenticalTo(expected).matches(aExpr, failureMessage: failureMessage) diff --git a/Sources/Nimble/Matchers/BeLessThan.swift b/Sources/Nimble/Matchers/BeLessThan.swift index 1b4cf122e..8047efd7f 100644 --- a/Sources/Nimble/Matchers/BeLessThan.swift +++ b/Sources/Nimble/Matchers/BeLessThan.swift @@ -31,7 +31,7 @@ public func < (lhs: Expectation, rhs: NMBComparable?) { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func beLessThanMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { + @objc public class func beLessThanMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let expr = actualExpression.cast { $0 as? NMBComparable } return try! beLessThan(expected).matches(expr, failureMessage: failureMessage) diff --git a/Sources/Nimble/Matchers/BeLessThanOrEqual.swift b/Sources/Nimble/Matchers/BeLessThanOrEqual.swift index cd4400ba1..098a85283 100644 --- a/Sources/Nimble/Matchers/BeLessThanOrEqual.swift +++ b/Sources/Nimble/Matchers/BeLessThanOrEqual.swift @@ -32,7 +32,7 @@ public func <=(lhs: Expectation, rhs: T) { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func beLessThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { + @objc public class func beLessThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil:false) { actualExpression, failureMessage in let expr = actualExpression.cast { $0 as? NMBComparable } return try! beLessThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage) diff --git a/Sources/Nimble/Matchers/BeLogical.swift b/Sources/Nimble/Matchers/BeLogical.swift index 1f8a94b67..2b18b4c4b 100644 --- a/Sources/Nimble/Matchers/BeLogical.swift +++ b/Sources/Nimble/Matchers/BeLogical.swift @@ -136,28 +136,28 @@ public func beFalsy() -> Predicate NMBObjCMatcher { + @objc public class func beTruthyMatcher() -> NMBObjCMatcher { return NMBObjCMatcher { actualExpression, failureMessage in let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false } return try! beTruthy().matches(expr, failureMessage: failureMessage) } } - public class func beFalsyMatcher() -> NMBObjCMatcher { + @objc public class func beFalsyMatcher() -> NMBObjCMatcher { return NMBObjCMatcher { actualExpression, failureMessage in let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false } return try! beFalsy().matches(expr, failureMessage: failureMessage) } } - public class func beTrueMatcher() -> NMBObjCMatcher { + @objc public class func beTrueMatcher() -> NMBObjCMatcher { return NMBObjCMatcher { actualExpression, failureMessage in let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false } return try! beTrue().matches(expr, failureMessage: failureMessage) } } - public class func beFalseMatcher() -> NMBObjCMatcher { + @objc public class func beFalseMatcher() -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false } return try! beFalse().matches(expr, failureMessage: failureMessage) diff --git a/Sources/Nimble/Matchers/BeNil.swift b/Sources/Nimble/Matchers/BeNil.swift index 1bf3e9c76..a22e0f4c1 100644 --- a/Sources/Nimble/Matchers/BeNil.swift +++ b/Sources/Nimble/Matchers/BeNil.swift @@ -10,7 +10,7 @@ public func beNil() -> Predicate { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func beNilMatcher() -> NMBObjCMatcher { + @objc public class func beNilMatcher() -> NMBObjCMatcher { return NMBObjCMatcher { actualExpression, failureMessage in return try! beNil().matches(actualExpression, failureMessage: failureMessage) } diff --git a/Sources/Nimble/Matchers/BeginWith.swift b/Sources/Nimble/Matchers/BeginWith.swift index 0ebdd6b5c..c2ab568bd 100644 --- a/Sources/Nimble/Matchers/BeginWith.swift +++ b/Sources/Nimble/Matchers/BeginWith.swift @@ -44,7 +44,7 @@ public func beginWith(_ startingSubstring: String) -> Predicate { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func beginWithMatcher(_ expected: Any) -> NMBObjCMatcher { + @objc public class func beginWithMatcher(_ expected: Any) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let actual = try! actualExpression.evaluate() if (actual as? String) != nil { diff --git a/Sources/Nimble/Matchers/Contain.swift b/Sources/Nimble/Matchers/Contain.swift index 1cc265dc8..8f93acbfb 100644 --- a/Sources/Nimble/Matchers/Contain.swift +++ b/Sources/Nimble/Matchers/Contain.swift @@ -69,7 +69,7 @@ public func contain(_ items: [Any?]) -> Predicate { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func containMatcher(_ expected: [NSObject]) -> NMBObjCMatcher { + @objc public class func containMatcher(_ expected: [NSObject]) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let location = actualExpression.location let actualValue = try! actualExpression.evaluate() diff --git a/Sources/Nimble/Matchers/ContainElementSatisfying.swift b/Sources/Nimble/Matchers/ContainElementSatisfying.swift index 18519d7b5..8b3797aac 100644 --- a/Sources/Nimble/Matchers/ContainElementSatisfying.swift +++ b/Sources/Nimble/Matchers/ContainElementSatisfying.swift @@ -27,7 +27,7 @@ public func containElementSatisfying(_ predicate: @escaping ((T) #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func containElementSatisfyingMatcher(_ predicate: @escaping ((NSObject) -> Bool)) -> NMBObjCMatcher { + @objc public class func containElementSatisfyingMatcher(_ predicate: @escaping ((NSObject) -> Bool)) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let value = try! actualExpression.evaluate() guard let enumeration = value as? NSFastEnumeration else { diff --git a/Sources/Nimble/Matchers/EndWith.swift b/Sources/Nimble/Matchers/EndWith.swift index 9b75adc7f..a6f9f9101 100644 --- a/Sources/Nimble/Matchers/EndWith.swift +++ b/Sources/Nimble/Matchers/EndWith.swift @@ -56,7 +56,7 @@ public func endWith(_ endingSubstring: String) -> Predicate { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func endWithMatcher(_ expected: Any) -> NMBObjCMatcher { + @objc public class func endWithMatcher(_ expected: Any) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let actual = try! actualExpression.evaluate() if (actual as? String) != nil { diff --git a/Sources/Nimble/Matchers/Equal.swift b/Sources/Nimble/Matchers/Equal.swift index 94c9874ea..9467154a4 100644 --- a/Sources/Nimble/Matchers/Equal.swift +++ b/Sources/Nimble/Matchers/Equal.swift @@ -211,7 +211,7 @@ public func !=(lhs: Expectation<[T: C]>, rhs: [T: C]?) { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func equalMatcher(_ expected: NSObject) -> NMBMatcher { + @objc public class func equalMatcher(_ expected: NSObject) -> NMBMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in return try! equal(expected).matches(actualExpression, failureMessage: failureMessage) } diff --git a/Sources/Nimble/Matchers/HaveCount.swift b/Sources/Nimble/Matchers/HaveCount.swift index c3427af49..e83941483 100644 --- a/Sources/Nimble/Matchers/HaveCount.swift +++ b/Sources/Nimble/Matchers/HaveCount.swift @@ -39,7 +39,7 @@ public func haveCount(_ expectedValue: Int) -> Predicate { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func haveCountMatcher(_ expected: NSNumber) -> NMBObjCMatcher { + @objc public class func haveCountMatcher(_ expected: NSNumber) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let location = actualExpression.location let actualValue = try! actualExpression.evaluate() diff --git a/Sources/Nimble/Matchers/Match.swift b/Sources/Nimble/Matchers/Match.swift index fa3d560a3..1e5762f69 100644 --- a/Sources/Nimble/Matchers/Match.swift +++ b/Sources/Nimble/Matchers/Match.swift @@ -19,7 +19,7 @@ public func match(_ expectedValue: String?) -> Predicate { #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func matchMatcher(_ expected: NSString) -> NMBMatcher { + @objc public class func matchMatcher(_ expected: NSString) -> NMBMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let actual = actualExpression.cast { $0 as? String } return try! match(expected.description).matches(actual, failureMessage: failureMessage) diff --git a/Sources/Nimble/Matchers/MatcherProtocols.swift b/Sources/Nimble/Matchers/MatcherProtocols.swift index 453f5b1fb..fff3c776b 100644 --- a/Sources/Nimble/Matchers/MatcherProtocols.swift +++ b/Sources/Nimble/Matchers/MatcherProtocols.swift @@ -5,7 +5,7 @@ import Foundation #endif /// Implement this protocol to implement a custom matcher for Swift -@available(*, deprecated, message: "Use to Predicate instead") +@available(*, deprecated, message: "Use Predicate instead") public protocol Matcher { associatedtype ValueType func matches(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool diff --git a/Sources/Nimble/Matchers/PostNotification.swift b/Sources/Nimble/Matchers/PostNotification.swift index 28560c6e5..8288bb06f 100644 --- a/Sources/Nimble/Matchers/PostNotification.swift +++ b/Sources/Nimble/Matchers/PostNotification.swift @@ -36,11 +36,9 @@ internal class NotificationCollector { private let mainThread = pthread_self() -let notificationCenterDefault = NotificationCenter.default - public func postNotifications( _ notificationsMatcher: T, - fromNotificationCenter center: NotificationCenter = notificationCenterDefault) + fromNotificationCenter center: NotificationCenter = .default) -> Predicate where T: Matcher, T.ValueType == [Notification] { diff --git a/Sources/Nimble/Matchers/RaisesException.swift b/Sources/Nimble/Matchers/RaisesException.swift index 286fdc2eb..6a0bfde85 100644 --- a/Sources/Nimble/Matchers/RaisesException.swift +++ b/Sources/Nimble/Matchers/RaisesException.swift @@ -176,7 +176,7 @@ public class NMBObjCRaiseExceptionMatcher: NSObject, NMBMatcher { } extension NMBObjCMatcher { - public class func raiseExceptionMatcher() -> NMBObjCRaiseExceptionMatcher { + @objc public class func raiseExceptionMatcher() -> NMBObjCRaiseExceptionMatcher { return NMBObjCRaiseExceptionMatcher(name: nil, reason: nil, userInfo: nil, block: nil) } } diff --git a/Sources/Nimble/Matchers/SatisfyAnyOf.swift b/Sources/Nimble/Matchers/SatisfyAnyOf.swift index 47b047291..e0fb35297 100644 --- a/Sources/Nimble/Matchers/SatisfyAnyOf.swift +++ b/Sources/Nimble/Matchers/SatisfyAnyOf.swift @@ -74,7 +74,7 @@ public func || (left: MatcherFunc, right: MatcherFunc) -> Predicate #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) extension NMBObjCMatcher { - public class func satisfyAnyOfMatcher(_ matchers: [NMBMatcher]) -> NMBPredicate { + @objc public class func satisfyAnyOfMatcher(_ matchers: [NMBMatcher]) -> NMBPredicate { return NMBPredicate { actualExpression in if matchers.isEmpty { return NMBPredicateResult( diff --git a/Sources/NimbleObjectiveC/DSL.h b/Sources/NimbleObjectiveC/DSL.h index 4538fb475..caa3f7c73 100644 --- a/Sources/NimbleObjectiveC/DSL.h +++ b/Sources/NimbleObjectiveC/DSL.h @@ -30,12 +30,12 @@ NS_ASSUME_NONNULL_BEGIN #define DEFINE_NMB_EXPECT_OVERLOAD(TYPE, EXPR) \ NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE \ - NMBExpectation *NMB_expect(TYPE(^actualBlock)(), NSString *file, NSUInteger line) { \ + NMBExpectation *NMB_expect(TYPE(^actualBlock)(void), NSString *file, NSUInteger line) { \ return NMB_expect(^id { return EXPR; }, file, line); \ } NIMBLE_EXPORT NIMBLE_OVERLOADABLE - NMBExpectation *NMB_expect(id(^actualBlock)(), NSString *file, NSUInteger line); + NMBExpectation *NMB_expect(id(^actualBlock)(void), NSString *file, NSUInteger line); // overloaded dispatch for nils - expect(nil) DEFINE_NMB_EXPECT_OVERLOAD(void*, nil) @@ -60,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN -NIMBLE_EXPORT NMBExpectation *NMB_expectAction(void(^actualBlock)(), NSString *file, NSUInteger line); +NIMBLE_EXPORT NMBExpectation *NMB_expectAction(void(^actualBlock)(void), NSString *file, NSUInteger line); diff --git a/Sources/NimbleObjectiveC/DSL.m b/Sources/NimbleObjectiveC/DSL.m index 31ff8100d..5a145b81f 100644 --- a/Sources/NimbleObjectiveC/DSL.m +++ b/Sources/NimbleObjectiveC/DSL.m @@ -4,8 +4,8 @@ SWIFT_CLASS("_TtC6Nimble7NMBWait") @interface NMBWait : NSObject -+ (void)untilTimeout:(NSTimeInterval)timeout file:(NSString *)file line:(NSUInteger)line action:(void(^)())action; -+ (void)untilFile:(NSString *)file line:(NSUInteger)line action:(void(^)())action; ++ (void)untilTimeout:(NSTimeInterval)timeout file:(NSString *)file line:(NSUInteger)line action:(void (^ _Nonnull)(void (^ _Nonnull)(void)))action; ++ (void)untilFile:(NSString *)file line:(NSUInteger)line action:(void (^ _Nonnull)(void (^ _Nonnull)(void)))action; @end @@ -13,14 +13,14 @@ + (void)untilFile:(NSString *)file line:(NSUInteger)line action:(void(^)())actio NS_ASSUME_NONNULL_BEGIN -NIMBLE_EXPORT NIMBLE_OVERLOADABLE NMBExpectation *__nonnull NMB_expect(id __nullable(^actualBlock)(), NSString *__nonnull file, NSUInteger line) { +NIMBLE_EXPORT NIMBLE_OVERLOADABLE NMBExpectation *__nonnull NMB_expect(id __nullable(^actualBlock)(void), NSString *__nonnull file, NSUInteger line) { return [[NMBExpectation alloc] initWithActualBlock:actualBlock negative:NO file:file line:line]; } -NIMBLE_EXPORT NMBExpectation *NMB_expectAction(void(^actualBlock)(), NSString *file, NSUInteger line) { +NIMBLE_EXPORT NMBExpectation *NMB_expectAction(void(^actualBlock)(void), NSString *file, NSUInteger line) { return NMB_expect(^id{ actualBlock(); return nil; @@ -146,13 +146,13 @@ NIMBLE_EXPORT void NMB_failWithMessage(NSString *msg, NSString *file, NSUInteger } NIMBLE_EXPORT NMBWaitUntilTimeoutBlock NMB_waitUntilTimeoutBuilder(NSString *file, NSUInteger line) { - return ^(NSTimeInterval timeout, void (^action)(void (^)(void))) { + return ^(NSTimeInterval timeout, void (^ _Nonnull action)(void (^ _Nonnull)(void))) { [NMBWait untilTimeout:timeout file:file line:line action:action]; }; } NIMBLE_EXPORT NMBWaitUntilBlock NMB_waitUntilBuilder(NSString *file, NSUInteger line) { - return ^(void (^action)(void (^)(void))) { + return ^(void (^ _Nonnull action)(void (^ _Nonnull)(void))) { [NMBWait untilFile:file line:line action:action]; }; } diff --git a/Sources/NimbleObjectiveC/NMBExceptionCapture.h b/Sources/NimbleObjectiveC/NMBExceptionCapture.h index d2a54d2f3..e6e0272a3 100644 --- a/Sources/NimbleObjectiveC/NMBExceptionCapture.h +++ b/Sources/NimbleObjectiveC/NMBExceptionCapture.h @@ -3,8 +3,8 @@ @interface NMBExceptionCapture : NSObject -- (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)())finally; -- (void)tryBlock:(__attribute__((noescape)) void(^ _Nonnull)())unsafeBlock NS_SWIFT_NAME(tryBlock(_:)); +- (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)(void))finally; +- (void)tryBlock:(__attribute__((noescape)) void(^ _Nonnull)(void))unsafeBlock NS_SWIFT_NAME(tryBlock(_:)); @end diff --git a/Sources/NimbleObjectiveC/NMBExceptionCapture.m b/Sources/NimbleObjectiveC/NMBExceptionCapture.m index 0a882b7cf..338104705 100644 --- a/Sources/NimbleObjectiveC/NMBExceptionCapture.m +++ b/Sources/NimbleObjectiveC/NMBExceptionCapture.m @@ -2,12 +2,12 @@ @interface NMBExceptionCapture () @property (nonatomic, copy) void(^ _Nullable handler)(NSException * _Nullable); -@property (nonatomic, copy) void(^ _Nullable finally)(); +@property (nonatomic, copy) void(^ _Nullable finally)(void); @end @implementation NMBExceptionCapture -- (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)())finally { +- (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)(void))finally { self = [super init]; if (self) { self.handler = handler; @@ -16,7 +16,7 @@ - (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnul return self; } -- (void)tryBlock:(void(^ _Nonnull)())unsafeBlock { +- (void)tryBlock:(void(^ _Nonnull)(void))unsafeBlock { @try { unsafeBlock(); }