Skip to content

Commit

Permalink
Add test case to verfy the fix of OpenCombine#241
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Nov 15, 2023
1 parent 3ae479a commit 6f9c615
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Tests/OpenCombineTests/PublisherTests/ZipTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -740,4 +740,35 @@ final class ZipTests: XCTestCase {
XCTFail("Failed to match the completion event in \(#function)")
}
}

// FIXME: swift-testing macro for specifying the relationship between a bug and a test case
// Uncomment the following line when we migrate to swift-testing
// @Test("Zip reference issue", .bug("#241", relationship: .verifiesFix))
func testZipReferenceIssue() throws {
var subscriptions: Set<AnyCancellable> = []
#if OPENCOMBINE_COMPATIBILITY_TEST
let scheduler = DispatchQueue.main
#else
let scheduler = DispatchQueue.OCombine(DispatchQueue.main)
#endif

let expectation = self.expectation(description: #function)
var result: (Int, Int)?

let firstPublisher = Just(1)
.delay(for: .milliseconds(600), scheduler: scheduler)
let secondPublisher = Just(2)
.delay(for: .milliseconds(600), scheduler: scheduler)
Publishers.Zip(firstPublisher, secondPublisher)
.sink(receiveValue: {
result = ($0.0, $0.1)
expectation.fulfill()
})
.store(in: &subscriptions)

wait(for: [expectation], timeout: 5)

XCTAssertEqual(result?.0, 1)
XCTAssertEqual(result?.1, 2)
}
}

0 comments on commit 6f9c615

Please sign in to comment.