Skip to content

Commit

Permalink
test: TimerPublisher on macOS 11
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddxxx committed Nov 20, 2020
1 parent 4f58fdb commit e61fce7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
16 changes: 0 additions & 16 deletions Tests/CXFoundationTests/TimerSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,5 @@ class TimerSpec: QuickSpec {

_ = connection
}

// MARK: 1.3 should add demands up from multiple subscriber
it("should add demands up from multiple subscriber") {
let pub = CXWrappers.Timer.publish(every: 0.1, on: .current, in: .common)
let sub1 = pub.subscribeTracingSubscriber(initialDemand: .max(1))
let sub2 = pub.subscribeTracingSubscriber(initialDemand: .max(2))

let connection = pub.connect()

RunLoop.current.run(until: Date().addingTimeInterval(1))

expect(sub1.eventsWithoutSubscription.count) == 3
expect(sub2.eventsWithoutSubscription.count) == 3

connection.cancel()
}
}
}
34 changes: 34 additions & 0 deletions Tests/CXInconsistentTests/Versioning/VersioningTimerSpec.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import CXShim
import CXTestUtility
import Foundation
import Nimble
import Quick

class VersioningTimerSpec: QuickSpec {

override func spec() {

it("should not add demands up from multiple subscriber") {
let pub = CXWrappers.Timer.publish(every: 0.1, on: .current, in: .common)
let sub1 = pub.subscribeTracingSubscriber(initialDemand: .max(1))
let sub2 = pub.subscribeTracingSubscriber(initialDemand: .max(2))

let connection = pub.connect()

RunLoop.current.run(until: Date().addingTimeInterval(1))

#if USE_COMBINE // FIXME: MACOS11: Apple's implementation is outdated
expect(sub1.eventsWithoutSubscription.count).toVersioning([
.v11_0: equal(3),
.v12_0: equal(1)
])
expect(sub2.eventsWithoutSubscription.count).toVersioning([
.v11_0: equal(3),
.v12_0: equal(2)
])
#endif

connection.cancel()
}
}
}
1 change: 1 addition & 0 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ QCKMain([
VersioningSwitchToLatestSpec.self,
VersioningFutureSpec.self,
VersioningTimeoutSpec.self,
VersioningTimerSpec.self,
])

0 comments on commit e61fce7

Please sign in to comment.