-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add XCTAssertEqual for [Recorded<Event<Void>>] #1747
Conversation
Generated by 🚫 Danger |
If we’re doing a specific overload for void, might as well make it time only, since the value is irrelevant and constant |
I added an overload to accept XCTAssertEqual(voidStream.events, [
.next(5),
.next(20),
.next(55),
.next(70)
]) What do you think ? |
I also think this factory method for Void events is very useful! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you for your review and fantastic idea! |
@kzaher Have a quick minute for this? pretty quick change, but remedies an issue some users have. What do you think? |
Hi guys, I can understand why this is annoying. I'm also annoyed by it. But as far as I can tell this is Swift compiler bug/inadequacy. I would prefer if we stayed away from trying to introduce workarounds for language/compiler inadequacies. 1> () == ()
$R0: Bool = true
2>
3> func a<T: Equatable>(l: T, r: T) -> Bool { return l == r }
4> a(l: (), r: ())
error: repl.swift:4:13: error: argument type '()' does not conform to expected type 'Equatable'
a(l: (), r: ()) If this was some serious issue, then sure, we would pull it in because hell, world isn't perfect. But it seems to me that this is just an annoyance. If somebody needs to assert a list of voids, just transform it to one of your custom |
@kzaher I disagree with this assumption. We can only program for the language we have, not for the language we might have. There is no intention from the Swift core team to Fix this, it seems to me at least. And even if that happens, we can always have it as part of a new release, like we always do. The problem is substantial, as right now the only way to assert equality of I urge you to reconsider this as its a huge pain in the butt for asserting anything void (which is substantial, as mentioned). |
Hi @freak4pc , what evidence do you have that needing to add one additional I would say that we need to be consistent and only provide If we accept this PR, how are you going to decide should we also add overload for Should we also add these overloads for And even if we did all that, that still wouldn't solve any of my problems since there is myriad of other APIs I have that accept
It is. I'm looking at this every day. My code is littered with structs that are only there because tuples aren't |
I don't think the fact users were able to hack around this for 4 years makes this a non-considerable change. The fact is - Void events are not going anywhere, and they are very very common. Testing against those is also very very common. Tuples are out of the question for this specific case IMO - since there are so many variations on tuples, but Voids are just a singular thing.
|
Any advanced thoughts of this or should we close? |
@freak4pc I have some different ideas how to tackle this. There is a chance that we'll write a swift evolution proposal that would indirectly solve this issue on the compiler level, where it should be solved. Last I've heard was that there was some support in the compiler community, but I think that we are still waiting for approval. I would really want to solve this in a more correct way. |
@kzaher I actually thank that "API-wise" this is the much cleaner path. Even if in the compiler you'd make e.g.
This API, even though is more manual, provides us with a much cleaner usage, in this specific case where value has no meaning:
I still think that the road to fix this in the compiler is very very far, so we should have a normal solution in the meantime that doesn't rely on mapping to a string just to perform a simple test. That's just my personal opinion :) |
Hey @kzaher - would appreciate if you would give this another thought. |
@freak4pc |
Manually mapping void streams to some string and testing against that |
Thank you for your discussion and sorry for absent. I understood you are saying. When I'm facing this problem, I thought why Tuple does not conform Equatable. If this is resolved by compiler, I think that is better. @YiYiZheng I always map to true of Bool in my testing file when I want to test Void stream. Like this.
Any other ideas?
|
Dear diary, It is March, 2021. This PR was opened 2.5 years ago, but it's still as relevant today. |
Dear diary, |
The observer of Void is not testable on RxSwift.
This is a test case for this.
This code fails to compile on latest RxSwift code because XCTAssertEqual is not defined for
Recorded<Event<Void>>>
.This PR adds XCTAssertEqual method and equatable for related them.
This PR also may fix the issue's problem: #1552