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

Consolidate CollectionSubject/ListSubject into IterableSubject? #57

Closed
fluentfuture opened this issue Apr 12, 2013 · 2 comments
Closed
Labels
type=addition A new feature

Comments

@fluentfuture
Copy link

Hi.

Wondering if assertions on Collection and List can be applied to all Iterable's.

Most assertions from ListSubject and CollectionSubject seem to also make sense to iterables:

isEmpty()
isOrdered()
containsSequence()
has().exactly(...)

So how about flattening the class hierarchy and just have all these assertions for any Iterable?

Internally some implementations could simply copy the Iterable into a List. It's a test after all.

I believe it also makes the API surface smaller.

@cgruber
Copy link
Contributor

cgruber commented Oct 7, 2013

So, has().*() used to be on iterable, but I wanted to distinguish random access types from iterables, since iterables have a very limited contract, and must behave a certain way. But the more I think of it, the more I think Iterable() should have these, and IteratorSubject should exist which allows you to do the things I currently am thinking of for Iterable. I'm not sure why I didn't think of that before. It's really iterator behaviour I wanted to keep clear from collection/list/etc, since isOrdered()/containsSequence() are list/bag/set operations, but Iterator is a walk over elements. So... I think I might just do that.

I'm a little worried about copying iterables into a list (even though it's a test) as some tests need to test statefully through the test, so exploding the whole iterator's contents can mess that up. That said, if I pull out the iterator itself, so those sorts of tests can go ASSERT.that(iterable.iterator()).blahblahblah(), then that is the escape valve for those kinds of tests.

@cgruber
Copy link
Contributor

cgruber commented Oct 29, 2014

Largely done.

@cgruber cgruber closed this as completed Oct 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type=addition A new feature
Projects
None yet
Development

No branches or pull requests

2 participants