Skip to content

Commit

Permalink
Use <? super T> in Assert.assertThat
Browse files Browse the repository at this point in the history
Add comments explaining our interpretation of the type parameter on org.hamcrest.Matcher
  • Loading branch information
fbarber committed Oct 5, 2011
1 parent 1cff207 commit 8c2f789
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/junit/Assert.java
Expand Up @@ -721,6 +721,11 @@ public static void assertEquals(Object[] expecteds, Object[] actuals) {
* // got value: &lt;0&gt;
* assertThat(0, is(not(1))) // passes
* </pre>
*
* <code>org.hamcrest.Matcher</code> does not currently document the meaning
* of its type parameter <code>T</code>. This method assumes that a matcher
* typed as <code>Matcher&lt;T&gt;</code> can be meaningfully applied only
* to values that could be assigned to a variable of type <code>T</code>.
*
* @param <T>
* the static type accepted by the matcher (this can flag obvious
Expand Down Expand Up @@ -753,6 +758,11 @@ public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
* assertThat(&quot;Zero is one&quot;, 0, is(not(1))) // passes
* </pre>
*
* <code>org.hamcrest.Matcher</code> does not currently document the meaning
* of its type parameter <code>T</code>. This method assumes that a matcher
* typed as <code>Matcher&lt;T&gt;</code> can be meaningfully applied only
* to values that could be assigned to a variable of type <code>T</code>.
*
* @param reason
* additional information about the error
* @param <T>
Expand Down

0 comments on commit 8c2f789

Please sign in to comment.