question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Primitive array subject `Iterable` views' methods are misnamed

See original GitHub issue

We have:

  • containsAtLeast
  • containsAnyOf
  • containsExactly
  • containsNoneOf

But the methods accept arrays, so they should use the names we use for Iterable- and array-accepting methods elsewhere:

  • containsAtLeastElementsIn
  • containsAnyIn
  • containsExactlyElementsIn
  • containsNoneIn

(To be clear, I’m talking about the methods in PrimitiveDoubleArraySubject.DoubleArrayAsIterable and PrimitiveFloatArraySubject.FloatArrayAsIterable.)

I didn’t see explicit discussion of the names in the doc “Truth about arrays (esp. double[]),” and in fact the doc suggests that we didn’t yet have a precedent for array-accepting methods, as it links to bug 18153623, the bug about IterableSubject.containsExactlyElementsIn(Object[]), etc. Or really, we did have a precedent, and that was to tell people to call the varargs methods, like containsExactly. So we followed precedent fine; we just didn’t realize that we had to update these methods when we added the methods to IterableSubject.

All that said, I can’t imagine that I’ll get around to fixing this, and I can live with that. Still, @kluever and @PeteGillin in case they want to argue that this is worse than I think. And I’m adding it to the 1.0 milestone to make sure I drop it consciously when the time comes.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cpovirkcommented, Jun 22, 2019

Since I don’t expect us to make breaking changes, I want to be careful about the message I’d send by having such a list. That said… I do have one 😃 – but more with the idea that it could make some interesting blog posts for people interested in API Design or writing Truth for MyLanguage. I’m not sure anything will ever come of that, but we’ll see.

0reactions
jbduncancommented, Jun 19, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is an array not assignable to Iterable? - Stack Overflow
Actually, Arrays.asList is not good enough because it doesn't work on arrays of primitive types. The only built-in way to generically iterate (boxed)...
Read more >
Should use for each or for loop for primitive array? - CodeRanch
I have read some posts, they say that both the primitive arrays and ArrayList are fast, at least faster than the List.
Read more >
ArrayList (Java Platform SE 7 ) - Oracle Help Center
Resizable-array implementation of the List interface. Implements all optional list operations, and permits all elements, including null.
Read more >
Array Copy in Java - GeeksforGeeks
Given an array, we need to copy its elements in a different array, to a naive user below way comes into mind which...
Read more >
ArrayLists and Iterators - Saylor Academy
But because lists are so useful, Java includes the ArrayList class, which works much like an array with extra methods and features.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found