diff --git a/Sources/Nimble/Polling+Require.swift b/Sources/Nimble/Polling+Require.swift index e43246d91..83e42d004 100644 --- a/Sources/Nimble/Polling+Require.swift +++ b/Sources/Nimble/Polling+Require.swift @@ -706,42 +706,56 @@ extension AsyncRequirement { /// Makes sure that the expression evaluates to a non-nil value, otherwise throw an error. /// As you can tell, this is a much less verbose equivalent to `require(expression).toEventuallyNot(beNil())` @discardableResult -public func unwrapEventually(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure @escaping () throws -> T?) throws -> T { +public func pollUnwrap(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure @escaping () throws -> T?) throws -> T { try require(file: file, line: line, expression()).toEventuallyNot(beNil()) } /// Makes sure that the expression evaluates to a non-nil value, otherwise throw an error. /// As you can tell, this is a much less verbose equivalent to `require(expression).toEventuallyNot(beNil())` @discardableResult -public func unwrapEventually(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure () -> (() throws -> T?)) throws -> T { +public func pollUnwrap(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure () -> (() throws -> T?)) throws -> T { + try require(file: file, line: line, expression()).toEventuallyNot(beNil()) +} + +/// Makes sure that the expression evaluates to a non-nil value, otherwise throw an error. +/// As you can tell, this is a much less verbose equivalent to `require(expression).toEventuallyNot(beNil())` +@discardableResult +public func pollUnwraps(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure @escaping () throws -> T?) throws -> T { + try require(file: file, line: line, expression()).toEventuallyNot(beNil()) +} + +/// Makes sure that the expression evaluates to a non-nil value, otherwise throw an error. +/// As you can tell, this is a much less verbose equivalent to `require(expression).toEventuallyNot(beNil())` +@discardableResult +public func pollUnwraps(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure () -> (() throws -> T?)) throws -> T { try require(file: file, line: line, expression()).toEventuallyNot(beNil()) } /// Makes sure that the async expression evaluates to a non-nil value, otherwise throw an error. /// As you can tell, this is a much less verbose equivalent to `requirea(expression).toEventuallyNot(beNil())` @discardableResult -public func unwrapEventually(file: FileString = #file, line: UInt = #line, _ expression: @escaping () async throws -> T?) async throws -> T { +public func pollUnwrap(file: FileString = #file, line: UInt = #line, _ expression: @escaping () async throws -> T?) async throws -> T { try await requirea(file: file, line: line, try await expression()).toEventuallyNot(beNil()) } /// Makes sure that the async expression evaluates to a non-nil value, otherwise throw an error. /// As you can tell, this is a much less verbose equivalent to `requirea(expression).toEventuallyNot(beNil())` @discardableResult -public func unwrapEventually(file: FileString = #file, line: UInt = #line, _ expression: () -> (() async throws -> T?)) async throws -> T { +public func pollUnwrap(file: FileString = #file, line: UInt = #line, _ expression: () -> (() async throws -> T?)) async throws -> T { try await requirea(file: file, line: line, expression()).toEventuallyNot(beNil()) } /// Makes sure that the async expression evaluates to a non-nil value, otherwise throw an error. /// As you can tell, this is a much less verbose equivalent to `requirea(expression).toEventuallyNot(beNil())` @discardableResult -public func unwrapEventuallyAsync(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure @escaping () async throws -> T?) async throws -> T { +public func pollUnwrapa(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure @escaping () async throws -> T?) async throws -> T { try await requirea(file: file, line: line, try await expression()).toEventuallyNot(beNil()) } /// Makes sure that the async expression evaluates to a non-nil value, otherwise throw an error. /// As you can tell, this is a much less verbose equivalent to `requirea(expression).toEventuallyNot(beNil())` @discardableResult -public func unwrapEventuallyAsync(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure () -> (() async throws -> T?)) async throws -> T { +public func pollUnwrapa(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure () -> (() async throws -> T?)) async throws -> T { try await requirea(file: file, line: line, expression()).toEventuallyNot(beNil()) } diff --git a/Sources/Nimble/Requirement.swift b/Sources/Nimble/Requirement.swift index d4d441d22..488ef3530 100644 --- a/Sources/Nimble/Requirement.swift +++ b/Sources/Nimble/Requirement.swift @@ -96,12 +96,14 @@ public struct SyncRequirement { } /// Tests the actual value using a matcher to match. + @discardableResult public func to(_ matcher: Matcher, description: String? = nil) throws -> Value { let (pass, msg, result) = executeRequire(expression, .toMatch, matcher, to: "to", description: description) return try verify(pass, msg, result) } /// Tests the actual value using a matcher to not match. + @discardableResult public func toNot(_ matcher: Matcher, description: String? = nil) throws -> Value { let (pass, msg, result) = executeRequire(expression, .toNotMatch, matcher, to: "to not", description: description) return try verify(pass, msg, result) @@ -110,18 +112,21 @@ public struct SyncRequirement { /// Tests the actual value using a matcher to not match. /// /// Alias to toNot(). + @discardableResult public func notTo(_ matcher: Matcher, description: String? = nil) throws -> Value { try toNot(matcher, description: description) } // MARK: - AsyncMatchers /// Tests the actual value using a matcher to match. + @discardableResult public func to(_ matcher: AsyncMatcher, description: String? = nil) async throws -> Value { let (pass, msg, result) = await executeRequire(expression.toAsyncExpression(), .toMatch, matcher, to: "to", description: description) return try verify(pass, msg, result) } /// Tests the actual value using a matcher to not match. + @discardableResult public func toNot(_ matcher: AsyncMatcher, description: String? = nil) async throws -> Value { let (pass, msg, result) = await executeRequire(expression.toAsyncExpression(), .toNotMatch, matcher, to: "to not", description: description) return try verify(pass, msg, result) @@ -130,6 +135,7 @@ public struct SyncRequirement { /// Tests the actual value using a matcher to not match. /// /// Alias to toNot(). + @discardableResult public func notTo(_ matcher: AsyncMatcher, description: String? = nil) async throws -> Value { try await toNot(matcher, description: description) } @@ -154,12 +160,14 @@ public struct AsyncRequirement { } /// Tests the actual value using a matcher to match. + @discardableResult public func to(_ matcher: Matcher, description: String? = nil) async throws -> Value { let (pass, msg, result) = executeRequire(await expression.toSynchronousExpression(), .toMatch, matcher, to: "to", description: description) return try verify(pass, msg, result) } /// Tests the actual value using a matcher to not match. + @discardableResult public func toNot(_ matcher: Matcher, description: String? = nil) async throws -> Value { let (pass, msg, result) = executeRequire(await expression.toSynchronousExpression(), .toNotMatch, matcher, to: "to not", description: description) return try verify(pass, msg, result) @@ -168,18 +176,21 @@ public struct AsyncRequirement { /// Tests the actual value using a matcher to not match. /// /// Alias to toNot(). + @discardableResult public func notTo(_ matcher: Matcher, description: String? = nil) async throws -> Value { try await toNot(matcher, description: description) } // MARK: - AsyncMatchers /// Tests the actual value using a matcher to match. + @discardableResult public func to(_ matcher: AsyncMatcher, description: String? = nil) async throws -> Value { let (pass, msg, result) = await executeRequire(expression, .toMatch, matcher, to: "to", description: description) return try verify(pass, msg, result) } /// Tests the actual value using a matcher to not match. + @discardableResult public func toNot(_ matcher: AsyncMatcher, description: String? = nil) async throws -> Value { let (pass, msg, result) = await executeRequire(expression, .toNotMatch, matcher, to: "to not", description: description) return try verify(pass, msg, result) @@ -188,6 +199,7 @@ public struct AsyncRequirement { /// Tests the actual value using a matcher to not match. /// /// Alias to toNot(). + @discardableResult public func notTo(_ matcher: AsyncMatcher, description: String? = nil) async throws -> Value { try await toNot(matcher, description: description) } diff --git a/Tests/NimbleTests/AsyncAwaitTest+Require.swift b/Tests/NimbleTests/AsyncAwaitTest+Require.swift index 6778d29cf..486a28234 100644 --- a/Tests/NimbleTests/AsyncAwaitTest+Require.swift +++ b/Tests/NimbleTests/AsyncAwaitTest+Require.swift @@ -13,7 +13,7 @@ final class AsyncAwaitRequireTest: XCTestCase { // swiftlint:disable:this type_b return 1 } - _ = try await require { try await someAsyncFunction() }.to(equal(1)) + try await require { try await someAsyncFunction() }.to(equal(1)) } class Error: Swift.Error {} @@ -26,25 +26,47 @@ final class AsyncAwaitRequireTest: XCTestCase { // swiftlint:disable:this type_b func testToEventuallyPositiveMatches() async throws { var value = 0 deferToMainQueue { value = 1 } - _ = try await require { value }.toEventually(equal(1)) + try await require { value }.toEventually(equal(1)) deferToMainQueue { value = 0 } - _ = try await require { value }.toEventuallyNot(equal(1)) + try await require { value }.toEventuallyNot(equal(1)) } func testToEventuallyNegativeMatches() async { let value = 0 await failsWithErrorMessage("expected to eventually not equal <0>, got <0>") { - _ = try await require { value }.toEventuallyNot(equal(0)) + try await require { value }.toEventuallyNot(equal(0)) } await failsWithErrorMessage("expected to eventually equal <1>, got <0>") { - _ = try await require { value }.toEventually(equal(1)) + try await require { value }.toEventually(equal(1)) } await failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try await require { try self.doThrowError() }.toEventually(equal(1)) + try await require { try self.doThrowError() }.toEventually(equal(1)) } await failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try await require { try self.doThrowError() }.toEventuallyNot(equal(0)) + try await require { try self.doThrowError() }.toEventuallyNot(equal(0)) + } + } + + func testPollUnwrapPositiveCase() async { + func someAsyncFunction() async throws -> Int { + try await Task.sleep(nanoseconds: 1_000_000) // 1 millisecond + return 1 + } + await expect { + try await pollUnwrapa(await someAsyncFunction()) + }.to(equal(1)) + } + + func testPollUnwrapNegativeCase() async { + await failsWithErrorMessage("expected to eventually not be nil, got nil") { + try await pollUnwrap { nil as Int? } + } + await failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { + try await pollUnwrap { try self.doThrowError() as Int? } + } + await failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { + try await pollUnwrap { try self.doThrowError() as Int? } } } @@ -60,11 +82,11 @@ final class AsyncAwaitRequireTest: XCTestCase { // swiftlint:disable:this type_b let subject = ExampleActor() - _ = try await require { await subject.value() }.toEventually(equal(2)) + try await require { await subject.value() }.toEventually(equal(2)) } func testToEventuallySyncCase() async throws { - _ = try await require(1).toEventually(equal(1), timeout: .seconds(300)) + try await require(1).toEventually(equal(1), timeout: .seconds(300)) } func testToEventuallyWaitingOnMainTask() async throws { @@ -79,13 +101,13 @@ final class AsyncAwaitRequireTest: XCTestCase { // swiftlint:disable:this type_b } EncapsulatedValue.execute() - _ = try await require(EncapsulatedValue.executed).toEventually(beTrue()) + try await require(EncapsulatedValue.executed).toEventually(beTrue()) } @MainActor func testToEventuallyOnMain() async throws { - _ = try await require(1).toEventually(equal(1), timeout: .seconds(300)) - _ = try await require { try? await Task.sleep(nanoseconds: 10_000); return 1 }.toEventually(equal(1)) + try await require(1).toEventually(equal(1), timeout: .seconds(300)) + try await require { try? await Task.sleep(nanoseconds: 10_000); return 1 }.toEventually(equal(1)) } @MainActor @@ -106,14 +128,14 @@ final class AsyncAwaitRequireTest: XCTestCase { // swiftlint:disable:this type_b } } - _ = try await require(MySubject()).toEventually(equal(MySubject())) + try await require(MySubject()).toEventually(equal(MySubject())) } func testToEventuallyWithSyncExpectationAlwaysExecutesExpressionOnMainActor() async throws { - _ = try await require(Thread.isMainThread).toEventually(beTrue()) - _ = try await require(Thread.isMainThread).toEventuallyNot(beFalse()) - _ = try await require(Thread.isMainThread).toAlways(beTrue(), until: .seconds(1)) - _ = try await require(Thread.isMainThread).toNever(beFalse(), until: .seconds(1)) + try await require(Thread.isMainThread).toEventually(beTrue()) + try await require(Thread.isMainThread).toEventuallyNot(beFalse()) + try await require(Thread.isMainThread).toAlways(beTrue(), until: .seconds(1)) + try await require(Thread.isMainThread).toNever(beFalse(), until: .seconds(1)) } func testToEventuallyWithAsyncExpectationDoesNotNecessarilyExecutesExpressionOnMainActor() async throws { @@ -121,10 +143,10 @@ final class AsyncAwaitRequireTest: XCTestCase { // swiftlint:disable:this type_b // However, the functionality actually works as you'd expect it to, you're just expected to tag things to use the main actor. func isMainThread() -> Bool { Thread.isMainThread } - _ = try await require(isMainThread()).toEventually(beFalse()) - _ = try await require(isMainThread()).toEventuallyNot(beTrue()) - _ = try await require(isMainThread()).toAlways(beFalse(), until: .seconds(1)) - _ = try await require(isMainThread()).toNever(beTrue(), until: .seconds(1)) + try await require(isMainThread()).toEventually(beFalse()) + try await require(isMainThread()).toEventuallyNot(beTrue()) + try await require(isMainThread()).toAlways(beFalse(), until: .seconds(1)) + try await require(isMainThread()).toNever(beTrue(), until: .seconds(1)) } @MainActor @@ -133,10 +155,10 @@ final class AsyncAwaitRequireTest: XCTestCase { // swiftlint:disable:this type_b // However, the functionality actually works as you'd expect it to, you're just expected to tag things to use the main actor. func isMainThread() -> Bool { Thread.isMainThread } - _ = try await require(isMainThread()).toEventually(beTrue()) - _ = try await require(isMainThread()).toEventuallyNot(beFalse()) - _ = try await require(isMainThread()).toAlways(beTrue(), until: .seconds(1)) - _ = try await require(isMainThread()).toNever(beFalse(), until: .seconds(1)) + try await require(isMainThread()).toEventually(beTrue()) + try await require(isMainThread()).toEventuallyNot(beFalse()) + try await require(isMainThread()).toAlways(beTrue(), until: .seconds(1)) + try await require(isMainThread()).toNever(beFalse(), until: .seconds(1)) } func testToEventuallyWithCustomDefaultTimeout() async throws { @@ -155,13 +177,13 @@ final class AsyncAwaitRequireTest: XCTestCase { // swiftlint:disable:this type_b let task = Task { sleepThenSetValueTo(1) } - _ = try await require { value }.toEventually(equal(1)) + try await require { value }.toEventually(equal(1)) let secondTask = Task { sleepThenSetValueTo(0) } - _ = try await require { value }.toEventuallyNot(equal(1)) + try await require { value }.toEventuallyNot(equal(1)) _ = await task.value _ = await secondTask.result @@ -177,8 +199,8 @@ final class AsyncAwaitRequireTest: XCTestCase { // swiftlint:disable:this type_b var subject: ClassUnderTest? = ClassUnderTest() if let sub = subject { - _ = try await require(sub.count).toEventually(equal(0), timeout: .milliseconds(100)) - _ = try await require(sub.count).toEventuallyNot(equal(1), timeout: .milliseconds(100)) + try await require(sub.count).toEventually(equal(0), timeout: .milliseconds(100)) + try await require(sub.count).toEventuallyNot(equal(1), timeout: .milliseconds(100)) } await waitUntil(timeout: .milliseconds(500)) { done in @@ -193,66 +215,66 @@ final class AsyncAwaitRequireTest: XCTestCase { // swiftlint:disable:this type_b func testToNeverPositiveMatches() async throws { var value = 0 deferToMainQueue { value = 1 } - _ = try await require { value }.toNever(beGreaterThan(1)) + try await require { value }.toNever(beGreaterThan(1)) deferToMainQueue { value = 0 } - _ = try await require { value }.neverTo(beGreaterThan(1)) + try await require { value }.neverTo(beGreaterThan(1)) } func testToNeverNegativeMatches() async { var value = 0 await failsWithErrorMessage("expected to never equal <0>, got <0>") { - _ = try await require { value }.toNever(equal(0)) + try await require { value }.toNever(equal(0)) } await failsWithErrorMessage("expected to never equal <0>, got <0>") { - _ = try await require { value }.neverTo(equal(0)) + try await require { value }.neverTo(equal(0)) } await failsWithErrorMessage("expected to never equal <1>, got <1>") { deferToMainQueue { value = 1 } - _ = try await require { value }.toNever(equal(1)) + try await require { value }.toNever(equal(1)) } await failsWithErrorMessage("expected to never equal <1>, got <1>") { deferToMainQueue { value = 1 } - _ = try await require { value }.neverTo(equal(1)) + try await require { value }.neverTo(equal(1)) } await failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try await require { try self.doThrowError() }.toNever(equal(0)) + try await require { try self.doThrowError() }.toNever(equal(0)) } await failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try await require { try self.doThrowError() }.neverTo(equal(0)) + try await require { try self.doThrowError() }.neverTo(equal(0)) } } func testToAlwaysPositiveMatches() async throws { var value = 1 deferToMainQueue { value = 2 } - _ = try await require { value }.toAlways(beGreaterThan(0)) + try await require { value }.toAlways(beGreaterThan(0)) deferToMainQueue { value = 2 } - _ = try await require { value }.alwaysTo(beGreaterThan(1)) + try await require { value }.alwaysTo(beGreaterThan(1)) } func testToAlwaysNegativeMatches() async { var value = 1 await failsWithErrorMessage("expected to always equal <0>, got <1>") { - _ = try await require { value }.toAlways(equal(0)) + try await require { value }.toAlways(equal(0)) } await failsWithErrorMessage("expected to always equal <0>, got <1>") { - _ = try await require { value }.alwaysTo(equal(0)) + try await require { value }.alwaysTo(equal(0)) } await failsWithErrorMessage("expected to always equal <1>, got <0>") { deferToMainQueue { value = 0 } - _ = try await require { value }.toAlways(equal(1)) + try await require { value }.toAlways(equal(1)) } await failsWithErrorMessage("expected to always equal <1>, got <0>") { deferToMainQueue { value = 0 } - _ = try await require { value }.alwaysTo(equal(1)) + try await require { value }.alwaysTo(equal(1)) } await failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try await require { try self.doThrowError() }.toAlways(equal(0)) + try await require { try self.doThrowError() }.toAlways(equal(0)) } await failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try await require { try self.doThrowError() }.alwaysTo(equal(0)) + try await require { try self.doThrowError() }.alwaysTo(equal(0)) } } } diff --git a/Tests/NimbleTests/DSLTest.swift b/Tests/NimbleTests/DSLTest.swift index dce7cdf29..3f1bf962f 100644 --- a/Tests/NimbleTests/DSLTest.swift +++ b/Tests/NimbleTests/DSLTest.swift @@ -120,11 +120,11 @@ final class DSLTest: XCTestCase { } func testExpectCombinedSyncAndAsyncRequirements() async throws { - _ = try await require { await nonThrowingAsyncInt() }.to(equal(1)) - _ = try await requirea(await nonThrowingAsyncInt()).to(equal(1)) - _ = try require(1).to(equal(1)) + try await require { await nonThrowingAsyncInt() }.to(equal(1)) + try await requirea(await nonThrowingAsyncInt()).to(equal(1)) + try require(1).to(equal(1)) - _ = try require { nonThrowingInt() }.to(equal(1)) + try require { nonThrowingInt() }.to(equal(1)) } func testRequire() throws { @@ -133,7 +133,7 @@ final class DSLTest: XCTestCase { let records = gatherExpectations(silently: true) { do { - _ = try require(1).to(equal(2)) + try require(1).to(equal(2)) } catch { expect(error).to(matchError(RequirementError.self)) } diff --git a/Tests/NimbleTests/PollingTest+Require.swift b/Tests/NimbleTests/PollingTest+Require.swift index 632d9f106..b8cf5bcff 100644 --- a/Tests/NimbleTests/PollingTest+Require.swift +++ b/Tests/NimbleTests/PollingTest+Require.swift @@ -20,33 +20,59 @@ final class PollingRequireTest: XCTestCase { throw errorToThrow } - func testToEventuallyPositiveMatches() throws { + func testToEventuallyPositiveMatches() { var value = 0 deferToMainQueue { value = 1 } - _ = try require { value }.toEventually(equal(1)) + expect { + try require { value }.toEventually(equal(1)) + }.to(equal(1)) deferToMainQueue { value = 0 } - _ = try require { value }.toEventuallyNot(equal(1)) + expect { + try require { value }.toEventuallyNot(equal(1)) + }.to(equal(0)) } func testToEventuallyNegativeMatches() { let value = 0 failsWithErrorMessage("expected to eventually not equal <0>, got <0>") { - _ = try require { value }.toEventuallyNot(equal(0)) + try require { value }.toEventuallyNot(equal(0)) } failsWithErrorMessage("expected to eventually equal <1>, got <0>") { - _ = try require { value }.toEventually(equal(1)) + try require { value }.toEventually(equal(1)) } failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try require { try self.doThrowError() }.toEventually(equal(1)) + try require { try self.doThrowError() }.toEventually(equal(1)) } failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try require { try self.doThrowError() }.toEventuallyNot(equal(0)) + try require { try self.doThrowError() }.toEventuallyNot(equal(0)) + } + } + + func testPollUnwrapPositiveCase() { + var value: Int? = nil + deferToMainQueue { + value = 1 + } + expect { + try pollUnwrap(value) + }.to(equal(1)) + } + + func testPollUnwrapNegativeCase() { + failsWithErrorMessage("expected to eventually not be nil, got nil") { + try pollUnwrap(nil as Int?) + failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { + try pollUnwrap { try self.doThrowError() as Int? } + } + failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { + try pollUnwrap { try self.doThrowError() as Int? } + } } } func testToEventuallySyncCase() throws { - _ = try require(1).toEventually(equal(1), timeout: .seconds(300)) + try require(1).toEventually(equal(1), timeout: .seconds(300)) } func testToEventuallyWithCustomDefaultTimeout() throws { @@ -65,12 +91,12 @@ final class PollingRequireTest: XCTestCase { var asyncOperation: () -> Void = { sleepThenSetValueTo(1) } DispatchQueue.global().async(execute: asyncOperation) - _ = try require { value }.toEventually(equal(1)) + try require { value }.toEventually(equal(1)) asyncOperation = { sleepThenSetValueTo(0) } DispatchQueue.global().async(execute: asyncOperation) - _ = try require { value }.toEventuallyNot(equal(1)) + try require { value }.toEventuallyNot(equal(1)) } func testToEventuallyAllowsInBackgroundThread() { @@ -78,7 +104,7 @@ final class PollingRequireTest: XCTestCase { var executedAsyncBlock: Bool = false let asyncOperation: () -> Void = { do { - _ = try require { + try require { expect(1).toEventually(equal(1)) }.toNot(raiseException(named: "InvalidNimbleAPIUsage")) } catch { @@ -102,8 +128,8 @@ final class PollingRequireTest: XCTestCase { var subject: ClassUnderTest? = ClassUnderTest() if let sub = subject { - _ = try require(sub.count).toEventually(equal(0), timeout: .milliseconds(100)) - _ = try require(sub.count).toEventuallyNot(equal(1), timeout: .milliseconds(100)) + try require(sub.count).toEventually(equal(0), timeout: .milliseconds(100)) + try require(sub.count).toEventuallyNot(equal(1), timeout: .milliseconds(100)) } waitUntil(timeout: .milliseconds(500)) { done in @@ -118,66 +144,66 @@ final class PollingRequireTest: XCTestCase { func testToNeverPositiveMatches() throws { var value = 0 deferToMainQueue { value = 1 } - _ = try require { value }.toNever(beGreaterThan(1)) + try require { value }.toNever(beGreaterThan(1)) deferToMainQueue { value = 0 } - _ = try require { value }.neverTo(beGreaterThan(1)) + try require { value }.neverTo(beGreaterThan(1)) } func testToNeverNegativeMatches() { var value = 0 failsWithErrorMessage("expected to never equal <0>, got <0>") { - _ = try require { value }.toNever(equal(0)) + try require { value }.toNever(equal(0)) } failsWithErrorMessage("expected to never equal <0>, got <0>") { - _ = try require { value }.neverTo(equal(0)) + try require { value }.neverTo(equal(0)) } failsWithErrorMessage("expected to never equal <1>, got <1>") { deferToMainQueue { value = 1 } - _ = try require { value }.toNever(equal(1)) + try require { value }.toNever(equal(1)) } failsWithErrorMessage("expected to never equal <1>, got <1>") { deferToMainQueue { value = 1 } - _ = try require { value }.neverTo(equal(1)) + try require { value }.neverTo(equal(1)) } failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try require { try self.doThrowError() }.toNever(equal(0)) + try require { try self.doThrowError() }.toNever(equal(0)) } failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try require { try self.doThrowError() }.neverTo(equal(0)) + try require { try self.doThrowError() }.neverTo(equal(0)) } } func testToAlwaysPositiveMatches() throws { var value = 1 deferToMainQueue { value = 2 } - _ = try require { value }.toAlways(beGreaterThan(0)) + try require { value }.toAlways(beGreaterThan(0)) deferToMainQueue { value = 2 } - _ = try require { value }.alwaysTo(beGreaterThan(1)) + try require { value }.alwaysTo(beGreaterThan(1)) } func testToAlwaysNegativeMatches() { var value = 1 failsWithErrorMessage("expected to always equal <0>, got <1>") { - _ = try require { value }.toAlways(equal(0)) + try require { value }.toAlways(equal(0)) } failsWithErrorMessage("expected to always equal <0>, got <1>") { - _ = try require { value }.alwaysTo(equal(0)) + try require { value }.alwaysTo(equal(0)) } failsWithErrorMessage("expected to always equal <1>, got <0>") { deferToMainQueue { value = 0 } - _ = try require { value }.toAlways(equal(1)) + try require { value }.toAlways(equal(1)) } failsWithErrorMessage("expected to always equal <1>, got <0>") { deferToMainQueue { value = 0 } - _ = try require { value }.alwaysTo(equal(1)) + try require { value }.alwaysTo(equal(1)) } failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try require { try self.doThrowError() }.toAlways(equal(0)) + try require { try self.doThrowError() }.toAlways(equal(0)) } failsWithErrorMessage("unexpected error thrown: <\(errorToThrow)>") { - _ = try require { try self.doThrowError() }.alwaysTo(equal(0)) + try require { try self.doThrowError() }.alwaysTo(equal(0)) } } }