-
Notifications
You must be signed in to change notification settings - Fork 69
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
fest-481 : Assert.isIn() and isNotIn() should take Iterable<?> #15
Conversation
Great! Idea - why not make those methods even more type-safe (like |
@ash2k could be interesting. |
@ash2k I agree with Nicolas, it would be nice to have a concrete example (that we could use for unit testing). Thanks ! |
This can't be used as a unit test but it shows benefits of generics: public class Test1 {
private final A var1 = new A();
private final B var2 = new B();
public void a() {
Collection<B> colB = codeUnderTest();
// wanted to write
// Assertions.assertThat(var2).isNotIn(colB);
Assertions.assertThat(var1).isNotIn(colB);
}
public Collection<B> codeUnderTest() {
// broken logic. should be
// return new ArrayList<B>(Arrays.asList(new B()));
return new ArrayList<B>(Arrays.asList(var2));
}
public class A {
}
public class B {
}
} With current implementation (wildcards instead of captured types) this broken test will compile and pass not detecting the error in
Java is a staticly typed language and generics were added to provide means to do more strict compile-time type checking. I think the question is "Why not use them?" than "Why use them?". What do you think? |
I think we should go as Mikhail suggest. |
Nicolas, Cheers, Joel |
I have already pushed this suggestion in this commit : https://github.com/nfrancois/fest-assert-2.x/commit/18ac8197505121ad8962738ebb7f9bf973a1ac7a Could be some conflict with #11, I let you see |
Ok, my bad, did not see your commit. Thanks ! |
See http://jira.codehaus.org/browse/FEST-481