Open GoogleCodeExporter opened 8 years ago
Perhaps stranger still is that extracting the matcher to a local variable makes
it work fine. It's terribly ugly this way, though:
Iterable<String> i = null;
Matcher<Iterable<? super String>> matcher = hasItem(equalTo("foo"));
assertThat(i, matcher);
Original comment by zzant...@gmail.com
on 16 Mar 2011 at 4:53
interesting thing is that "contains" matcher works. I've never had courage to
investigate the difference though =)
Original comment by ata...@gmail.com
on 31 Mar 2011 at 11:05
The signature of contains is different than hasItem:
public static <T> org.hamcrest.Matcher<java.lang.Iterable<? super T>>
hasItem(org.hamcrest.Matcher<? super T> p0)
vs
public static <E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>>
contains(org.hamcrest.Matcher<? super E> p0)
Notably, the former returns a Matcher<Iterable<? super T>>, where the latter
returns a Matcher<Iterable<? extends E>>. The generics are where things are
broken. I'm not sure, but I think "? extends E" makes more sense in that
context anyway.
Original comment by zzant...@gmail.com
on 31 Mar 2011 at 2:53
Bug added against JDK6:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7035413
(The bug database is *really* slow sometimes.)
Original comment by zzant...@gmail.com
on 11 Apr 2011 at 3:08
tagging
Original comment by t.denley
on 12 May 2012 at 10:39
Original issue reported on code.google.com by
zzant...@gmail.com
on 16 Mar 2011 at 4:43