File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
main/java/org/hamcrest/core
test/java/org/hamcrest/core Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -33,9 +33,7 @@ public void describeTo(Description description) {
33
33
/**
34
34
* Creates a matcher that always matches, regardless of the examined object.
35
35
*/
36
- public static Matcher <Object > anything () {
37
- return new IsAnything <Object >();
38
- }
36
+ public static Matcher <Object > anything () { return new IsAnything <>(); }
39
37
40
38
/**
41
39
* Creates a matcher that always matches, regardless of the examined object, but describes
@@ -45,6 +43,6 @@ public static Matcher<Object> anything() {
45
43
* a meaningful {@link String} used when describing itself
46
44
*/
47
45
public static Matcher <Object > anything (String description ) {
48
- return new IsAnything <Object >(description );
46
+ return new IsAnything <>(description );
49
47
}
50
48
}
Original file line number Diff line number Diff line change 5
5
6
6
import static org .hamcrest .AbstractMatcherTest .assertDescription ;
7
7
import static org .hamcrest .AbstractMatcherTest .assertMatches ;
8
+ import static org .hamcrest .MatcherAssert .assertThat ;
9
+ import static org .hamcrest .core .Is .is ;
8
10
import static org .hamcrest .core .IsAnything .anything ;
9
11
10
12
public final class IsAnythingTest {
11
13
12
14
private final Matcher <Object > matcher = anything ();
13
15
14
- private static class CustomThing { }
15
-
16
- @ Test public void
16
+ private static class CustomThing {
17
+ }
18
+
19
+ @ Test
20
+ public void
17
21
alwaysEvaluatesToTrue () {
18
22
assertMatches ("didn't match null" , matcher , null );
19
23
assertMatches ("didn't match Object" , matcher , new Object ());
20
24
assertMatches ("didn't match custom object" , matcher , new CustomThing ());
21
25
assertMatches ("didn't match String" , matcher , "hi" );
22
26
}
23
27
28
+ @ Test
29
+ public void compilesWithoutTypeWarnings () {
30
+ assertThat (new CustomThing (), is (anything ()));
31
+ }
32
+
24
33
@ Test public void
25
34
hasUsefulDefaultDescription () {
26
35
assertDescription ("ANYTHING" , matcher );
You can’t perform that action at this time.
0 commit comments