diff --git a/.github/workflows/ci-swiftpm.yml b/.github/workflows/ci-swiftpm.yml index fccee70..2ff7d0c 100644 --- a/.github/workflows/ci-swiftpm.yml +++ b/.github/workflows/ci-swiftpm.yml @@ -37,6 +37,8 @@ jobs: if: ${{ needs.filter.outputs.should_skip != 'true' }} - run: swift test if: ${{ needs.filter.outputs.should_skip != 'true' }} + - run: swift test --traits Include_Nimble + if: ${{ needs.filter.outputs.should_skip != 'true' }} swiftpm_darwin_15: name: SwiftPM, Darwin 15, Xcode ${{ matrix.xcode }} @@ -55,6 +57,8 @@ jobs: if: ${{ needs.filter.outputs.should_skip != 'true' }} - run: swift test if: ${{ needs.filter.outputs.should_skip != 'true' }} + - run: swift test --traits Include_Nimble + if: ${{ needs.filter.outputs.should_skip != 'true' }} swiftpm_linux: name: SwiftPM, Linux @@ -75,6 +79,8 @@ jobs: if: ${{ needs.filter.outputs.should_skip != 'true' }} - run: swift test if: ${{ needs.filter.outputs.should_skip != 'true' }} + - run: swift test --traits Include_Nimble + if: ${{ needs.filter.outputs.should_skip != 'true' }} swiftpm_android: name: SwiftPM, Android diff --git a/Package.resolved b/Package.resolved index dc2e4a7..4f525ad 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "5bc9c42a661634bd36bc39a230eb3807665c4762f9170c426c649f738d2edde6", + "originHash" : "5da7f878f5b1139f894b982a52fd7488eb9f2b260e6e914101cd9937e8b6941a", "pins" : [ { "identity" : "cwlcatchexception", @@ -33,8 +33,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-docc-plugin", "state" : { - "revision" : "3e4f133a77e644a5812911a0513aeb7288b07d06", - "version" : "1.4.5" + "revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64", + "version" : "1.4.3" } }, { diff --git a/Package.swift b/Package.swift index cb64c13..0562b81 100644 --- a/Package.swift +++ b/Package.swift @@ -1,11 +1,14 @@ -// swift-tools-version: 6.0 +// swift-tools-version: 6.1 import PackageDescription let package = Package( name: "swift-fakes", platforms: [ - .macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .visionOS(.v1) + .macOS(.v10_15), + .iOS(.v13), + .tvOS(.v13), + .visionOS(.v1) ], products: [ .library( @@ -13,21 +16,48 @@ let package = Package( targets: ["Fakes"] ), ], + traits: [ + .init( + name: "Include_Nimble", + description: "Enable Nimble Integration", + enabledTraits: [] + ), + ], dependencies: [ - .package(url: "https://github.com/Quick/Nimble.git", from: "14.0.0"), + .package( + url: "https://github.com/Quick/Nimble.git", + from: "14.0.0" + ), .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), ], targets: [ .target( name: "Fakes", - dependencies: ["Nimble"], + dependencies: [ + .product( + name: "Nimble", + package: "Nimble", + condition: .when( + traits: ["Include_Nimble"] + ) + ) + ], resources: [ .copy("PrivacyInfo.xcprivacy") ] ), .testTarget( name: "FakesTests", - dependencies: ["Fakes", "Nimble"] + dependencies: [ + "Fakes", + .product( + name: "Nimble", + package: "Nimble", + condition: .when( + traits: ["Include_Nimble"] + ) + ) + ] ), ] ) diff --git a/Sources/Fakes/Spy/Spy+Nimble.swift b/Sources/Fakes/Spy/Spy+Nimble.swift index 56e6413..a37c273 100644 --- a/Sources/Fakes/Spy/Spy+Nimble.swift +++ b/Sources/Fakes/Spy/Spy+Nimble.swift @@ -1,3 +1,4 @@ +#if Include_Nimble import Nimble // MARK: - Verifying any calls to the Spy. @@ -303,3 +304,4 @@ private func _mostRecentlyBeCalled( ) } } +#endif diff --git a/Tests/FakesTests/DynamicResultTests.swift b/Tests/FakesTests/DynamicResultTests.swift index 1ac86c5..3475dab 100644 --- a/Tests/FakesTests/DynamicResultTests.swift +++ b/Tests/FakesTests/DynamicResultTests.swift @@ -1,74 +1,73 @@ import Fakes -import Nimble -import XCTest +import Testing -final class DynamicResultTests: XCTestCase { - func testSingleStaticValue() { +struct DynamicResultTests { + @Test func testSingleStaticValue() { let subject = DynamicResult(1) - expect(subject.call(1)).to(equal(1)) - expect(subject.call(1)).to(equal(1)) - expect(subject.call(1)).to(equal(1)) + #expect(subject.call(1) == 1) + #expect(subject.call(1) == 1) + #expect(subject.call(1) == 1) } - func testMultipleStaticValues() { + @Test func testMultipleStaticValues() { let subject = DynamicResult(1, 2, 3) - expect(subject.call()).to(equal(1)) - expect(subject.call()).to(equal(2)) - expect(subject.call()).to(equal(3)) + #expect(subject.call() == 1) + #expect(subject.call() == 2) + #expect(subject.call() == 3) // After the last call, we continue to return the last stub in the list - expect(subject.call()).to(equal(3)) - expect(subject.call()).to(equal(3)) + #expect(subject.call() == 3) + #expect(subject.call() == 3) } - func testClosure() { + @Test func testClosure() { let subject = DynamicResult({ $0 + 1 }) - expect(subject.call(1)).to(equal(2)) - expect(subject.call(2)).to(equal(3)) - expect(subject.call(3)).to(equal(4)) + #expect(subject.call(1) == 2) + #expect(subject.call(2) == 3) + #expect(subject.call(3) == 4) } - func testStubs() { + @Test func testStubs() { let subject = DynamicResult( .value(1), .closure({ $0 * 3}), .value(4) ) - expect(subject.call(1)).to(equal(1)) - expect(subject.call(2)).to(equal(6)) - expect(subject.call(3)).to(equal(4)) - expect(subject.call(3)).to(equal(4)) + #expect(subject.call(1) == 1) + #expect(subject.call(2) == 6) + #expect(subject.call(3) == 4) + #expect(subject.call(3) == 4) } // MARK: - Replacement Tests - func testReplacementStaticValue() { + @Test func testReplacementStaticValue() { let subject = DynamicResult(1) subject.replace(2, 3, 4, 6) - expect(subject.call()).to(equal(2)) - expect(subject.call()).to(equal(3)) - expect(subject.call()).to(equal(4)) - expect(subject.call()).to(equal(6)) + #expect(subject.call() == 2) + #expect(subject.call() == 3) + #expect(subject.call() == 4) + #expect(subject.call() == 6) // After the last call, we continue to return the last stub in the list - expect(subject.call()).to(equal(6)) + #expect(subject.call() == 6) } - func testReplacementClosure() { + @Test func testReplacementClosure() { let subject = DynamicResult(1) subject.replace({ $0 + 4}) - expect(subject.call(1)).to(equal(5)) - expect(subject.call(2)).to(equal(6)) - expect(subject.call(3)).to(equal(7)) + #expect(subject.call(1) == 5) + #expect(subject.call(2) == 6) + #expect(subject.call(3) == 7) } - func testReplacementStubs() { + @Test func testReplacementStubs() { let subject = DynamicResult(1) subject.replace( @@ -77,42 +76,42 @@ final class DynamicResultTests: XCTestCase { .value(4) ) - expect(subject.call(1)).to(equal(2)) - expect(subject.call(2)).to(equal(6)) - expect(subject.call(3)).to(equal(4)) - expect(subject.call(3)).to(equal(4)) + #expect(subject.call(1) == 2) + #expect(subject.call(2) == 6) + #expect(subject.call(3) == 4) + #expect(subject.call(3) == 4) } // MARK: - Appending Tests - func testAppendingStaticValue() { + @Test func testAppendingStaticValue() { let subject = DynamicResult(1, 2, 3) subject.append(4, 5, 6) - expect(subject.call()).to(equal(1)) - expect(subject.call()).to(equal(2)) - expect(subject.call()).to(equal(3)) - expect(subject.call()).to(equal(4)) - expect(subject.call()).to(equal(5)) - expect(subject.call()).to(equal(6)) + #expect(subject.call() == 1) + #expect(subject.call() == 2) + #expect(subject.call() == 3) + #expect(subject.call() == 4) + #expect(subject.call() == 5) + #expect(subject.call() == 6) // After the last call, we continue to return the last stub in the list - expect(subject.call()).to(equal(6)) + #expect(subject.call() == 6) } - func testAppendingClosure() { + @Test func testAppendingClosure() { let subject = DynamicResult(1, 2, 3) subject.append({ $0 + 10}) - expect(subject.call(1)).to(equal(1)) - expect(subject.call(2)).to(equal(2)) - expect(subject.call(3)).to(equal(3)) - expect(subject.call(4)).to(equal(14)) - expect(subject.call(5)).to(equal(15)) + #expect(subject.call(1) == 1) + #expect(subject.call(2) == 2) + #expect(subject.call(3) == 3) + #expect(subject.call(4) == 14) + #expect(subject.call(5) == 15) } - func testAppendingStubs() { + @Test func testAppendingStubs() { let subject = DynamicResult(1, 2, 3) subject.append( @@ -121,12 +120,12 @@ final class DynamicResultTests: XCTestCase { .value(6) ) - expect(subject.call(1)).to(equal(1)) - expect(subject.call(2)).to(equal(2)) - expect(subject.call(3)).to(equal(3)) - expect(subject.call(4)).to(equal(4)) - expect(subject.call(5)).to(equal(15)) - expect(subject.call(6)).to(equal(6)) - expect(subject.call(7)).to(equal(6)) + #expect(subject.call(1) == 1) + #expect(subject.call(2) == 2) + #expect(subject.call(3) == 3) + #expect(subject.call(4) == 4) + #expect(subject.call(5) == 15) + #expect(subject.call(6) == 6) + #expect(subject.call(7) == 6) } } diff --git a/Tests/FakesTests/PendableTests.swift b/Tests/FakesTests/PendableTests.swift index 3d02755..3e47307 100644 --- a/Tests/FakesTests/PendableTests.swift +++ b/Tests/FakesTests/PendableTests.swift @@ -1,9 +1,8 @@ import Fakes -import Nimble -import XCTest +import Testing -final class PendableTests: XCTestCase { - func testSingleCall() async throws { +struct PendableTests { + @Test func testSingleCall() async throws { let subject = Pendable.pending(fallback: 0) async let result = subject.call() @@ -13,10 +12,10 @@ final class PendableTests: XCTestCase { subject.resolve(with: 2) let value = await result - expect(value).to(equal(2)) + #expect(value == 2) } - func testMultipleCalls() async throws { + @Test func testMultipleCalls() async throws { let subject = Pendable.pending(fallback: 0) async let result = withTaskGroup(of: Int.self, returning: [Int].self) { taskGroup in @@ -36,17 +35,20 @@ final class PendableTests: XCTestCase { subject.resolve(with: 3) let value = await result - expect(value).to(equal(Array(repeating: 3, count: 100))) + #expect(value == Array(repeating: 3, count: 100)) } - func testAutoresolve() async { + @Test func testAutoresolve() async throws { let subject = Pendable.pending(fallback: 3) + let spy = Spy() - await waitUntil(timeout: .milliseconds(500)) { done in - Task { - _ = await subject.call(fallbackDelay: 0.1) - done() - } + Task { + let value = await subject.call(fallbackDelay: 0.1) + spy(value) } + + try await Task.sleep(for: .milliseconds(500)) + + #expect(spy.wasCalled(with: 3)) } } diff --git a/Tests/FakesTests/PropertySpyTests.swift b/Tests/FakesTests/PropertySpyTests.swift index 85a61a5..11e977f 100644 --- a/Tests/FakesTests/PropertySpyTests.swift +++ b/Tests/FakesTests/PropertySpyTests.swift @@ -1,9 +1,8 @@ import Fakes -import Nimble -import XCTest +import Testing -final class SettablePropertySpyTests: XCTestCase { - func testGettingPropertyWhenTypesMatch() { +struct SettablePropertySpyTests { + @Test func testGettingPropertyWhenTypesMatch() { struct AnObject { @SettablePropertySpy(1) var value: Int @@ -11,15 +10,15 @@ final class SettablePropertySpyTests: XCTestCase { let object = AnObject() - expect(object.value).to(equal(1)) + #expect(object.value == 1) // because we called it, we should expect for the getter spy to be called - expect(object.$value.getter).to(beCalled()) + #expect(object.$value.getter.wasCalled) // We never interacted with the setter, so it shouldn't have been called. - expect(object.$value.setter).toNot(beCalled()) + #expect(object.$value.setter.wasNotCalled) } - func testSettingPropertyWhenTypesMatch() { + @Test func testSettingPropertyWhenTypesMatch() { struct AnObject { @SettablePropertySpy(1) var value: Int @@ -28,17 +27,17 @@ final class SettablePropertySpyTests: XCTestCase { var object = AnObject() object.value = 3 - expect(object.$value.getter).toNot(beCalled()) - expect(object.$value.setter).to(beCalled(3)) + #expect(object.$value.getter.wasNotCalled) + #expect(object.$value.setter.wasCalled(with: 3)) // the returned value should now be updated with the new value - expect(object.value).to(equal(3)) + #expect(object.value == 3) // and because we called the getter, the getter spy should be called. - expect(object.$value.getter).to(beCalled()) + #expect(object.$value.getter.wasCalled) } - func testGettingPropertyProtocolInheritence() { + @Test func testGettingPropertyProtocolInheritence() { struct ImplementedProtocol: SomeProtocol { var value: Int = 1 } @@ -50,15 +49,15 @@ final class SettablePropertySpyTests: XCTestCase { let object = AnObject() - expect(object.value).to(beAKindOf(ImplementedProtocol.self)) + #expect(object.value is ImplementedProtocol) // because we called it, we should expect for the getter spy to be called - expect(object.$value.getter).to(beCalled()) + #expect(object.$value.getter.wasCalled) // We never interacted with the setter, so it shouldn't have been called. - expect(object.$value.setter).toNot(beCalled()) + #expect(object.$value.setter.wasNotCalled) } - func testSettingPropertyProtocolInheritence() { + @Test func testSettingPropertyProtocolInheritence() { struct ImplementedProtocol: SomeProtocol, Equatable { var value: Int = 1 } @@ -71,24 +70,17 @@ final class SettablePropertySpyTests: XCTestCase { var object = AnObject() object.value = ImplementedProtocol(value: 2) - expect(object.$value.getter).toNot(beCalled()) - expect(object.$value.setter).to(beCalled(satisfyAllOf( - beAKindOf(ImplementedProtocol.self), - map(\.value, equal(2)) - ))) + #expect(object.$value.getter.wasNotCalled) // the returned value should now be updated with the new value - expect(object.value).to(satisfyAllOf( - beAKindOf(ImplementedProtocol.self), - map(\.value, equal(2)) - )) + #expect((object.value as? ImplementedProtocol)?.value == 2) // and because we called the getter, the getter spy should be called. - expect(object.$value.getter).to(beCalled(times: 1)) + #expect(object.$value.getter.wasCalled(times: 1)) } } -final class PropertySpyTests: XCTestCase { - func testGettingPropertyWhenTypesMatch() { +struct PropertySpyTests { + @Test func testGettingPropertyWhenTypesMatch() { struct AnObject { @PropertySpy(1) var value: Int @@ -96,12 +88,12 @@ final class PropertySpyTests: XCTestCase { let object = AnObject() - expect(object.value).to(equal(1)) + #expect(object.value == 1) // because we called it, we should expect for the getter spy to be called - expect(object.$value).to(beCalled()) + #expect(object.$value.wasCalled) } - func testGettingPropertyProtocolInheritence() { + @Test func testGettingPropertyProtocolInheritence() { struct ImplementedProtocol: SomeProtocol { var value: Int = 1 } @@ -118,14 +110,12 @@ final class PropertySpyTests: XCTestCase { let object = ObjectUsingProtocol() - expect(object.value).to(beAnInstanceOf(ImplementedProtocol.self)) + #expect(object.value is ImplementedProtocol) // because we called it, we should expect for the getter spy to be called - expect(object.$value).to(beCalled()) - expect(object.$value).to(beAnInstanceOf(Spy.self)) + #expect(object.$value.wasCalled) - let otherObject = ObjectUsingDirectInstance() - - expect(otherObject.$value).to(beAnInstanceOf(Spy.self)) + // it can be initialized and expressed. + let _ = ObjectUsingDirectInstance() } } diff --git a/Tests/FakesTests/SpyTests+Nimble.swift b/Tests/FakesTests/SpyTests+Nimble.swift index b8d5865..e0f9623 100644 --- a/Tests/FakesTests/SpyTests+Nimble.swift +++ b/Tests/FakesTests/SpyTests+Nimble.swift @@ -1,9 +1,10 @@ +#if Include_Nimble import Nimble -import XCTest +import Testing import Fakes -final class SpyNimbleMatchersTest: XCTestCase { - func testBeCalledWithoutArguments() { +struct SpyNimbleMatchersTest { + @Test func testBeCalledWithoutArguments() { let spy = Spy() // beCalled should match if spy has been called any number of times. @@ -16,7 +17,7 @@ final class SpyNimbleMatchersTest: XCTestCase { expect(spy).to(beCalled()) } - func testBeCalledWithArguments() { + @Test func testBeCalledWithArguments() { let spy = Spy() expect(spy).toNot(beCalled()) @@ -30,7 +31,7 @@ final class SpyNimbleMatchersTest: XCTestCase { expect(spy).to(beCalled(3)) } - func testBeCalledWithMultipleArguments() { + @Test func testBeCalledWithMultipleArguments() { let spy = Spy() spy(3) @@ -44,7 +45,7 @@ final class SpyNimbleMatchersTest: XCTestCase { )) } - func testBeCalledWithTimes() { + @Test func testBeCalledWithTimes() { let spy = Spy() expect(spy).to(beCalled(times: 0)) @@ -62,7 +63,7 @@ final class SpyNimbleMatchersTest: XCTestCase { expect(spy).toNot(beCalled(times: 1)) } - func testBeCalledWithArgumentsAndTimes() { + @Test func testBeCalledWithArgumentsAndTimes() { let spy = Spy() spy(1) @@ -80,7 +81,7 @@ final class SpyNimbleMatchersTest: XCTestCase { expect(spy).to(beCalled(3, times: 2)) } - func testBeCalledWithMultipleArgumentsAndTimes() { + @Test func testBeCalledWithMultipleArgumentsAndTimes() { let spy = Spy() spy(1) @@ -93,7 +94,7 @@ final class SpyNimbleMatchersTest: XCTestCase { expect(spy).to(beCalled(equal(3), beLessThan(4), times: 2)) } - func testMostRecentlyBeCalled() { + @Test func testMostRecentlyBeCalled() { let spy = Spy() spy(1) @@ -110,7 +111,7 @@ final class SpyNimbleMatchersTest: XCTestCase { expect(spy).to(mostRecentlyBeCalled(2)) } - func testMostRecentlyBeCalledWithMultipleArguments() { + @Test func testMostRecentlyBeCalledWithMultipleArguments() { let spy = Spy() spy(1) @@ -134,3 +135,4 @@ final class SpyNimbleMatchersTest: XCTestCase { )) } } +#endif diff --git a/Tests/FakesTests/SpyTests.swift b/Tests/FakesTests/SpyTests.swift index 77f7b95..e88fdba 100644 --- a/Tests/FakesTests/SpyTests.swift +++ b/Tests/FakesTests/SpyTests.swift @@ -1,134 +1,130 @@ +#if Include_Nimble import Nimble -import XCTest +#endif +import Testing @testable import Fakes -final class SpyTests: XCTestCase { - func testVoid() { +struct SpyTests { + @Test func testVoid() { let subject = Spy() // it returns the returning argument as the result, without stubbing. - expect { + #expect(throws: Never.self) { subject(()) - }.to(beVoid()) + } // it records the call - expect(subject.calls).to(haveCount(1)) - expect(subject.calls.first).to(beVoid()) + #expect(subject.calls.count == 1) + #expect(subject.calls.first! == ()) // allows Void arguments to be called without passing in a void - expect { + #expect(throws: Never.self) { subject() - }.to(beVoid()) + } // it records the call. - expect(subject.calls).to(haveCount(2)) - expect(subject.calls.last).to(beVoid()) + #expect(subject.calls.count == 2) + #expect(subject.calls.last! == ()) } - func testStubbing() { + @Test func testStubbing() { let subject = Spy(123) - expect { - subject() - }.to(equal(123)) + #expect(subject() == 123) subject.stub(456) - expect { - subject() - }.to(equal(456)) + #expect(subject() == 456) } - func testMultipleStubs() { + @Test func testMultipleStubs() { let subject = Spy(1, 2, 3) - expect(subject()).to(equal(1)) - expect(subject()).to(equal(2)) - expect(subject()).to(equal(3)) - expect(subject()).to(equal(3)) + #expect(subject() == 1) + #expect(subject() == 2) + #expect(subject() == 3) + #expect(subject() == 3) } - func testClosureStubs() { + @Test func testClosureStubs() { let subject = Spy { $0 } - expect(subject(1)).to(equal(1)) - expect(subject(2)).to(equal(2)) - expect(subject(3)).to(equal(3)) - expect(subject(10)).to(equal(10)) + #expect(subject(1) == 1) + #expect(subject(2) == 2) + #expect(subject(3) == 3) + #expect(subject(10) == 10) } - func testReplacingStubs() { + @Test func testReplacingStubs() { let subject = Spy(5) subject.stub(1, 2, 3) - expect(subject()).to(equal(1)) - expect(subject()).to(equal(2)) - expect(subject()).to(equal(3)) - expect(subject()).to(equal(3)) + #expect(subject() == 1) + #expect(subject() == 2) + #expect(subject() == 3) + #expect(subject() == 3) } - func testReplacingClosures() { + @Test func testReplacingClosures() { let subject = Spy(5) subject.stub { $0 } - expect(subject(1)).to(equal(1)) - expect(subject(2)).to(equal(2)) - expect(subject(3)).to(equal(3)) - expect(subject(10)).to(equal(10)) + #expect(subject(1) == 1) + #expect(subject(2) == 2) + #expect(subject(3) == 3) + #expect(subject(10) == 10) } - func testResult() { + @Test func testResult() throws { let subject = Spy>(.failure(TestError.uhOh)) - expect { + #expect(throws: TestError.uhOh) { try subject() as Int - }.to(throwError(TestError.uhOh)) + } - expect { + #expect(throws: TestError.uhOh) { try subject(()) as Int - }.to(throwError(TestError.uhOh)) + } // stub(success:) subject.stub(success: 2) - expect { - try subject() - }.to(equal(2)) + #expect(try subject() == 2) // stub(failure:) subject.stub(failure: .ohNo) - expect { + #expect(throws: TestError.ohNo) { try subject() as Int - }.to(throwError(TestError.ohNo)) + } } - func testResultInitializers() { + @Test func testResultInitializers() throws { let subject = ThrowingSpy(failure: .ohNo) - expect { + #expect(throws: TestError.ohNo) { try subject() as Int - }.to(throwError(TestError.ohNo)) + } let subject2 = ThrowingSpy(success: 3) - expect { - try subject2() - }.to(equal(3)) + #expect(try subject2() == 3) } - func testResultTakesNonVoidArguments() { + @Test func testResultTakesNonVoidArguments() { let intSpy = Spy() intSpy(1) - expect(intSpy.calls).to(equal([1])) + #expect(intSpy.calls == [1]) intSpy(1) } - func testPendable() async { +#if Include_Nimble + // TODO: Reimplement this using polling confirmations once they're a thing. + @Test func testPendable() async { let subject = PendableSpy(pendingFallback: 1) await expect { @@ -141,16 +137,19 @@ final class SpyTests: XCTestCase { await subject(fallbackDelay: 0) }.toEventually(equal(4)) } +#endif - func testPendableTakesNonVoidArguments() async throws { + @Test func testPendableTakesNonVoidArguments() async throws { let subject = PendableSpy(finished: ()) await subject(3, fallbackDelay: 0) - expect(subject.calls).to(equal([3])) + #expect(subject.calls == [3]) } - func testThrowingPendable() async { +#if Include_Nimble + // TODO: Reimplement this using polling confirmations once they're a thing. + @Test func testThrowingPendable() async { let subject = ThrowingPendableSpy(pendingSuccess: 0) await expect { @@ -168,26 +167,29 @@ final class SpyTests: XCTestCase { try await subject(fallbackDelay: 0) }.toEventually(throwError(TestError.uhOh)) } +#endif - func testThrowingPendableTakesNonVoidArguments() async throws { + @Test func testThrowingPendableTakesNonVoidArguments() async throws { let subject = ThrowingPendableSpy(success: ()) try await subject(8, fallbackDelay: 0) - expect(subject.calls).to(equal([8])) + #expect(subject.calls == [8]) } - func testClearCalls() { + @Test func testClearCalls() { let subject = Spy() subject(1) subject(2) subject.clearCalls() - expect(subject.calls).to(beEmpty()) + #expect(subject.calls == []) } - func testDynamicPendable() async { +#if Include_Nimble + // TODO: Reimplement this using polling confirmations once they're a thing. + @Test func testDynamicPendable() async { let subject = Spy>() let managedTask = await ManagedTask.running { @@ -201,7 +203,7 @@ final class SpyTests: XCTestCase { await expect { await managedTask.isFinished }.toEventually(beTrue()) } - func testDynamicPendableDeinit() async { + @Test func testDynamicPendableDeinit() async { let subject = Spy>() let managedTask = await ManagedTask.running { @@ -215,6 +217,7 @@ final class SpyTests: XCTestCase { await expect { await managedTask.isFinished }.toEventually(beTrue()) } +#endif } actor ManagedTask {