AsyncMonitor/Tests/AsyncMonitorTests/AsyncCancellableTests.swift
Sami Samhuri bb8d04b54f
Document everything (#2)
* Document everything

* Make sure ReadmeExamples are up to date
2025-06-13 11:37:02 -07:00

19 lines
554 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)
}
}