-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from cx-org/fix#44
fix scheduler time overflow
- Loading branch information
Showing
8 changed files
with
103 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Foundation | ||
import Nimble | ||
|
||
public func throwAssertion<T>() -> Predicate<T> { | ||
return Predicate { actualExpression in | ||
return try Nimble.throwAssertion().satisfies(actualExpression.cast { _ in }) | ||
} | ||
} | ||
|
||
public func beAllEqual<S: Sequence, T: Equatable>() -> Predicate<S> | ||
where S.Iterator.Element == T { | ||
return Predicate.simple("element be all equal") { actualExpression in | ||
guard let actualValue = try actualExpression.evaluate() else { | ||
return .fail | ||
} | ||
var actualGenerator = actualValue.makeIterator() | ||
if let first = actualGenerator.next() { | ||
while let next = actualGenerator.next() { | ||
if next != first { | ||
return .doesNotMatch | ||
} | ||
} | ||
} | ||
return .matches | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extension FixedWidthInteger { | ||
|
||
public func multipliedClamping(by rhs: Self) -> Self { | ||
let (value, overflow) = multipliedReportingOverflow(by: rhs) | ||
return overflow ? .max : value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Foundation | ||
import CXShim | ||
import CXTestUtility | ||
import Quick | ||
import Nimble | ||
|
||
class FixedSpec: QuickSpec { | ||
|
||
override func spec() { | ||
|
||
afterEach { | ||
TestResources.release() | ||
} | ||
|
||
// MARK: should fix https://github.com/cx-org/CombineX/issues/44 | ||
it("should fix #44") { | ||
let pub = PassthroughSubject<Int, Never>() | ||
let sub = makeTestSubscriber(Int.self, Never.self, .unlimited) | ||
pub.debounce(for: 0.5, scheduler: DispatchQueue.global().cx).receive(subscriber: sub) | ||
|
||
(0...10).forEach(pub.send) | ||
|
||
expect(sub.events).to(beEmpty()) | ||
expect(sub.events).toEventually(equal([.value(10)])) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
This target contains inconsistent behaviour between CombineX and Apple's Combine, including: | ||
|
||
### [FailingTests](FailingTests) | ||
### FailingTests | ||
|
||
The behaviour of CombineX is wrong and needs to be fixed. | ||
|
||
### [SuspiciousBehaviour](SuspiciousBehaviour) | ||
### SuspiciousBehaviour | ||
|
||
The behaviour of Apple's Combine is suspicious or inconsistent with documentation. CombineX will not fix them. | ||
|
||
### Fixed | ||
|
||
Was failing or suspicious, now fixed and consistent with Apple's Combine. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,4 +80,6 @@ QCKMain([ | |
FailingSubjectSpec.self, | ||
|
||
SuspiciousDemandSpec.self, | ||
|
||
FixedSpec.self, | ||
]) |