Skip to content

Commit 07621ff

Browse files
author
nat.pryce
committed
improved variable name
1 parent a369d80 commit 07621ff

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

hamcrest-core/src/main/java/org/hamcrest/StringDescription.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public StringDescription(Appendable out) {
2424
* @return
2525
* The description of the object.
2626
*/
27-
public static String toString(SelfDescribing value) {
28-
return new StringDescription().appendDescriptionOf(value).toString();
27+
public static String toString(SelfDescribing selfDescribing) {
28+
return new StringDescription().appendDescriptionOf(selfDescribing).toString();
2929
}
3030

3131
/**

hamcrest-integration/src/main/java/org/hamcrest/MatcherAssert.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@ public static <T> void assertThat(String reason, T actual, Matcher<T> matcher) {
2121
throw new java.lang.AssertionError(description.toString());
2222
}
2323
}
24+
25+
public static void assertThat(String reason, boolean assertion) {
26+
if (!assertion) {
27+
throw new java.lang.AssertionError(reason);
28+
}
29+
}
2430
}

hamcrest-unit-test/src/main/java/org/hamcrest/MatcherAssertTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ public void testIncludesDescriptionOfTestedValueInErrorMessage() {
1616
}
1717
catch (AssertionError e) {
1818
assertEquals(expectedMessage, e.getMessage());
19+
return;
1920
}
21+
22+
fail("should have failed");
2023
}
2124

2225
public void testDescriptionCanBeElided() {
@@ -30,7 +33,23 @@ public void testDescriptionCanBeElided() {
3033
}
3134
catch (AssertionError e) {
3235
assertEquals(expectedMessage, e.getMessage());
36+
return;
3337
}
38+
39+
fail("should have failed");
40+
}
41+
42+
public void testCanTestBooleanDirectly() {
43+
assertThat("reason message", true);
44+
45+
try {
46+
assertThat("failing reason message", false);
47+
}
48+
catch (AssertionError e) {
49+
assertEquals("failing reason message", e.getMessage());
50+
return;
51+
}
52+
53+
fail("should have failed");
3454
}
3555
}
36-

0 commit comments

Comments
 (0)