From 796860290d1a32013a99ce3b3c6643440755a434 Mon Sep 17 00:00:00 2001 From: Xander Deng Date: Thu, 23 Jan 2020 15:29:42 +0800 Subject: [PATCH] refine TracingSubscriber --- Sources/CXTest/CompletionExtensions.swift | 11 +- Sources/CXTest/TracingSubscriber.swift | 114 ++++++++++++++---- Sources/CXTest/TracingSubscriberEvent.swift | 91 -------------- Sources/CXTestUtility/TestSubscriber.swift | 51 ++++++++ .../NotificationCenterSpec.swift | 4 +- Tests/CXFoundationTests/TimerSpec.swift | 8 +- .../CXInconsistentTests/Fixed/FixedSpec.swift | 4 +- .../SuspiciousBufferSpec.swift | 4 +- .../SuspiciousSwitchToLatestSpec.swift | 10 +- Tests/CombineXTests/AnySubscriberSpec.swift | 2 +- Tests/CombineXTests/ObserableObjectSpec.swift | 34 +++--- Tests/CombineXTests/PublishedSpec.swift | 6 +- .../Publishers/AutoconnectSpec.swift | 4 +- .../CombineXTests/Publishers/BufferSpec.swift | 4 +- .../Publishers/CollectByCountSpec.swift | 6 +- .../Publishers/CollectByTimeSpec.swift | 8 +- .../Publishers/CombineLatestSpec.swift | 8 +- .../Publishers/ConcatenateSpec.swift | 4 +- .../Publishers/DebounceSpec.swift | 8 +- .../Publishers/DropUntilOutputSpec.swift | 6 +- .../CombineXTests/Publishers/EmptySpec.swift | 4 +- .../Publishers/FlatMapSpec.swift | 12 +- .../CombineXTests/Publishers/FutureSpec.swift | 12 +- Tests/CombineXTests/Publishers/JustSpec.swift | 4 +- .../Publishers/MapErrorSpec.swift | 2 +- .../Publishers/MeasureIntervalSpec.swift | 6 +- .../CombineXTests/Publishers/MergeSpec.swift | 4 +- .../Publishers/MulticastSpec.swift | 6 +- .../Publishers/OptionalSpec.swift | 4 +- .../CombineXTests/Publishers/OutputSpec.swift | 6 +- .../Publishers/PrefixUntilOutputSpec.swift | 4 +- .../Publishers/ReceiveOnSpec.swift | 2 +- .../CombineXTests/Publishers/RecordSpec.swift | 2 +- .../Publishers/RemoveDuplicatesSpec.swift | 2 +- .../Publishers/ReplaceEmptySpec.swift | 4 +- .../Publishers/ReplaceErrorSpec.swift | 2 +- .../CombineXTests/Publishers/ResultSpec.swift | 4 +- .../CombineXTests/Publishers/RetrySpec.swift | 6 +- .../Publishers/SequenceSpec.swift | 6 +- .../Publishers/SwitchToLatestSpec.swift | 10 +- .../Publishers/ThrottleSpec.swift | 12 +- .../Publishers/TimeoutSpec.swift | 8 +- .../Publishers/TryAllSatisfySpec.swift | 6 +- .../Publishers/TryCatchSpec.swift | 6 +- .../Publishers/TryCompactMapSpec.swift | 6 +- .../Publishers/TryDropWhileSpec.swift | 6 +- .../Publishers/TryPrefixWhileSpec.swift | 8 +- .../Publishers/TryReduceSpec.swift | 4 +- .../Publishers/TryRemoveDuplicatesSpec.swift | 6 +- .../Publishers/TryScanSpec.swift | 4 +- Tests/CombineXTests/Publishers/ZipSpec.swift | 10 +- .../Subjects/CurrentValueSubjectSpec.swift | 32 ++--- .../Subjects/PassthroughSubjectSpec.swift | 26 ++-- 53 files changed, 329 insertions(+), 294 deletions(-) delete mode 100644 Sources/CXTest/TracingSubscriberEvent.swift diff --git a/Sources/CXTest/CompletionExtensions.swift b/Sources/CXTest/CompletionExtensions.swift index 138b7c24..6727c7e9 100644 --- a/Sources/CXTest/CompletionExtensions.swift +++ b/Sources/CXTest/CompletionExtensions.swift @@ -22,10 +22,19 @@ public extension Subscribers.Completion { var isFailure: Bool { switch self { + case .finished: + return false case .failure: return true + } + } + + var error: Failure? { + switch self { case .finished: - return false + return nil + case let .failure(e): + return e } } } diff --git a/Sources/CXTest/TracingSubscriber.swift b/Sources/CXTest/TracingSubscriber.swift index 3d20669a..07d35335 100644 --- a/Sources/CXTest/TracingSubscriber.swift +++ b/Sources/CXTest/TracingSubscriber.swift @@ -1,59 +1,73 @@ import CXShim import CXUtility -public class TracingSubscriber: Subscriber, CustomStringConvertible, CustomReflectable, CustomPlaygroundDisplayConvertible { +public class TracingSubscriber: Subscriber { - public typealias Event = TracingSubscriberEvent + public enum Event { + case subscription(CombineIdentifier) + case value(Input) + case completion(Subscribers.Completion) + } - private let receiveSubscriptionBody: ((Subscription) -> Void)? - private let receiveValueBody: ((Input) -> Subscribers.Demand)? - private let receiveCompletionBody: ((Subscribers.Completion) -> Void)? + private let _rcvSubscription: ((Subscription) -> Void)? + private let _rcvValue: ((Input) -> Subscribers.Demand)? + private let _rcvCompletion: ((Subscribers.Completion) -> Void)? + private let _onDeinit: (() -> Void)? - private let lock = Lock() + private let _lock = Lock() private var _subscription: Subscription? private var _events: [Event] = [] public var events: [Event] { - return self.lock.withLockGet(self._events) + return self._lock.withLockGet(self._events) } public var subscription: Subscription? { - return self.lock.withLockGet(self._subscription) + return self._lock.withLockGet(self._subscription) + } + + public init(receiveSubscription: ((Subscription) -> Void)? = nil, receiveValue: ((Input) -> Subscribers.Demand)? = nil, receiveCompletion: ((Subscribers.Completion) -> Void)? = nil, onDeinit: (() -> Void)? = nil) { + self._rcvSubscription = receiveSubscription + self._rcvValue = receiveValue + self._rcvCompletion = receiveCompletion + self._onDeinit = onDeinit } - public init(receiveSubscription: ((Subscription) -> Void)? = nil, receiveValue: ((Input) -> Subscribers.Demand)? = nil, receiveCompletion: ((Subscribers.Completion) -> Void)? = nil) { - self.receiveSubscriptionBody = receiveSubscription - self.receiveValueBody = receiveValue - self.receiveCompletionBody = receiveCompletion + deinit { + _onDeinit?() } public func receive(subscription: Subscription) { - self.lock.withLock { + self._lock.withLock { + self._events.append(.subscription(subscription.combineIdentifier)) self._subscription = subscription } - self.receiveSubscriptionBody?(subscription) + self._rcvSubscription?(subscription) } public func receive(_ value: Input) -> Subscribers.Demand { - self.lock.withLock { + self._lock.withLock { self._events.append(.value(value)) } - return self.receiveValueBody?(value) ?? .none + return self._rcvValue?(value) ?? .none } public func receive(completion: Subscribers.Completion) { - self.lock.withLock { + self._lock.withLock { self._events.append(.completion(completion)) self._subscription = nil } - self.receiveCompletionBody?(completion) + self._rcvCompletion?(completion) } - public func release() { - self.lock.withLock { + public func releaseSubscription() { + self._lock.withLock { self._subscription = nil } } +} + +extension TracingSubscriber: CustomStringConvertible, CustomReflectable, CustomPlaygroundDisplayConvertible { public var description: String { return "\(type(of: self))" @@ -65,12 +79,64 @@ public class TracingSubscriber: Subscriber, CustomStringC public var customMirror: Mirror { return Mirror(self, children: [ - "receiveSubscriptionBody": receiveSubscriptionBody as Any, - "receiveValueBody": receiveValueBody as Any, - "receiveCompletionBody": receiveCompletionBody as Any, - "lock": lock, + "_rcvSubscription": _rcvSubscription as Any, + "_rcvValue": _rcvValue as Any, + "_rcvCompletion": _rcvCompletion as Any, + "_lock": _lock, "_subscription": _subscription as Any, "_events": _events, ]) } } + +// MARK: - Event + +extension TracingSubscriber.Event: Equatable where Input: Equatable, Failure: Equatable {} + +extension TracingSubscriber.Event: Hashable where Input: Hashable, Failure: Hashable {} + +extension TracingSubscriber.Event: CustomStringConvertible { + + public var description: String { + switch self { + case let .subscription(s): + return "subscription \(s)" + case let .value(v): + return "value \(v)" + case let .completion(c): + return "completion \(c)" + } + } +} + +public extension TracingSubscriber.Event { + + var value: Input? { + switch self { + case .value(let v): + return v + case .subscription, .completion: + return nil + } + } + + var completion: Subscribers.Completion? { + switch self { + case let .completion(c): + return c + case .subscription, .value: + return nil + } + } + + func mapError(_ transform: (Failure) -> NewFailure) -> TracingSubscriber.Event { + switch self { + case let .subscription(s): + return .subscription(s) + case let .value(i): + return .value(i) + case let .completion(c): + return .completion(c.mapError(transform)) + } + } +} diff --git a/Sources/CXTest/TracingSubscriberEvent.swift b/Sources/CXTest/TracingSubscriberEvent.swift deleted file mode 100644 index 0e13853f..00000000 --- a/Sources/CXTest/TracingSubscriberEvent.swift +++ /dev/null @@ -1,91 +0,0 @@ -import CXShim - -public enum TracingSubscriberEvent { - case value(Input) - case completion(Subscribers.Completion) -} - -public extension TracingSubscriberEvent { - - func isFinished() -> Bool { - switch self { - case .value: return false - case .completion(let c): return c.isFinished - } - } - - var value: Input? { - switch self { - case .value(let v): return v - case .completion: return nil - } - } - - var error: Failure? { - guard case .completion(let c) = self, case .failure(let e) = c else { - return nil - } - return e - } - - func mapError(_ transform: (Failure) -> NewFailure) -> TracingSubscriberEvent { - switch self { - case .value(let i): return .value(i) - case .completion(let c): return .completion(c.mapError(transform)) - } - } -} - -public extension TracingSubscriberEvent where Input: Equatable { - - func isValue(_ value: Input) -> Bool { - switch self { - case .value(let v): return v == value - case .completion: return false - } - } -} - -extension TracingSubscriberEvent: Equatable where Input: Equatable, Failure: Equatable {} - -extension TracingSubscriberEvent: CustomStringConvertible { - - public var description: String { - switch self { - case .value(let v): - return "\(v)" - case .completion(let c): - return "\(c)" - } - } -} - -public protocol TestEventProtocol { - associatedtype Input - associatedtype Failure: Error - - var testEvent: TracingSubscriberEvent { - get set - } -} - -extension TracingSubscriberEvent: TestEventProtocol { - - public var testEvent: TracingSubscriberEvent { - get { - return self - } - set { - self = newValue - } - } -} - -extension Collection where Element: TestEventProtocol { - - public func mapError(_ transform: (Element.Failure) -> NewFailure) -> [TracingSubscriberEvent] { - return self.map { - $0.testEvent.mapError(transform) - } - } -} diff --git a/Sources/CXTestUtility/TestSubscriber.swift b/Sources/CXTestUtility/TestSubscriber.swift index a610e022..ce22969e 100644 --- a/Sources/CXTestUtility/TestSubscriber.swift +++ b/Sources/CXTestUtility/TestSubscriber.swift @@ -26,3 +26,54 @@ public extension Publisher { return sub } } + +public extension TracingSubscriber { + + var eventsWithoutSubscription: [Event] { + return self.events.filter { !$0.isSubscription } + } +} + +public extension TracingSubscriber.Event { + + var isSubscription: Bool { + switch self { + case .subscription: + return true + case .value, .completion: + return false + } + } +} + +public typealias TracingSubscriberEvent = TracingSubscriber.Event + +public protocol TestEventProtocol { + associatedtype Input + associatedtype Failure: Error + + var testEvent: TracingSubscriber.Event { + get set + } +} + +extension TracingSubscriber.Event: TestEventProtocol { + + public var testEvent: TracingSubscriber.Event { + get { + return self + } + set { + self = newValue + } + } +} + +extension Collection where Element: TestEventProtocol { + + public func mapError(_ transform: (Element.Failure) -> NewFailure) -> [TracingSubscriber.Event] { + return self.map { + $0.testEvent.mapError(transform) + } + } +} diff --git a/Tests/CXFoundationTests/NotificationCenterSpec.swift b/Tests/CXFoundationTests/NotificationCenterSpec.swift index 2f57b093..9c1e9104 100644 --- a/Tests/CXFoundationTests/NotificationCenterSpec.swift +++ b/Tests/CXFoundationTests/NotificationCenterSpec.swift @@ -23,7 +23,7 @@ class NotificationCenterSpec: QuickSpec { NotificationCenter.default.post(name: name, object: nil) NotificationCenter.default.post(name: name, object: nil) - expect(sub.events).toEventually(haveCount(3)) + expect(sub.eventsWithoutSubscription).toEventually(haveCount(3)) } // MARK: 1.2 should stop sending values after cancel @@ -39,7 +39,7 @@ class NotificationCenterSpec: QuickSpec { NotificationCenter.default.post(name: name, object: nil) NotificationCenter.default.post(name: name, object: nil) - expect(sub.events).toEventually(beEmpty()) + expect(sub.eventsWithoutSubscription).toEventually(beEmpty()) } } } diff --git a/Tests/CXFoundationTests/TimerSpec.swift b/Tests/CXFoundationTests/TimerSpec.swift index 71c42433..e3453fd7 100644 --- a/Tests/CXFoundationTests/TimerSpec.swift +++ b/Tests/CXFoundationTests/TimerSpec.swift @@ -21,7 +21,7 @@ class TimerSpec: QuickSpec { waitUntil(timeout: 3) { done in DispatchQueue.main.asyncAfter(deadline: .now() + 1) { done() - expect(sub.events).to(beEmpty()) + expect(sub.eventsWithoutSubscription).to(beEmpty()) } } } @@ -34,7 +34,7 @@ class TimerSpec: QuickSpec { let connection = pub.connect() - expect(sub.events).toEventually(haveCount(4)) + expect(sub.eventsWithoutSubscription).toEventually(haveCount(4)) _ = connection } @@ -51,8 +51,8 @@ class TimerSpec: QuickSpec { RunLoop.current.run(until: Date().addingTimeInterval(1)) - expect(sub1.events.count) == 3 - expect(sub2.events.count) == 3 + expect(sub1.eventsWithoutSubscription.count) == 3 + expect(sub2.eventsWithoutSubscription.count) == 3 connection.cancel() } diff --git a/Tests/CXInconsistentTests/Fixed/FixedSpec.swift b/Tests/CXInconsistentTests/Fixed/FixedSpec.swift index cd34bdff..a39f2f8d 100644 --- a/Tests/CXInconsistentTests/Fixed/FixedSpec.swift +++ b/Tests/CXInconsistentTests/Fixed/FixedSpec.swift @@ -20,8 +20,8 @@ class FixedSpec: QuickSpec { (0...10).forEach(pub.send) - expect(sub.events).to(beEmpty()) - expect(sub.events).toEventually(equal([.value(10)])) + expect(sub.eventsWithoutSubscription).to(beEmpty()) + expect(sub.eventsWithoutSubscription).toEventually(equal([.value(10)])) } } } diff --git a/Tests/CXInconsistentTests/SuspiciousBehaviour/SuspiciousBufferSpec.swift b/Tests/CXInconsistentTests/SuspiciousBehaviour/SuspiciousBufferSpec.swift index 45ff0146..ca13f0c9 100644 --- a/Tests/CXInconsistentTests/SuspiciousBehaviour/SuspiciousBufferSpec.swift +++ b/Tests/CXInconsistentTests/SuspiciousBehaviour/SuspiciousBufferSpec.swift @@ -23,9 +23,9 @@ class SuspiciousBufferSpec: QuickSpec { } // FIXME: Apple's combine doesn't receive error. - let valueEvents = Array(0..<5).map { TestSubscriberEvent.value($0) } + let valueEvents = Array(0..<5).map { TracingSubscriberEvent.value($0) } let expected = valueEvents + [.completion(.failure(.e1))] - expect(sub.events).toBranch( + expect(sub.eventsWithoutSubscription).toBranch( combine: equal(valueEvents), cx: equal(expected)) } diff --git a/Tests/CXInconsistentTests/SuspiciousBehaviour/SuspiciousSwitchToLatestSpec.swift b/Tests/CXInconsistentTests/SuspiciousBehaviour/SuspiciousSwitchToLatestSpec.swift index c3778855..739da065 100644 --- a/Tests/CXInconsistentTests/SuspiciousBehaviour/SuspiciousSwitchToLatestSpec.swift +++ b/Tests/CXInconsistentTests/SuspiciousBehaviour/SuspiciousSwitchToLatestSpec.swift @@ -53,17 +53,17 @@ class SuspiciousSwitchToLatestSpec: QuickSpec { subject.send(subject1) subject1.send(completion: .finished) - expect(sub.events) == [] + expect(sub.eventsWithoutSubscription) == [] subject.send(subject2) - expect(sub.events) == [] + expect(sub.eventsWithoutSubscription) == [] subject.send(completion: .finished) - expect(sub.events) == [] + expect(sub.eventsWithoutSubscription) == [] // FIXME: Combine won't get any event when the last child finish. subject2.send(completion: .finished) - expect(sub.events).toBranch( + expect(sub.eventsWithoutSubscription).toBranch( combine: beEmpty(), cx: equal([.completion(.finished)])) } @@ -93,7 +93,7 @@ class SuspiciousSwitchToLatestSpec: QuickSpec { (11...20).forEach(subject2.send) // FIXME: Combine will get only 10 values (demand 12). - expect(sub.events).toBranch( + expect(sub.eventsWithoutSubscription).toBranch( combine: haveCount(10), cx: haveCount(12)) } diff --git a/Tests/CombineXTests/AnySubscriberSpec.swift b/Tests/CombineXTests/AnySubscriberSpec.swift index e93e7ec5..155f111d 100644 --- a/Tests/CombineXTests/AnySubscriberSpec.swift +++ b/Tests/CombineXTests/AnySubscriberSpec.swift @@ -68,7 +68,7 @@ class AnySubscriberSpec: QuickSpec { pub.send(2) pub.send(completion: .failure(.e0)) - expect(sub.events) == [.value(1), .value(2), .completion(.failure(.e0))] + expect(sub.eventsWithoutSubscription) == [.value(1), .value(2), .completion(.failure(.e0))] } } } diff --git a/Tests/CombineXTests/ObserableObjectSpec.swift b/Tests/CombineXTests/ObserableObjectSpec.swift index 82f874e7..ef1d7aeb 100644 --- a/Tests/CombineXTests/ObserableObjectSpec.swift +++ b/Tests/CombineXTests/ObserableObjectSpec.swift @@ -24,22 +24,22 @@ class ObserableObjectSpec: QuickSpec { obj.x = 1 obj.y = "foo" - expect(sub.events.count) == 0 + expect(sub.eventsWithoutSubscription.count) == 0 obj.a = 1 - expect(sub.events.count) == 1 + expect(sub.eventsWithoutSubscription.count) == 1 obj.a = 2 - expect(sub.events.count) == 2 + expect(sub.eventsWithoutSubscription.count) == 2 obj.a += 1 - expect(sub.events.count) == 3 + expect(sub.eventsWithoutSubscription.count) == 3 obj.d.toggle() - expect(sub.events.count) == 4 + expect(sub.eventsWithoutSubscription.count) == 4 obj.e.append(1) - expect(sub.events.count) == 5 + expect(sub.eventsWithoutSubscription.count) == 5 } // MARK: 1.2 generic class should publish observed value's change @@ -47,13 +47,13 @@ class ObserableObjectSpec: QuickSpec { let obj = ObservableGeneric(0, 0.0) let sub = obj.objectWillChange.subscribeTestSubscriber() - expect(sub.events.count) == 0 + expect(sub.eventsWithoutSubscription.count) == 0 obj.a = 1 - expect(sub.events.count) == 1 + expect(sub.eventsWithoutSubscription.count) == 1 obj.b = 1.0 - expect(sub.events.count) == 2 + expect(sub.eventsWithoutSubscription.count) == 2 } // MARK: 1.3 derived class should publish non-observable base class's change @@ -61,19 +61,19 @@ class ObserableObjectSpec: QuickSpec { let obj = ObservableDerivedWithNonObservableBase() let sub = obj.objectWillChange.subscribeTestSubscriber() - expect(sub.events.count) == 0 + expect(sub.eventsWithoutSubscription.count) == 0 obj.a += 1 - expect(sub.events.count) == 1 + expect(sub.eventsWithoutSubscription.count) == 1 obj.b += 1 - expect(sub.events.count) == 2 + expect(sub.eventsWithoutSubscription.count) == 2 obj.c += 1 - expect(sub.events.count) == 3 + expect(sub.eventsWithoutSubscription.count) == 3 obj.d += 1 - expect(sub.events.count) == 4 + expect(sub.eventsWithoutSubscription.count) == 4 } // MARK: class derived from objc should publish observed value's change @@ -81,13 +81,13 @@ class ObserableObjectSpec: QuickSpec { let obj = ObservableDerivedObjc() let sub = obj.objectWillChange.subscribeTestSubscriber() - expect(sub.events.count) == 0 + expect(sub.eventsWithoutSubscription.count) == 0 obj.a += 1 - expect(sub.events.count) == 1 + expect(sub.eventsWithoutSubscription.count) == 1 obj.b += 1 - expect(sub.events.count) == 2 + expect(sub.eventsWithoutSubscription.count) == 2 } } diff --git a/Tests/CombineXTests/PublishedSpec.swift b/Tests/CombineXTests/PublishedSpec.swift index d0de8ec5..cea10889 100644 --- a/Tests/CombineXTests/PublishedSpec.swift +++ b/Tests/CombineXTests/PublishedSpec.swift @@ -25,12 +25,12 @@ class PublishedSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, Never.self, .unlimited) x.$name.subscribe(sub) - expect(sub.events) == [.value(0)] + expect(sub.eventsWithoutSubscription) == [.value(0)] x.name = 1 x.name = 2 - expect(sub.events) == [.value(0), .value(1), .value(2)] + expect(sub.eventsWithoutSubscription) == [.value(0), .value(1), .value(2)] } } @@ -56,7 +56,7 @@ class PublishedSpec: QuickSpec { x.name = $0 } - expect(sub.events.count) == 13 + expect(sub.eventsWithoutSubscription.count) == 13 } } } diff --git a/Tests/CombineXTests/Publishers/AutoconnectSpec.swift b/Tests/CombineXTests/Publishers/AutoconnectSpec.swift index e91405b4..121d8d50 100644 --- a/Tests/CombineXTests/Publishers/AutoconnectSpec.swift +++ b/Tests/CombineXTests/Publishers/AutoconnectSpec.swift @@ -30,7 +30,7 @@ class AutoconnectSpec: QuickSpec { subject.send(2) subject.send(3) - expect(sub.events) == [.value(1), .value(2), .value(3)] + expect(sub.eventsWithoutSubscription) == [.value(1), .value(2), .value(3)] subscription?.cancel() @@ -38,7 +38,7 @@ class AutoconnectSpec: QuickSpec { subject.send(5) subject.send(6) - expect(sub.events) == [.value(1), .value(2), .value(3)] + expect(sub.eventsWithoutSubscription) == [.value(1), .value(2), .value(3)] } } } diff --git a/Tests/CombineXTests/Publishers/BufferSpec.swift b/Tests/CombineXTests/Publishers/BufferSpec.swift index 83f05893..42271fd1 100644 --- a/Tests/CombineXTests/Publishers/BufferSpec.swift +++ b/Tests/CombineXTests/Publishers/BufferSpec.swift @@ -52,7 +52,7 @@ class BufferSpec: QuickSpec { sub.subscription?.request(.max(5)) let expected = (Array(0..<5) + Array(6..<11)).map { TracingSubscriberEvent.value($0) } - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.3 should drop newest @@ -69,7 +69,7 @@ class BufferSpec: QuickSpec { sub.subscription?.request(.max(5)) let expected = Array(0..<10).map { TracingSubscriberEvent.value($0) } - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } } diff --git a/Tests/CombineXTests/Publishers/CollectByCountSpec.swift b/Tests/CombineXTests/Publishers/CollectByCountSpec.swift index 1af8c8ed..96e5d4d7 100644 --- a/Tests/CombineXTests/Publishers/CollectByCountSpec.swift +++ b/Tests/CombineXTests/Publishers/CollectByCountSpec.swift @@ -25,7 +25,7 @@ class CollectByCountSpec: QuickSpec { } pub.send(completion: .failure(.e0)) - expect(sub.events) == [ + expect(sub.eventsWithoutSubscription) == [ .value([0, 1]), .value([2, 3]), .completion(.failure(.e0)) @@ -43,7 +43,7 @@ class CollectByCountSpec: QuickSpec { } pub.send(completion: .finished) - expect(sub.events) == [ + expect(sub.eventsWithoutSubscription) == [ .value([0, 1]), .value([2, 3]), .value([4]), @@ -68,7 +68,7 @@ class CollectByCountSpec: QuickSpec { } pub.send(completion: .finished) - expect(sub.events) == [.value([0, 1]), .value([2, 3]), .completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.value([0, 1]), .value([2, 3]), .completion(.finished)] } } } diff --git a/Tests/CombineXTests/Publishers/CollectByTimeSpec.swift b/Tests/CombineXTests/Publishers/CollectByTimeSpec.swift index 28844f9c..45e5732c 100644 --- a/Tests/CombineXTests/Publishers/CollectByTimeSpec.swift +++ b/Tests/CombineXTests/Publishers/CollectByTimeSpec.swift @@ -33,7 +33,7 @@ class CollectByTimeSpec: QuickSpec { subject.send(completion: .failure(.e0)) scheduler.advance(by: .zero) - expect(sub.events) == [.value([1, 2]), .completion(.failure(.e0))] + expect(sub.eventsWithoutSubscription) == [.value([1, 2]), .completion(.failure(.e0))] } // MARK: 1.2 should collect by time then send unsent values if upstream finishes @@ -55,7 +55,7 @@ class CollectByTimeSpec: QuickSpec { subject.send(completion: .finished) scheduler.advance(by: .zero) - expect(sub.events) == [ + expect(sub.eventsWithoutSubscription) == [ .value([1, 2]), .value([3, 4, 5]), .completion(.finished) @@ -84,7 +84,7 @@ class CollectByTimeSpec: QuickSpec { subject.send(completion: .finished) scheduler.advance(by: .zero) - expect(sub.events) == [ + expect(sub.eventsWithoutSubscription) == [ .value([1, 2]), .value([3]), .value([4, 5]), @@ -120,7 +120,7 @@ class CollectByTimeSpec: QuickSpec { subject.send($0) } - expect(sub.events.count) == 4 + expect(sub.eventsWithoutSubscription.count) == 4 } // MARK: 1.5 should always request 1 when strategy is by time diff --git a/Tests/CombineXTests/Publishers/CombineLatestSpec.swift b/Tests/CombineXTests/Publishers/CombineLatestSpec.swift index d4c34b4c..38c27b87 100644 --- a/Tests/CombineXTests/Publishers/CombineLatestSpec.swift +++ b/Tests/CombineXTests/Publishers/CombineLatestSpec.swift @@ -32,7 +32,7 @@ class CombineLatestSpec: QuickSpec { subject1.send("c") let expected = ["1a", "2a", "2b", "2c"].map { TracingSubscriberEvent.value($0) } - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.2 should combine latest of 3 @@ -60,7 +60,7 @@ class CombineLatestSpec: QuickSpec { subject2.send("D") let expected = ["2bA", "3bA", "3cA", "3dA", "3dB", "3dC", "3dD"].map { TracingSubscriberEvent.value($0) } - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.3 should finish when one sends an error @@ -79,7 +79,7 @@ class CombineLatestSpec: QuickSpec { let valueEvents = [6, 10, 14, 18, 22, 26, 30].map { TracingSubscriberEvent.value($0) } let expected = valueEvents + [.completion(.failure(.e0))] - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.4 should send as many as demands @@ -102,7 +102,7 @@ class CombineLatestSpec: QuickSpec { [subject0, subject1].randomElement()!.send("\($0)") } - expect(sub.events.count) == 12 + expect(sub.eventsWithoutSubscription.count) == 12 } } diff --git a/Tests/CombineXTests/Publishers/ConcatenateSpec.swift b/Tests/CombineXTests/Publishers/ConcatenateSpec.swift index f35fad7f..8e31261b 100644 --- a/Tests/CombineXTests/Publishers/ConcatenateSpec.swift +++ b/Tests/CombineXTests/Publishers/ConcatenateSpec.swift @@ -26,7 +26,7 @@ class ConcatenateSpec: QuickSpec { let valueEvents = (1...5).map { TracingSubscriberEvent.value($0) } let expected = valueEvents + [.completion(.finished)] - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.2 should send as many value as demand @@ -45,7 +45,7 @@ class ConcatenateSpec: QuickSpec { pub.subscribe(sub) let events = (0..<12).map { TracingSubscriberEvent.value($0) } - expect(sub.events) == events + expect(sub.eventsWithoutSubscription) == events } // MARK: 1.3 should subscribe suffix after the finish of prefix diff --git a/Tests/CombineXTests/Publishers/DebounceSpec.swift b/Tests/CombineXTests/Publishers/DebounceSpec.swift index 4f13b865..bd8592db 100644 --- a/Tests/CombineXTests/Publishers/DebounceSpec.swift +++ b/Tests/CombineXTests/Publishers/DebounceSpec.swift @@ -29,7 +29,7 @@ class DebounceSpec: QuickSpec { subject.send(4) scheduler.advance(by: .seconds(0.9)) - expect(sub.events) == [] + expect(sub.eventsWithoutSubscription) == [] subject.send(1) subject.send(2) @@ -44,7 +44,7 @@ class DebounceSpec: QuickSpec { subject.send(9) scheduler.advance(by: .seconds(1.8)) - expect(sub.events) == [.value(3), .value(6), .value(9)] + expect(sub.eventsWithoutSubscription) == [.value(3), .value(6), .value(9)] } // MARK: 1.2 should send last value repeatedly @@ -58,7 +58,7 @@ class DebounceSpec: QuickSpec { subject.send(1) scheduler.advance(by: .seconds(10)) - expect(sub.events) == [.value(1)] + expect(sub.eventsWithoutSubscription) == [.value(1)] } // MARK: 1.3 should send as many values as demand @@ -79,7 +79,7 @@ class DebounceSpec: QuickSpec { scheduler.advance(by: .seconds(1)) } - expect(sub.events.count).toEventually(equal(12)) + expect(sub.eventsWithoutSubscription.count).toEventually(equal(12)) } } diff --git a/Tests/CombineXTests/Publishers/DropUntilOutputSpec.swift b/Tests/CombineXTests/Publishers/DropUntilOutputSpec.swift index 81b6451b..80106e94 100644 --- a/Tests/CombineXTests/Publishers/DropUntilOutputSpec.swift +++ b/Tests/CombineXTests/Publishers/DropUntilOutputSpec.swift @@ -34,7 +34,7 @@ class DropUntilOutputSpec: QuickSpec { } let expected = (10..<20).map { TracingSubscriberEvent.value($0) } - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.2 should complete when other complete @@ -55,7 +55,7 @@ class DropUntilOutputSpec: QuickSpec { pub0.send($0) } - expect(sub.events) == [.completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.completion(.finished)] } // MARK: 1.3 should complete if self complete @@ -73,7 +73,7 @@ class DropUntilOutputSpec: QuickSpec { } pub0.send(completion: .finished) - expect(sub.events) == [.completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.completion(.finished)] } } } diff --git a/Tests/CombineXTests/Publishers/EmptySpec.swift b/Tests/CombineXTests/Publishers/EmptySpec.swift index d4f02686..f1a235e0 100644 --- a/Tests/CombineXTests/Publishers/EmptySpec.swift +++ b/Tests/CombineXTests/Publishers/EmptySpec.swift @@ -20,7 +20,7 @@ class EmptySpec: QuickSpec { let sub = makeTestSubscriber(Int.self, Never.self, .unlimited) empty.subscribe(sub) - expect(sub.events) == [.completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.completion(.finished)] } // MARK: 1.2 should send nothing @@ -28,7 +28,7 @@ class EmptySpec: QuickSpec { let empty = Empty(completeImmediately: false) let sub = makeTestSubscriber(Int.self, Never.self, .unlimited) empty.subscribe(sub) - expect(sub.events) == [] + expect(sub.eventsWithoutSubscription) == [] } } diff --git a/Tests/CombineXTests/Publishers/FlatMapSpec.swift b/Tests/CombineXTests/Publishers/FlatMapSpec.swift index 5f393d53..b6721362 100644 --- a/Tests/CombineXTests/Publishers/FlatMapSpec.swift +++ b/Tests/CombineXTests/Publishers/FlatMapSpec.swift @@ -35,7 +35,7 @@ class FlatMapSpec: QuickSpec { let events = [1, 2, 3].flatMap { [$0, $0, $0] }.map { TracingSubscriberEvent.value($0) } let expected = events + [.completion(.finished)] - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.2 should send values as demand @@ -59,7 +59,7 @@ class FlatMapSpec: QuickSpec { pub.subscribe(sub) - expect(sub.events.count) == 19 + expect(sub.eventsWithoutSubscription.count) == 19 } // MARK: 1.3 should complete when a sub-publisher sends an error @@ -96,12 +96,12 @@ class FlatMapSpec: QuickSpec { subjects[1].send(completion: .failure(.e1)) - expect(sub.events.count) == 10 + expect(sub.eventsWithoutSubscription.count) == 10 var events = [0, 1, 2].flatMap { _ in [0, 1, 2] }.map { Sub.Event.value($0) } events.append(Sub.Event.completion(.failure(.e1))) - expect(sub.events) == events + expect(sub.eventsWithoutSubscription) == events } // MARK: 1.4 should buffer one output for each sub-publisher if there is no demand @@ -138,7 +138,7 @@ class FlatMapSpec: QuickSpec { subscription?.request(.unlimited) - expect(sub.events) == [.value(0), .value(0), .value(2), .value(3)] + expect(sub.eventsWithoutSubscription) == [.value(0), .value(0), .value(2), .value(3)] } } @@ -177,7 +177,7 @@ class FlatMapSpec: QuickSpec { g.wait() - expect(sub.events.count) == 10 + expect(sub.eventsWithoutSubscription.count) == 10 } } } diff --git a/Tests/CombineXTests/Publishers/FutureSpec.swift b/Tests/CombineXTests/Publishers/FutureSpec.swift index 65ba4e6d..ddb2d0b3 100644 --- a/Tests/CombineXTests/Publishers/FutureSpec.swift +++ b/Tests/CombineXTests/Publishers/FutureSpec.swift @@ -26,8 +26,8 @@ class FutureSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, TestError.self, .unlimited) f.subscribe(sub) - expect(sub.events) == [] - expect(sub.events).toEventually(equal([.value(1), .completion(.finished)])) + expect(sub.eventsWithoutSubscription) == [] + expect(sub.eventsWithoutSubscription).toEventually(equal([.value(1), .completion(.finished)])) } // MARK: 1.2 should send failure when promise fail @@ -41,8 +41,8 @@ class FutureSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, TestError.self, .unlimited) f.subscribe(sub) - expect(sub.events) == [] - expect(sub.events).toEventually(equal([.completion(.failure(.e0))])) + expect(sub.eventsWithoutSubscription) == [] + expect(sub.eventsWithoutSubscription).toEventually(equal([.completion(.failure(.e0))])) } // MAKR: 1.3 should send events immediately if promise is completed @@ -53,7 +53,7 @@ class FutureSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, TestError.self, .unlimited) f.subscribe(sub) - expect(sub.events) == [.value(1), .completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.value(1), .completion(.finished)] } } @@ -80,7 +80,7 @@ class FutureSpec: QuickSpec { g.wait() for sub in subs { - expect(sub.events) == [.completion(.failure(.e0))] + expect(sub.eventsWithoutSubscription) == [.completion(.failure(.e0))] } } } diff --git a/Tests/CombineXTests/Publishers/JustSpec.swift b/Tests/CombineXTests/Publishers/JustSpec.swift index 2adefefd..03d07b20 100644 --- a/Tests/CombineXTests/Publishers/JustSpec.swift +++ b/Tests/CombineXTests/Publishers/JustSpec.swift @@ -22,7 +22,7 @@ class JustSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, Never.self, .unlimited) pub.subscribe(sub) - expect(sub.events) == [.value(1), .completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.value(1), .completion(.finished)] } #if !SWIFT_PACKAGE @@ -186,7 +186,7 @@ class JustSpec: QuickSpec { } g.wait() - expect(sub.events) == [.value(1), .completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.value(1), .completion(.finished)] } } } diff --git a/Tests/CombineXTests/Publishers/MapErrorSpec.swift b/Tests/CombineXTests/Publishers/MapErrorSpec.swift index 60c8622b..53bba9d2 100644 --- a/Tests/CombineXTests/Publishers/MapErrorSpec.swift +++ b/Tests/CombineXTests/Publishers/MapErrorSpec.swift @@ -28,7 +28,7 @@ class MapErrorSpec: QuickSpec { let valueEvents = (0..<100).map { TracingSubscriberEvent.value($0) } let expected = valueEvents + [.completion(.failure(.e2))] - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } #if !SWIFT_PACKAGE diff --git a/Tests/CombineXTests/Publishers/MeasureIntervalSpec.swift b/Tests/CombineXTests/Publishers/MeasureIntervalSpec.swift index 6bc52645..19d47d28 100644 --- a/Tests/CombineXTests/Publishers/MeasureIntervalSpec.swift +++ b/Tests/CombineXTests/Publishers/MeasureIntervalSpec.swift @@ -42,9 +42,9 @@ class MeasureIntervalSpec: QuickSpec { subject.send(completion: .finished) - expect(sub.events).to(haveCount(dts.count + 1)) - expect(sub.events.last) == .completion(.finished) - for (event, dt) in zip(sub.events.dropLast(), dts) { + expect(sub.eventsWithoutSubscription).to(haveCount(dts.count + 1)) + expect(sub.eventsWithoutSubscription.last) == .completion(.finished) + for (event, dt) in zip(sub.eventsWithoutSubscription.dropLast(), dts) { expect(event.value?.seconds).to(beCloseTo(dt, within: 0.1)) } } diff --git a/Tests/CombineXTests/Publishers/MergeSpec.swift b/Tests/CombineXTests/Publishers/MergeSpec.swift index 17559f27..4b3ad0a3 100644 --- a/Tests/CombineXTests/Publishers/MergeSpec.swift +++ b/Tests/CombineXTests/Publishers/MergeSpec.swift @@ -38,7 +38,7 @@ class MergeSpec: QuickSpec { let events = (0..<100).map { TracingSubscriberEvent.value($0) } - expect(sub.events) == events + expect(sub.eventsWithoutSubscription) == events } // MARK: It should merge many upstreams @@ -62,7 +62,7 @@ class MergeSpec: QuickSpec { let events = (0..<100).map { TracingSubscriberEvent.value($0) } - expect(sub.events) == events + expect(sub.eventsWithoutSubscription) == events } } } diff --git a/Tests/CombineXTests/Publishers/MulticastSpec.swift b/Tests/CombineXTests/Publishers/MulticastSpec.swift index bf5da194..cde2c4c9 100644 --- a/Tests/CombineXTests/Publishers/MulticastSpec.swift +++ b/Tests/CombineXTests/Publishers/MulticastSpec.swift @@ -24,14 +24,14 @@ class MulticastSpec: QuickSpec { 10.times { subject.send($0) } - expect(sub.events) == [] + expect(sub.eventsWithoutSubscription) == [] let cancel = pub.connect() 10.times { subject.send($0) } - expect(sub.events) == (0..<10).map { .value($0) } + expect(sub.eventsWithoutSubscription) == (0..<10).map { .value($0) } cancel.cancel() @@ -39,7 +39,7 @@ class MulticastSpec: QuickSpec { subject.send($0) } - expect(sub.events) == (0..<10).map { .value($0) } + expect(sub.eventsWithoutSubscription) == (0..<10).map { .value($0) } } } } diff --git a/Tests/CombineXTests/Publishers/OptionalSpec.swift b/Tests/CombineXTests/Publishers/OptionalSpec.swift index 8b90abc2..27f6f5c5 100644 --- a/Tests/CombineXTests/Publishers/OptionalSpec.swift +++ b/Tests/CombineXTests/Publishers/OptionalSpec.swift @@ -23,7 +23,7 @@ class OptionalSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, Never.self, .unlimited) pub.subscribe(sub) - expect(sub.events) == [.value(1), .completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.value(1), .completion(.finished)] } // MARK: 1.2 should send finished even no demand @@ -33,7 +33,7 @@ class OptionalSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, Never.self, .max(0)) pub.subscribe(sub) - expect(sub.events) == [.completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.completion(.finished)] } #if !SWIFT_PACKAGE diff --git a/Tests/CombineXTests/Publishers/OutputSpec.swift b/Tests/CombineXTests/Publishers/OutputSpec.swift index 2cdcd012..c2dfd322 100644 --- a/Tests/CombineXTests/Publishers/OutputSpec.swift +++ b/Tests/CombineXTests/Publishers/OutputSpec.swift @@ -26,7 +26,7 @@ class OutputSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, Error.self, .unlimited) pub.output(in: 0..<2).subscribe(sub) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } // FIXME: Even if the upstream doesn't send subscription, the downstream still can receive values. 🤔. expect(got) == [.value(0), .value(1)] @@ -53,7 +53,7 @@ class OutputSpec: QuickSpec { TracingSubscriberEvent.value($0) } let expected = valueEvents + [.completion(.finished)] - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.2 should send values as demand @@ -76,7 +76,7 @@ class OutputSpec: QuickSpec { let expected = (10..<17).map { TracingSubscriberEvent.value($0) } - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } #if !SWIFT_PACKAGE diff --git a/Tests/CombineXTests/Publishers/PrefixUntilOutputSpec.swift b/Tests/CombineXTests/Publishers/PrefixUntilOutputSpec.swift index 7f64c0b0..2392bcf8 100644 --- a/Tests/CombineXTests/Publishers/PrefixUntilOutputSpec.swift +++ b/Tests/CombineXTests/Publishers/PrefixUntilOutputSpec.swift @@ -35,7 +35,7 @@ class PrefixUntilOutputSpec: QuickSpec { let valueEvents = (0..<10).map { TracingSubscriberEvent.value($0) } let expected = valueEvents + [.completion(.finished)] - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.2 should complete when other complete @@ -59,7 +59,7 @@ class PrefixUntilOutputSpec: QuickSpec { let expected = (0..<20).map { TracingSubscriberEvent.value($0) } - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } } } diff --git a/Tests/CombineXTests/Publishers/ReceiveOnSpec.swift b/Tests/CombineXTests/Publishers/ReceiveOnSpec.swift index 863a25f9..32ce4b08 100644 --- a/Tests/CombineXTests/Publishers/ReceiveOnSpec.swift +++ b/Tests/CombineXTests/Publishers/ReceiveOnSpec.swift @@ -82,7 +82,7 @@ class ReceiveOnSpec: QuickSpec { subject.send($0) } - expect(sub.events.count).toEventually(equal(10)) + expect(sub.eventsWithoutSubscription.count).toEventually(equal(10)) } } } diff --git a/Tests/CombineXTests/Publishers/RecordSpec.swift b/Tests/CombineXTests/Publishers/RecordSpec.swift index e7c73766..63d96182 100644 --- a/Tests/CombineXTests/Publishers/RecordSpec.swift +++ b/Tests/CombineXTests/Publishers/RecordSpec.swift @@ -71,7 +71,7 @@ class RecordSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, TestError.self, .unlimited) record.subscribe(sub) - expect(sub.events) == [.value(1), .value(2), .completion(.failure(.e2))] + expect(sub.eventsWithoutSubscription) == [.value(1), .value(2), .completion(.failure(.e2))] } } } diff --git a/Tests/CombineXTests/Publishers/RemoveDuplicatesSpec.swift b/Tests/CombineXTests/Publishers/RemoveDuplicatesSpec.swift index e8b1881b..138a4b25 100644 --- a/Tests/CombineXTests/Publishers/RemoveDuplicatesSpec.swift +++ b/Tests/CombineXTests/Publishers/RemoveDuplicatesSpec.swift @@ -34,7 +34,7 @@ class RemoveDuplicatesSpec: QuickSpec { let events = [1, 2, 1].map { TracingSubscriber.Event.value($0) } let expected = events + [.completion(.finished)] - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } } } diff --git a/Tests/CombineXTests/Publishers/ReplaceEmptySpec.swift b/Tests/CombineXTests/Publishers/ReplaceEmptySpec.swift index 25e23cef..7e2c7b54 100644 --- a/Tests/CombineXTests/Publishers/ReplaceEmptySpec.swift +++ b/Tests/CombineXTests/Publishers/ReplaceEmptySpec.swift @@ -20,7 +20,7 @@ class ReplaceEmptySpec: QuickSpec { let sub = makeTestSubscriber(Int.self, Never.self, .unlimited) pub.subscribe(sub) - expect(sub.events) == [.value(1), .completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.value(1), .completion(.finished)] } // MARK: 1.2 should not send default value if not empty @@ -29,7 +29,7 @@ class ReplaceEmptySpec: QuickSpec { let sub = makeTestSubscriber(Int.self, Never.self, .unlimited) pub.subscribe(sub) - expect(sub.events) == [.value(0), .completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.value(0), .completion(.finished)] } #if !SWIFT_PACKAGE diff --git a/Tests/CombineXTests/Publishers/ReplaceErrorSpec.swift b/Tests/CombineXTests/Publishers/ReplaceErrorSpec.swift index 98e63ddf..d96e62be 100644 --- a/Tests/CombineXTests/Publishers/ReplaceErrorSpec.swift +++ b/Tests/CombineXTests/Publishers/ReplaceErrorSpec.swift @@ -19,7 +19,7 @@ class ReplaceErrorSpec: QuickSpec { let pub = Fail(error: .e0).replaceError(with: 1) let sub = makeTestSubscriber(Int.self, Never.self, .unlimited) pub.subscribe(sub) - expect(sub.events) == [.value(1), .completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.value(1), .completion(.finished)] } #if !SWIFT_PACKAGE diff --git a/Tests/CombineXTests/Publishers/ResultSpec.swift b/Tests/CombineXTests/Publishers/ResultSpec.swift index 2d3ae1cd..142239ea 100644 --- a/Tests/CombineXTests/Publishers/ResultSpec.swift +++ b/Tests/CombineXTests/Publishers/ResultSpec.swift @@ -24,7 +24,7 @@ class ResultSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, TestError.self, .unlimited) pub.subscribe(sub) - expect(sub.events) == [.value(1), .completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.value(1), .completion(.finished)] } // MARK: 1.2 should send failure even no demand @@ -34,7 +34,7 @@ class ResultSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, TestError.self, .max(0)) pub.subscribe(sub) - expect(sub.events) == [.completion(.failure(.e0))] + expect(sub.eventsWithoutSubscription) == [.completion(.failure(.e0))] } #if !SWIFT_PACKAGE diff --git a/Tests/CombineXTests/Publishers/RetrySpec.swift b/Tests/CombineXTests/Publishers/RetrySpec.swift index d6471ff5..726c2023 100644 --- a/Tests/CombineXTests/Publishers/RetrySpec.swift +++ b/Tests/CombineXTests/Publishers/RetrySpec.swift @@ -28,7 +28,7 @@ class RetrySpec: QuickSpec { let sub = makeTestSubscriber(Int.self, TestError.self, .unlimited) pub.retry(5).subscribe(sub) - expect(sub.events) == [.completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.completion(.finished)] } // MARK: 1.2 should retry specified times then fail @@ -45,7 +45,7 @@ class RetrySpec: QuickSpec { let sub = makeTestSubscriber(Int.self, TestError.self, .unlimited) pub.retry(1).subscribe(sub) - expect(sub.events) == [.completion(.failure(.e1))] + expect(sub.eventsWithoutSubscription) == [.completion(.failure(.e1))] } } @@ -61,7 +61,7 @@ class RetrySpec: QuickSpec { let sub = makeTestSubscriber(Int.self, TestError.self, .max(5)) pub.retry(1).subscribe(sub) - expect(sub.events) == [.value(1), .value(2), .value(3), .value(1), .value(2)] + expect(sub.eventsWithoutSubscription) == [.value(1), .value(2), .value(3), .value(1), .value(2)] } } } diff --git a/Tests/CombineXTests/Publishers/SequenceSpec.swift b/Tests/CombineXTests/Publishers/SequenceSpec.swift index d7c9be92..04836532 100644 --- a/Tests/CombineXTests/Publishers/SequenceSpec.swift +++ b/Tests/CombineXTests/Publishers/SequenceSpec.swift @@ -28,7 +28,7 @@ class SequenceSpec: QuickSpec { let valueEvents = values.map { Event.value($0) } let expected = valueEvents + [.completion(.finished)] - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.2 should send as many values as demand @@ -46,7 +46,7 @@ class SequenceSpec: QuickSpec { pub.subscribe(sub) let events = (0..<70).map { Event.value($0) } - expect(sub.events) == events + expect(sub.eventsWithoutSubscription) == events } } @@ -144,7 +144,7 @@ class SequenceSpec: QuickSpec { g.wait() - expect(sub.events.count) == 100 + expect(sub.eventsWithoutSubscription.count) == 100 } // MARK: 3.2 receiving value should not block cancel diff --git a/Tests/CombineXTests/Publishers/SwitchToLatestSpec.swift b/Tests/CombineXTests/Publishers/SwitchToLatestSpec.swift index 7fe67572..cb82b6d5 100644 --- a/Tests/CombineXTests/Publishers/SwitchToLatestSpec.swift +++ b/Tests/CombineXTests/Publishers/SwitchToLatestSpec.swift @@ -41,7 +41,7 @@ class SwitchToLatestSpec: QuickSpec { subject2.send(9) let expected = [1, 2, 3, 7, 8, 9].map { TracingSubscriberEvent.value($0) } - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.3 should send failure if a child send failure @@ -66,7 +66,7 @@ class SwitchToLatestSpec: QuickSpec { subject2.send($0) } - expect(sub.events) == [.completion(.failure(.e0))] + expect(sub.eventsWithoutSubscription) == [.completion(.failure(.e0))] } // MARK: 1.4 should relay finish when there are no unfinished children @@ -81,15 +81,15 @@ class SwitchToLatestSpec: QuickSpec { subject.send(subject1) subject1.send(completion: .finished) - expect(sub.events) == [] + expect(sub.eventsWithoutSubscription) == [] subject.send(subject2) subject2.send(completion: .finished) - expect(sub.events) == [] + expect(sub.eventsWithoutSubscription) == [] subject.send(completion: .finished) - expect(sub.events) == [.completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.completion(.finished)] } } diff --git a/Tests/CombineXTests/Publishers/ThrottleSpec.swift b/Tests/CombineXTests/Publishers/ThrottleSpec.swift index 12d743b5..89a40787 100644 --- a/Tests/CombineXTests/Publishers/ThrottleSpec.swift +++ b/Tests/CombineXTests/Publishers/ThrottleSpec.swift @@ -39,10 +39,10 @@ class ThrottleSpec: QuickSpec { subject.send(7) - expect(sub.events) == [.value(2), .value(4), .value(6)] + expect(sub.eventsWithoutSubscription) == [.value(2), .value(4), .value(6)] scheduler.advance(by: .seconds(0.5)) - expect(sub.events) == [.value(2), .value(4), .value(6), .value(7)] + expect(sub.eventsWithoutSubscription) == [.value(2), .value(4), .value(6), .value(7)] } // MARK: 1.2 should send as many values as demand @@ -63,7 +63,7 @@ class ThrottleSpec: QuickSpec { scheduler.advance(by: .seconds(1)) } - expect(sub.events.count).toEventually(equal(12)) + expect(sub.eventsWithoutSubscription.count).toEventually(equal(12)) } } @@ -92,10 +92,10 @@ class ThrottleSpec: QuickSpec { subject.send(7) - expect(sub.events) == [.value(1), .value(3), .value(5)] + expect(sub.eventsWithoutSubscription) == [.value(1), .value(3), .value(5)] scheduler.advance(by: .seconds(0.5)) - expect(sub.events) == [.value(1), .value(3), .value(5), .value(7)] + expect(sub.eventsWithoutSubscription) == [.value(1), .value(3), .value(5), .value(7)] } // MARK: 1.4 should send as many values as demand @@ -116,7 +116,7 @@ class ThrottleSpec: QuickSpec { scheduler.advance(by: .seconds(1)) } - expect(sub.events.count).toEventually(equal(12)) + expect(sub.eventsWithoutSubscription.count).toEventually(equal(12)) } } } diff --git a/Tests/CombineXTests/Publishers/TimeoutSpec.swift b/Tests/CombineXTests/Publishers/TimeoutSpec.swift index 7a57fe9f..8f5e7515 100644 --- a/Tests/CombineXTests/Publishers/TimeoutSpec.swift +++ b/Tests/CombineXTests/Publishers/TimeoutSpec.swift @@ -25,10 +25,10 @@ class TimeoutSpec: QuickSpec { pub.subscribe(sub) scheduler.advance(by: .seconds(4)) - expect(sub.events) == [] + expect(sub.eventsWithoutSubscription) == [] scheduler.advance(by: .seconds(5)) - expect(sub.events) == [.completion(.failure(.e0))] + expect(sub.eventsWithoutSubscription) == [.completion(.failure(.e0))] } // MARK: 1.2 should finish if `customError` is nil @@ -42,7 +42,7 @@ class TimeoutSpec: QuickSpec { pub.subscribe(sub) scheduler.advance(by: .seconds(6)) - expect(sub.events) == [.completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.completion(.finished)] } // MARK: 1.3 should send timeout event in scheduled action @@ -60,7 +60,7 @@ class TimeoutSpec: QuickSpec { }) pub.subscribe(sub) - expect(sub.events).toEventually(equal([.completion(.failure(TestError.e0))])) + expect(sub.eventsWithoutSubscription).toEventually(equal([.completion(.failure(TestError.e0))])) } } } diff --git a/Tests/CombineXTests/Publishers/TryAllSatisfySpec.swift b/Tests/CombineXTests/Publishers/TryAllSatisfySpec.swift index f2eeab8d..f27cc8b1 100644 --- a/Tests/CombineXTests/Publishers/TryAllSatisfySpec.swift +++ b/Tests/CombineXTests/Publishers/TryAllSatisfySpec.swift @@ -32,7 +32,7 @@ class TryAllSatisfySpec: QuickSpec { } subject.send(completion: .finished) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.value(true), .completion(.finished)] } @@ -54,7 +54,7 @@ class TryAllSatisfySpec: QuickSpec { } subject.send(completion: .finished) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.value(false), .completion(.finished)] } @@ -81,7 +81,7 @@ class TryAllSatisfySpec: QuickSpec { } subject.send(completion: .finished) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.completion(.failure(.e0))] } } diff --git a/Tests/CombineXTests/Publishers/TryCatchSpec.swift b/Tests/CombineXTests/Publishers/TryCatchSpec.swift index a011049b..712435b5 100644 --- a/Tests/CombineXTests/Publishers/TryCatchSpec.swift +++ b/Tests/CombineXTests/Publishers/TryCatchSpec.swift @@ -24,7 +24,7 @@ class TryCatchSpec: QuickSpec { pub.subscribe(sub) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } let valueEvents = [1, 2, 3].map { TracingSubscriberEvent.value($0) } let expected = valueEvents + [.completion(.failure(.e0))] @@ -47,7 +47,7 @@ class TryCatchSpec: QuickSpec { pub.subscribe(sub) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } let events = (0..<12).map { TracingSubscriberEvent.value($0) } expect(got) == events } @@ -63,7 +63,7 @@ class TryCatchSpec: QuickSpec { pub.subscribe(sub) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.completion(.failure(.e2))] } } diff --git a/Tests/CombineXTests/Publishers/TryCompactMapSpec.swift b/Tests/CombineXTests/Publishers/TryCompactMapSpec.swift index d2e7d7b1..7f0ed3ef 100644 --- a/Tests/CombineXTests/Publishers/TryCompactMapSpec.swift +++ b/Tests/CombineXTests/Publishers/TryCompactMapSpec.swift @@ -30,7 +30,7 @@ class TryCompactMapSpec: QuickSpec { let valueEvents = (0..<50).map { TracingSubscriberEvent.value(2 * $0) } let expected = valueEvents + [.completion(.finished)] - let got = sub.events.map { + let got = sub.eventsWithoutSubscription.map { $0.mapError { _ -> Never in fatalError("never happen") } @@ -50,7 +50,7 @@ class TryCompactMapSpec: QuickSpec { pub.send(i) } - expect(sub.events.count) == 10 + expect(sub.eventsWithoutSubscription.count) == 10 } // MARK: 1.3 should fail if transform throws an error @@ -75,7 +75,7 @@ class TryCompactMapSpec: QuickSpec { let valueEvents = (0..<10).map { TracingSubscriberEvent.value($0) } let expected = valueEvents + [.completion(.failure(.e0))] - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == expected } diff --git a/Tests/CombineXTests/Publishers/TryDropWhileSpec.swift b/Tests/CombineXTests/Publishers/TryDropWhileSpec.swift index 5378cfeb..e1ef5ed9 100644 --- a/Tests/CombineXTests/Publishers/TryDropWhileSpec.swift +++ b/Tests/CombineXTests/Publishers/TryDropWhileSpec.swift @@ -26,7 +26,7 @@ class TryDropWhileSpec: QuickSpec { } subject.send(completion: .finished) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } let valueEvents = (50..<100).map { TracingSubscriberEvent.value($0) @@ -46,7 +46,7 @@ class TryDropWhileSpec: QuickSpec { pub.send(i) } - expect(sub.events.count) == 10 + expect(sub.eventsWithoutSubscription.count) == 10 } // MARK: 1.3 should fail if predicate throws error @@ -63,7 +63,7 @@ class TryDropWhileSpec: QuickSpec { pub.send(completion: .finished) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.completion(.failure(.e0))] } diff --git a/Tests/CombineXTests/Publishers/TryPrefixWhileSpec.swift b/Tests/CombineXTests/Publishers/TryPrefixWhileSpec.swift index c7d2906b..81a1045a 100644 --- a/Tests/CombineXTests/Publishers/TryPrefixWhileSpec.swift +++ b/Tests/CombineXTests/Publishers/TryPrefixWhileSpec.swift @@ -26,7 +26,7 @@ class TryPrefixWhileSpec: QuickSpec { } subject.send(completion: .finished) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } let valueEvents = (0..<50).map { TracingSubscriberEvent.value($0) @@ -48,7 +48,7 @@ class TryPrefixWhileSpec: QuickSpec { } subject.send(completion: .failure(.e0)) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.completion(.finished)] } @@ -62,7 +62,7 @@ class TryPrefixWhileSpec: QuickSpec { pub.send(i) } - expect(sub.events.count) == 10 + expect(sub.eventsWithoutSubscription.count) == 10 } // MARK: 1.4 should fail if predicate throws error @@ -79,7 +79,7 @@ class TryPrefixWhileSpec: QuickSpec { pub.send(completion: .finished) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.completion(.failure(.e0))] } } diff --git a/Tests/CombineXTests/Publishers/TryReduceSpec.swift b/Tests/CombineXTests/Publishers/TryReduceSpec.swift index 3394e0bd..900b2d51 100644 --- a/Tests/CombineXTests/Publishers/TryReduceSpec.swift +++ b/Tests/CombineXTests/Publishers/TryReduceSpec.swift @@ -29,7 +29,7 @@ class TryReduceSpec: QuickSpec { subject.send(completion: .finished) let reduced = (0..<100).reduce(0) { $0 + $1 } - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.value(reduced), .completion(.finished)] } @@ -47,7 +47,7 @@ class TryReduceSpec: QuickSpec { subject.send($0) } - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.completion(.failure(.e0))] } diff --git a/Tests/CombineXTests/Publishers/TryRemoveDuplicatesSpec.swift b/Tests/CombineXTests/Publishers/TryRemoveDuplicatesSpec.swift index cd59ace7..c41b9aae 100644 --- a/Tests/CombineXTests/Publishers/TryRemoveDuplicatesSpec.swift +++ b/Tests/CombineXTests/Publishers/TryRemoveDuplicatesSpec.swift @@ -29,7 +29,7 @@ class TryRemoveDuplicatesSpec: QuickSpec { pub.send(3) pub.send(3) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.value(1), .value(2), .value(3)] } @@ -44,7 +44,7 @@ class TryRemoveDuplicatesSpec: QuickSpec { pub.send(Int.random(in: 0..<100)) } - expect(sub.events.count) == 10 + expect(sub.eventsWithoutSubscription.count) == 10 } // MARK: 1.3 should fail if closure throws error @@ -59,7 +59,7 @@ class TryRemoveDuplicatesSpec: QuickSpec { pub.send(1) pub.send(1) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.value(1), .completion(.failure(.e0))] } diff --git a/Tests/CombineXTests/Publishers/TryScanSpec.swift b/Tests/CombineXTests/Publishers/TryScanSpec.swift index dc64940f..3ad7e89e 100644 --- a/Tests/CombineXTests/Publishers/TryScanSpec.swift +++ b/Tests/CombineXTests/Publishers/TryScanSpec.swift @@ -28,7 +28,7 @@ class TryScanSpec: QuickSpec { } subject.send(completion: .finished) - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } var initial = 0 let valueEvents = (0..<100).map { n -> TracingSubscriberEvent in @@ -53,7 +53,7 @@ class TryScanSpec: QuickSpec { subject.send($0) } - let got = sub.events.mapError { $0 as! TestError } + let got = sub.eventsWithoutSubscription.mapError { $0 as! TestError } expect(got) == [.completion(.failure(.e0))] } diff --git a/Tests/CombineXTests/Publishers/ZipSpec.swift b/Tests/CombineXTests/Publishers/ZipSpec.swift index 0c6751e9..e605047c 100644 --- a/Tests/CombineXTests/Publishers/ZipSpec.swift +++ b/Tests/CombineXTests/Publishers/ZipSpec.swift @@ -32,7 +32,7 @@ class ZipSpec: QuickSpec { subject1.send("c") let expected = ["0a", "1b", "2c"].map { TracingSubscriberEvent.value($0) } - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.2 should zip of 3 @@ -60,7 +60,7 @@ class ZipSpec: QuickSpec { subject2.send("D") let expected = ["0aA", "1bB", "2cC", "3dD"].map { TracingSubscriberEvent.value($0) } - expect(sub.events) == expected + expect(sub.eventsWithoutSubscription) == expected } // MARK: 1.3 should finish when one sends a finish @@ -76,7 +76,7 @@ class ZipSpec: QuickSpec { subjects[$0 % 4].send($0) } subjects[3].send(completion: .finished) - expect(sub.events) == [.value(6), .value(22), .completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.value(6), .value(22), .completion(.finished)] } // MARK: 1.4 should fail when one sends an error @@ -92,7 +92,7 @@ class ZipSpec: QuickSpec { subjects[$0 % 4].send($0) } subjects[3].send(completion: .failure(.e0)) - expect(sub.events) == [.value(6), .value(22), .completion(.failure(.e0))] + expect(sub.eventsWithoutSubscription) == [.value(6), .value(22), .completion(.failure(.e0))] } // MARK: 1.5 should send as many as demands @@ -119,7 +119,7 @@ class ZipSpec: QuickSpec { subject1.send("\($0)") } - expect(sub.events.count) == 12 + expect(sub.eventsWithoutSubscription.count) == 12 } } } diff --git a/Tests/CombineXTests/Subjects/CurrentValueSubjectSpec.swift b/Tests/CombineXTests/Subjects/CurrentValueSubjectSpec.swift index b6e1ab68..4cbcf286 100644 --- a/Tests/CombineXTests/Subjects/CurrentValueSubjectSpec.swift +++ b/Tests/CombineXTests/Subjects/CurrentValueSubjectSpec.swift @@ -27,7 +27,7 @@ class CurrentValueSubjectSpec: QuickSpec { subject.send($0) } - expect(sub.events) == [.value(-1), .completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.value(-1), .completion(.finished)] expect(subject.value) == -1 } @@ -41,7 +41,7 @@ class CurrentValueSubjectSpec: QuickSpec { subject.send(completion: .failure(.e1)) subject.send(completion: .failure(.e2)) - expect(sub.events) == [.value(-1), .completion(.failure(.e0))] + expect(sub.eventsWithoutSubscription) == [.value(-1), .completion(.failure(.e0))] } // MARK: 1.3 should not send events after the subscription is cancelled @@ -60,7 +60,7 @@ class CurrentValueSubjectSpec: QuickSpec { subject.send(1) subject.send(completion: .failure(.e0)) - expect(sub.events).to(beEmpty()) + expect(sub.eventsWithoutSubscription).to(beEmpty()) } // MARK: @@ -79,7 +79,7 @@ class CurrentValueSubjectSpec: QuickSpec { subject.send($0) } - expect(sub.events).to(beEmpty()) + expect(sub.eventsWithoutSubscription).to(beEmpty()) } // MARK: 1.5 should send completion even if the subscriber does not request @@ -94,7 +94,7 @@ class CurrentValueSubjectSpec: QuickSpec { subject.subscribe(sub) subject.send(completion: .failure(.e0)) - expect(sub.events) == [.completion(.failure(.e0))] + expect(sub.eventsWithoutSubscription) == [.completion(.failure(.e0))] } // MARK: @@ -106,7 +106,7 @@ class CurrentValueSubjectSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, TestError.self, .unlimited) subject.subscribe(sub) - expect(sub.events) == [.completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.completion(.finished)] } } @@ -130,13 +130,13 @@ class CurrentValueSubjectSpec: QuickSpec { subject.send($0) } - expect(sub.events.count) == 2 + expect(sub.eventsWithoutSubscription.count) == 2 sub.subscription?.request(.max(5)) 10.times { subject.send($0) } - expect(sub.events.count) == 7 + expect(sub.eventsWithoutSubscription.count) == 7 } // MARK: 2.2 should send as many values to subscribers as their demands @@ -157,7 +157,7 @@ class CurrentValueSubjectSpec: QuickSpec { } for (i, sub) in zip(nums, subs) { - expect(sub.events.count) == i + expect(sub.eventsWithoutSubscription.count) == i } } @@ -185,7 +185,7 @@ class CurrentValueSubjectSpec: QuickSpec { weak var subscription = sub.subscription as AnyObject - sub.release() + sub.releaseSubscription() expect(subscription).toNot(beNil()) pub.send(completion: .finished) @@ -217,7 +217,7 @@ class CurrentValueSubjectSpec: QuickSpec { weak var subscription = sub.subscription as AnyObject - sub.release() + sub.releaseSubscription() expect(subscription).toNot(beNil()) (subscription as? Subscription)?.cancel() @@ -361,7 +361,7 @@ class CurrentValueSubjectSpec: QuickSpec { g.wait() - expect(sub.events.count) == 10 + expect(sub.eventsWithoutSubscription.count) == 10 } // MARK: 4.3 no guarantee of synchronous backpressure @@ -391,7 +391,7 @@ class CurrentValueSubjectSpec: QuickSpec { g.wait() - expect(sub.events.count) == 10 + expect(sub.eventsWithoutSubscription.count) == 10 } } @@ -425,15 +425,15 @@ class CurrentValueSubjectSpec: QuickSpec { }, receiveCompletion: { _ in }) subject.subscribe(sub) - expect(sub.events) == [] + expect(sub.eventsWithoutSubscription) == [] subject.send(1) sub.subscription?.request(.max(1)) - expect(sub.events) == [.value(1)] + expect(sub.eventsWithoutSubscription) == [.value(1)] sub.subscription?.request(.max(1)) - expect(sub.events) == [.value(1)] + expect(sub.eventsWithoutSubscription) == [.value(1)] } } } diff --git a/Tests/CombineXTests/Subjects/PassthroughSubjectSpec.swift b/Tests/CombineXTests/Subjects/PassthroughSubjectSpec.swift index 1d3fdf90..f10044dc 100644 --- a/Tests/CombineXTests/Subjects/PassthroughSubjectSpec.swift +++ b/Tests/CombineXTests/Subjects/PassthroughSubjectSpec.swift @@ -103,7 +103,7 @@ class PassthroughSubjectSpec: QuickSpec { 10.times { subject.send($0) } - expect(sub.events) == [.completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.completion(.finished)] } // MARK: 1.2 should not send completion to subscribers after sending completion @@ -117,7 +117,7 @@ class PassthroughSubjectSpec: QuickSpec { subject.send(completion: .failure(.e1)) subject.send(completion: .failure(.e2)) - expect(sub.events) == [.completion(.failure(.e0))] + expect(sub.eventsWithoutSubscription) == [.completion(.failure(.e0))] } // MARK: 1.3 should not send events after the subscription is cancelled @@ -136,7 +136,7 @@ class PassthroughSubjectSpec: QuickSpec { subject.send(1) subject.send(completion: .failure(.e0)) - expect(sub.events).to(beEmpty()) + expect(sub.eventsWithoutSubscription).to(beEmpty()) } // MARK: 1.4 should not send values before the subscriber requests @@ -153,7 +153,7 @@ class PassthroughSubjectSpec: QuickSpec { subject.send(1) subject.send(1) - expect(sub.events).to(beEmpty()) + expect(sub.eventsWithoutSubscription).to(beEmpty()) } // MARK: 1.5 should send completion even if the subscriber does not request @@ -165,7 +165,7 @@ class PassthroughSubjectSpec: QuickSpec { subject.subscribe(sub) subject.send(completion: .failure(.e0)) - expect(sub.events) == [.completion(.failure(.e0))] + expect(sub.eventsWithoutSubscription) == [.completion(.failure(.e0))] } // MARK: 1.6 should resend completion if the subscription happens after sending completion @@ -176,7 +176,7 @@ class PassthroughSubjectSpec: QuickSpec { let sub = makeTestSubscriber(Int.self, TestError.self, .unlimited) subject.subscribe(sub) - expect(sub.events) == [.completion(.finished)] + expect(sub.eventsWithoutSubscription) == [.completion(.finished)] } } @@ -199,13 +199,13 @@ class PassthroughSubjectSpec: QuickSpec { subject.send($0) } - expect(sub.events.count) == 2 + expect(sub.eventsWithoutSubscription.count) == 2 sub.subscription?.request(.max(5)) 10.times { subject.send($0) } - expect(sub.events.count) == 8 + expect(sub.eventsWithoutSubscription.count) == 8 } // MARK: 2.2 should send as many values to subscribers as their demands @@ -226,7 +226,7 @@ class PassthroughSubjectSpec: QuickSpec { } for (i, sub) in zip(nums, subs) { - expect(sub.events.count) == i + expect(sub.eventsWithoutSubscription.count) == i } } @@ -254,7 +254,7 @@ class PassthroughSubjectSpec: QuickSpec { weak var subscription = sub.subscription as AnyObject - sub.release() + sub.releaseSubscription() expect(subscription).toNot(beNil()) pub.send(completion: .finished) @@ -286,7 +286,7 @@ class PassthroughSubjectSpec: QuickSpec { weak var subscription = sub.subscription as AnyObject - sub.release() + sub.releaseSubscription() expect(subscription).toNot(beNil()) (subscription as? Subscription)?.cancel() @@ -431,7 +431,7 @@ class PassthroughSubjectSpec: QuickSpec { g.wait() - expect(sub.events.count) == 10 + expect(sub.eventsWithoutSubscription.count) == 10 } // MARK: 4.3 no guarantee of synchronous backpressure @@ -461,7 +461,7 @@ class PassthroughSubjectSpec: QuickSpec { g.wait() - expect(sub.events.count) == 10 + expect(sub.eventsWithoutSubscription.count) == 10 } } }