mirror of
https://github.com/samsonjs/AsyncMonitor.git
synced 2026-03-25 08:25:47 +00:00
17 lines
550 B
Swift
17 lines
550 B
Swift
@testable import AsyncMonitor
|
|
import Testing
|
|
|
|
@MainActor class AsyncCancellableTests {
|
|
var cancellables = Set<AnyAsyncCancellable>()
|
|
|
|
@Test func storeInsertsIntoSetAndKeepsSubjectAlive() throws {
|
|
var subject: TestCancellable? = TestCancellable()
|
|
weak var weakSubject: TestCancellable? = subject
|
|
try #require(subject).store(in: &cancellables)
|
|
#expect(cancellables.count == 1)
|
|
subject = nil
|
|
#expect(weakSubject != nil)
|
|
cancellables.removeAll()
|
|
#expect(weakSubject == nil)
|
|
}
|
|
}
|