-
Notifications
You must be signed in to change notification settings - Fork 0
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
provide contains for array #75
Comments
Is it an option to add an overloaded |
You mean overloads which basically delegate to
and I would prefer if things always need to be done the same way. Otherwise it seems a bit like an inconsistency that one can do |
Hm, I see your point. Then generating the functions for any matcher that is defined for On the other hand, this peculiarity of atrium might be something that shies people away in the very beginning, when picking their assertion library (“I am not going to use that, I can’t even test arrays!”). |
Would be an argument to add at least overloads for |
@dalewking what Array type do you usually deal with: |
In the case I needed it was an Array, in fact I was trying to assertions on the values property of an enum |
I think using it is not a big deal once you know it. However, finding out that it is meant to be used like that might be. People just want to write down That’s my take. Maybe @dalewking can talk about his experience. On another note: would adding array overloads to all functions that deconstruct an |
Believe you mean expect(arr.toList()). Is it a show stopper issue? No, and that is of course what I had to do. But when you try |
I meant
I see your point and I am not against adding more support for arrays it should just be in a way which is manageable.
Yes, I think you really underestimate this. Have a look at arrayAssertions.kt it covers one functionality Note further, that Nevertheless, I support the idea of having better support for array. I would strive for a generative approach but would also be fine with the following compromise:
How does that sound to you? If you don't like the compromise then I'll create an issue for the generative approach instead. |
Thanks for the elaborate explanation. I want to clarify before I make a decision on whether I want to put up with this: I was still thinking of making deconstructing functions support arrays. E.g. add overloads like fun expect(subject: Array) = expect(subject).asList() and Expect<List<Array<*>>.get(index: Int) = get(index).asList() and similarily for the feature functions, etc. However, your explanation still seems to talk about copying From my point of view, my proposal has some advantages: When copying the
With my approach, I think it would rightfully return an Expect<List>. Because we would try to eliminate all What are your thoughts on the advantages and disadvantages of the two approaches?
I agree, if we tackle arrays, we should also support |
Bowing out of this conversation as I have had to abandon Atrium due to lack of Kotlin Native iOS support |
@dalewking fair enough, thanks for your input so far, appreciated 👍 |
@jGleitz if I get you right, you would like to turn Arrays into Lists for all cases where a function could potentially return an array. I have a very bad feeling with this because:
Also, if I were using array a lot then it is likely that I would create extension-methods for it. |
Yes, that is my idea.
I am not sure what you mean by that. From my understanding, we would need array overloads for every function that deconstructs an
I am also not sure what you mean by that. Somebody who is just using the atrium API would automatically get an
That is a good point. I would need to see some use cases to judge how bad that is, though. Because where would I use those functions? Maybe we can adapt the feature functions to deal with that? Maybe I use the functions before handing the values to atrium? As far as I can see, it would only be a problem if I use the functions on a value after I have passed it to |
above I guessed that we have around 20 functions to transform for Array. What I meant with
Every time you write an own assertion function for a type which has type parameters where you want to extract this type you would need to add the 9 to 11 overloads for array. For instance: With your proposition we put the maintenance burden not only on us but also on potential Atrium extension writers. Say one writes an extension for Arrow which has a lot of data structures with type parameters (and I guess this will happen at one point). Do you see what I mean? If we duplicate the Iterable/List functions on the other hand, then we have:
|
Hm. It sounded all well in my head. But you are right, duplicating the assertions is the better approach. |
Alright, the remaining question is how we want to proceed: create a task for a generative approach or are you willing to do the work as suggested hear: |
I’ve done some code generations with kotlinpoet and it was fairly easy. Especially because building Gradle tasks is so easy. So if I was to pick it up (which I plan to, but I can’t promise), I would probably do that. |
good, I will create a task and whoever wants to work on it can (I'll leave it open to the implementer what generative approach is taken) |
Created, robstoll/atrium#459 closing this |
Since I got another request (robstoll/atrium#419) regarding
I am opening the discussion if we want to support this.
So far people where happy enough with:
But I understand that it is kind of cumbersome if one works a lot with arrays.
The problem with better support for array is that it would require a lot of duplication. There are 9 different Array types and everywhere we support Iterable we would need to add 9 additional duplicates. That's a lot of maintenance for little gain IMO.
I could imagine that we use a generative approach to tackle it so that we only have to write the Iterable version and derive the ones for the 9 different array types. However, still questionable if the effort and the maintenance afterwards is worth it.
Thoughts?
The text was updated successfully, but these errors were encountered: