-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test Publishers.CollectByTime with TestScheduler #25
Comments
Hi – thanks for the report. Yes, looks like there was an issue with the TestScheduler that meant it failed to schedule any repeating actions – which is required by Combine's CollectByTime publisher. I've posted a fix on a branch called test-scheduler-intervals attached to PR #26. Let me know if that resolves your issue. |
It works, thanks a lot! |
Or maybe it doesn't...
And got |
Not at all. Good to get the issues ironed out. Try the latest commit to PR #26 |
There is still something wrong with it...
With test scheduler I got:
As you can see I've written the function which produces the expected answer and the result should be:
I've tested the "expected answer" function and P.S. I think there is something wrong with the approach to repeating actions. I'm going to continue without test scheduler for P.S. P.S. I have created a |
Hi @iwheelbuy, thanks for writing this up – I really appreciate it! However, when I run your example numbers, it matches the control.
I'm not sure our understanding My understanding of When also specifying count as part of the strategy, the behaviour is the same, except that if the count is reached within a time interval (0..<5 or 5..<10), the publisher will immediately output the elements it has already collected for that time interval, but otherwise continue as normal. As an example, if we schedule [0,1,2,3,4,5,6,7,8,9] to be published with an interval of 5, and a count of 5, we will receive [[0,1,2,3,4],[5,6,7,8,9]] and if we ask for an interval of 5 and count of 2 we will receive [[0,1],[2,3],[4],[5,6],[7,8],[9]]. As the interval is determined by the subscribe time, if we offset everything by 3 ([3,4,5,6,7,8,9,10,11,12]), with an interval of 5 and a count of 5, we will receive [[3,4],[5,6,7,8,9],[10,11,12]] and if we ask for an interval of 5 and count of 2 we will receive [[3,4],[5,6],[7,8],[9],[10,11],[12]]. Using your own example, we can test without Entwine using a control by:
And with Entwine, we have:
Were you expecting something different? |
Our understanding matches up! It was me who made a mistake. Values I'll check again (^ |
As I've mentioned
The first emitted array |
Thanks for checking! If you run this test:
What do you get? |
XCTAssertEqual failed: ("[[1, 5, 7, 11], [13], [27, 35], [43], [51, 53, 55], [61, 67, 69], [73, 77, 79, 83], [87, 89, 91, 93, 95]]") is not equal to ("[[1, 5, 7, 11], [13, 27, 35, 43, 51], [53, 55, 61, 67, 69], [73, 77, 79, 83, 87]]") |
Curious – that passes for me. Are you testing against the latest |
Checked also on XCTAssertEqual failed: ("[[1, 5, 7, 11], [13], [27, 35], [43], [51, 53, 55], [61, 67, 69], [73, 77, 79, 83], [87, 89, 91, 93, 95]]") is not equal to ("[[1, 5, 7, 11], [13, 27, 35, 43, 51], [53, 55, 61, 67, 69], [73, 77, 79, 83, 87]]") |
Yeah, it needs to be the branch of the PR for this issue: |
After switching between PR branch, 0.9.0 tag and back - It started to pass successfully..... I'll do some more research, thank you for your reply. |
No problem, let me know if it works out and I'll merge this into master. Thanks! |
Everything works! |
Great news! Glad it worked out. |
I've started to test various Combine Publishers and got stuck with
Publishers.CollectByTime
. I'm usingTestScheduler
andVirtualTimeInterval
to test it. I might got it all wrong, but I expect the publisher to buffer and periodically publish arrays of signals. The first array is published correctly and it respects theVirtualTimeInterval
. But then ALL other signals are published in the second array andVirtualTime
of each signal is ignored.With
VirtualTimeInterval = 2
I publishI expect
Publishers.CollectByTime
to group signals this way:["ab", "cd", "ef"]
. But I get["ab", "cdef"]
.Can you please tell me what is wrong with my code or maybe with my understanding the
CollectByTime
publisher?The text was updated successfully, but these errors were encountered: