Skip to content
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

Move hasNext() check out of Iterable.all #305

Closed
robstoll opened this issue Jan 13, 2020 · 6 comments · Fixed by #939
Closed

Move hasNext() check out of Iterable.all #305

robstoll opened this issue Jan 13, 2020 · 6 comments · Fixed by #939
Assignees
Milestone

Comments

@robstoll
Copy link
Owner

Platform (jvm, js, android):all
Extension (none, kotlin 1.3, jdk8): none

Code related feature

Similar to #299 but for Iterable.none and iterable.all. Following an example:

expect: [1, 2, 3, 4]        (java.util.Arrays.ArrayList <1234789>)
◆ does not contain: 
  ⚬ an entry which: 
      » is greater than: 2        (kotlin.Int <1234789>)
    ✘ ▶ number of occurrences: 2
        ◾ is: 0        (kotlin.Int <1234789>)
    ✔ ▶ has at least one element: true
        ◾ is: true

Moreover, it should re-use the hasNext check instead of an own descriptive assertion

@robstoll robstoll added this to the 0.10.0 milestone Jan 13, 2020
@robstoll robstoll removed this from the 0.10.0 milestone Feb 5, 2020
@tfesenko
Copy link
Contributor

I'll work on this!

@robstoll
Copy link
Owner Author

@tfesenko note that this one is not a good first issue, I would recommend you first implement
#31 to get a bit more into Atrium and come back to this one afterwards

@robstoll
Copy link
Owner Author

robstoll commented Apr 3, 2020

@tfesenko do you still plan to work on this one? Do you need any help?

@tfesenko tfesenko removed their assignment Apr 4, 2020
@tfesenko
Copy link
Contributor

tfesenko commented Apr 4, 2020

@robstoll , unfortunately, I won't have the time to work on it right now.

@wordhou
Copy link
Collaborator

wordhou commented Jun 9, 2021

With #931 merged, this seems like a good target to work on. I believe this is the last place still using createHasElementAssertion(list) rather than _logic.hasNext. I can work on this.

Can I also suggest that in the failure case when the list is empty, we add an explanatory group explaining the conditions being checked. Similar to the notToContain in #722. So for

expect(emptyList<Double>()).all { toBeLessThan(1.0) }

we see

◆ has: a next element
  » all entries: 
    » is greater than: 2.5        (kotlin.Double <76130456>)

instead of just

◆ has: a next element

@robstoll robstoll added this to the 0.17.0 milestone Jun 9, 2021
@robstoll
Copy link
Owner Author

robstoll commented Jun 9, 2021

@wordhou also think that this is a good next issue and I totally agree, we should still see what went wrong in case the iterable is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants