Skip to content

Commit 2aad319

Browse files
cpovirkGoogle Java Core Libraries
authored and
Google Java Core Libraries
committed
Refer to the actual value as "the actual value," not as "the subject."
(#203) I considered instead using phrases like "the string," we [sometimes already do](https://github.com/google/truth/blob/0337b58cf7ca53d89d9badb56d7467c8576f8aa4/core/src/main/java/com/google/common/truth/StringSubject.java#L99). But I worried that that wasn't always immediately clear about whether we're talking about the actual value or some parameter of the assertion method (which is an expected value or similar). Not that I cared about this _enough_ to go back and change existing occurrences.... This CL probably covers all remaining occurrences in core Truth. I haven't looked at our extensions or our tests. RELNOTES=n/a PiperOrigin-RevId: 766689205
1 parent 0337b58 commit 2aad319

32 files changed

+344
-331
lines changed

core/src/main/java/com/google/common/truth/BigDecimalSubject.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.jspecify.annotations.Nullable;
2424

2525
/**
26-
* Propositions for {@link BigDecimal} typed subjects.
26+
* Propositions for {@link BigDecimal} values.
2727
*
2828
* @author Kurt Alfred Kluever
2929
*/
@@ -36,7 +36,7 @@ private BigDecimalSubject(FailureMetadata metadata, @Nullable BigDecimal actual)
3636
}
3737

3838
/**
39-
* Fails if the subject's value is not equal to the value of the given {@link BigDecimal}. (i.e.,
39+
* Fails if the actual value is not equal to the value of the given {@link BigDecimal}. (i.e.,
4040
* fails if {@code actual.comparesTo(expected) != 0}).
4141
*
4242
* <p><b>Note:</b> The scale of the BigDecimal is ignored. If you want to compare the values and
@@ -47,8 +47,8 @@ public void isEqualToIgnoringScale(BigDecimal expected) {
4747
}
4848

4949
/**
50-
* Fails if the subject's value is not equal to the value of the {@link BigDecimal} created from
51-
* the expected string (i.e., fails if {@code actual.comparesTo(new BigDecimal(expected)) != 0}).
50+
* Fails if the actual value is not equal to the value of the {@link BigDecimal} created from the
51+
* expected string (i.e., fails if {@code actual.comparesTo(new BigDecimal(expected)) != 0}).
5252
*
5353
* <p><b>Note:</b> The scale of the BigDecimal is ignored. If you want to compare the values and
5454
* the scales, use {@link #isEqualTo(Object)}.
@@ -58,8 +58,8 @@ public void isEqualToIgnoringScale(String expected) {
5858
}
5959

6060
/**
61-
* Fails if the subject's value is not equal to the value of the {@link BigDecimal} created from
62-
* the expected {@code long} (i.e., fails if {@code actual.comparesTo(new BigDecimal(expected)) !=
61+
* Fails if the actual value is not equal to the value of the {@link BigDecimal} created from the
62+
* expected {@code long} (i.e., fails if {@code actual.comparesTo(new BigDecimal(expected)) !=
6363
* 0}).
6464
*
6565
* <p><b>Note:</b> The scale of the BigDecimal is ignored. If you want to compare the values and
@@ -70,7 +70,7 @@ public void isEqualToIgnoringScale(long expected) {
7070
}
7171

7272
/**
73-
* Fails if the subject's value and scale is not equal to the given {@link BigDecimal}.
73+
* Fails if the actual value and scale is not equal to the given {@link BigDecimal}.
7474
*
7575
* <p><b>Note:</b> If you only want to compare the values of the BigDecimals and not their scales,
7676
* use {@link #isEqualToIgnoringScale(BigDecimal)} instead.
@@ -81,7 +81,7 @@ public void isEqualTo(@Nullable Object expected) {
8181
}
8282

8383
/**
84-
* Fails if the subject is not equivalent to the given value according to {@link
84+
* Fails if the actual value is not equivalent to the given value according to {@link
8585
* Comparable#compareTo}, (i.e., fails if {@code a.comparesTo(b) != 0}). This method behaves
8686
* identically to (the more clearly named) {@link #isEqualToIgnoringScale(BigDecimal)}.
8787
*

core/src/main/java/com/google/common/truth/BooleanSubject.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.jspecify.annotations.Nullable;
2121

2222
/**
23-
* Propositions for boolean subjects.
23+
* Propositions for boolean values.
2424
*
2525
* @author Christian Gruber ([email protected])
2626
*/
@@ -32,7 +32,7 @@ private BooleanSubject(FailureMetadata metadata, @Nullable Boolean actual) {
3232
this.actual = actual;
3333
}
3434

35-
/** Fails if the subject is false or {@code null}. */
35+
/** Fails if the actual value is false or {@code null}. */
3636
public void isTrue() {
3737
if (actual == null) {
3838
isEqualTo(true); // fails
@@ -41,7 +41,7 @@ public void isTrue() {
4141
}
4242
}
4343

44-
/** Fails if the subject is true or {@code null}. */
44+
/** Fails if the actual value is true or {@code null}. */
4545
public void isFalse() {
4646
if (actual == null) {
4747
isEqualTo(false); // fails

core/src/main/java/com/google/common/truth/ClassSubject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.jspecify.annotations.Nullable;
2222

2323
/**
24-
* Propositions for {@link Class} subjects.
24+
* Propositions for {@link Class} values.
2525
*
2626
* @author Kurt Alfred Kluever
2727
*/

core/src/main/java/com/google/common/truth/ComparableSubject.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.jspecify.annotations.Nullable;
2222

2323
/**
24-
* Propositions for {@link Comparable} typed subjects.
24+
* Propositions for {@link Comparable} values.
2525
*
2626
* @author Kurt Alfred Kluever
2727
* @param <T> the type of the object being tested by this {@code ComparableSubject}
@@ -52,22 +52,22 @@ private ComparableSubject(FailureMetadata metadata, @Nullable Object actual) {
5252
this.actual = actual;
5353
}
5454

55-
/** Checks that the subject is in {@code range}. */
55+
/** Checks that the actual value is in {@code range}. */
5656
public final void isIn(Range<T> range) {
5757
if (!range.contains(actualAsT())) {
5858
failWithActual("expected to be in range", range);
5959
}
6060
}
6161

62-
/** Checks that the subject is <i>not</i> in {@code range}. */
62+
/** Checks that the actual value is <i>not</i> in {@code range}. */
6363
public final void isNotIn(Range<T> range) {
6464
if (range.contains(actualAsT())) {
6565
failWithActual("expected not to be in range", range);
6666
}
6767
}
6868

6969
/**
70-
* Checks that the subject is equivalent to {@code other} according to {@link
70+
* Checks that the actual value is equivalent to {@code other} according to {@link
7171
* Comparable#compareTo}, (i.e., checks that {@code a.comparesTo(b) == 0}).
7272
*
7373
* <p><b>Note:</b> Do not use this method for checking object equality. Instead, use {@link
@@ -80,9 +80,9 @@ public void isEquivalentAccordingToCompareTo(@Nullable T expected) {
8080
}
8181

8282
/**
83-
* Checks that the subject is greater than {@code other}.
83+
* Checks that the actual value is greater than {@code other}.
8484
*
85-
* <p>To check that the subject is greater than <i>or equal to</i> {@code other}, use {@link
85+
* <p>To check that the actual value is greater than <i>or equal to</i> {@code other}, use {@link
8686
* #isAtLeast}.
8787
*/
8888
public final void isGreaterThan(@Nullable T other) {
@@ -92,9 +92,9 @@ public final void isGreaterThan(@Nullable T other) {
9292
}
9393

9494
/**
95-
* Checks that the subject is less than {@code other}.
95+
* Checks that the actual value is less than {@code other}.
9696
*
97-
* <p>To check that the subject is less than <i>or equal to</i> {@code other}, use {@link
97+
* <p>To check that the actual value is less than <i>or equal to</i> {@code other}, use {@link
9898
* #isAtMost}.
9999
*/
100100
public final void isLessThan(@Nullable T other) {
@@ -104,9 +104,9 @@ public final void isLessThan(@Nullable T other) {
104104
}
105105

106106
/**
107-
* Checks that the subject is less than or equal to {@code other}.
107+
* Checks that the actual value is less than or equal to {@code other}.
108108
*
109-
* <p>To check that the subject is <i>strictly</i> less than {@code other}, use {@link
109+
* <p>To check that the actual value is <i>strictly</i> less than {@code other}, use {@link
110110
* #isLessThan}.
111111
*/
112112
public final void isAtMost(@Nullable T other) {
@@ -116,9 +116,9 @@ public final void isAtMost(@Nullable T other) {
116116
}
117117

118118
/**
119-
* Checks that the subject is greater than or equal to {@code other}.
119+
* Checks that the actual value is greater than or equal to {@code other}.
120120
*
121-
* <p>To check that the subject is <i>strictly</i> greater than {@code other}, use {@link
121+
* <p>To check that the actual value is <i>strictly</i> greater than {@code other}, use {@link
122122
* #isGreaterThan}.
123123
*/
124124
public final void isAtLeast(@Nullable T other) {

core/src/main/java/com/google/common/truth/DoubleSubject.java

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.jspecify.annotations.Nullable;
2828

2929
/**
30-
* Propositions for {@link Double} subjects.
30+
* Propositions for {@link Double} values.
3131
*
3232
* @author Kurt Alfred Kluever
3333
*/
@@ -40,18 +40,18 @@ private DoubleSubject(FailureMetadata metadata, @Nullable Double actual) {
4040
}
4141

4242
/**
43-
* A partially specified check about an approximate relationship to a {@code double} subject using
44-
* a tolerance.
43+
* A partially specified check about an approximate relationship to a {@code double} value using a
44+
* tolerance.
4545
*/
4646
public abstract static class TolerantDoubleComparison {
4747

4848
// Prevent subclassing outside of this class
4949
private TolerantDoubleComparison() {}
5050

5151
/**
52-
* Fails if the subject was expected to be within the tolerance of the given value but was not
53-
* <i>or</i> if it was expected <i>not</i> to be within the tolerance but was. The subject and
54-
* tolerance are specified earlier in the fluent call chain.
52+
* Fails if the actual value was expected to be within the tolerance of the given value but was
53+
* not <i>or</i> if it was expected <i>not</i> to be within the tolerance but was. The actual
54+
* value and tolerance are specified earlier in the fluent call chain.
5555
*/
5656
public abstract void of(double expected);
5757

@@ -79,13 +79,13 @@ public int hashCode() {
7979
}
8080

8181
/**
82-
* Prepares for a check that the subject is a finite number within the given tolerance of an
82+
* Prepares for a check that the actual value is a finite number within the given tolerance of an
8383
* expected value that will be provided in the next call in the fluent chain.
8484
*
85-
* <p>The check will fail if either the subject or the object is {@link Double#POSITIVE_INFINITY},
86-
* {@link Double#NEGATIVE_INFINITY}, or {@link Double#NaN}. To check for those values, use {@link
87-
* #isPositiveInfinity}, {@link #isNegativeInfinity}, {@link #isNaN}, or (with more generality)
88-
* {@link #isEqualTo}.
85+
* <p>The check will fail if either the actual value or the expected value is {@link
86+
* Double#POSITIVE_INFINITY}, {@link Double#NEGATIVE_INFINITY}, or {@link Double#NaN}. To check
87+
* for those values, use {@link #isPositiveInfinity}, {@link #isNegativeInfinity}, {@link #isNaN},
88+
* or (with more generality) {@link #isEqualTo}.
8989
*
9090
* <p>The check will pass if both values are zero, even if one is {@code 0.0} and the other is
9191
* {@code -0.0}. Use {@link #isEqualTo} to assert that a value is exactly {@code 0.0} or that it
@@ -96,9 +96,9 @@ public int hashCode() {
9696
* and {@code -0.0}). See the documentation on {@link #isEqualTo} for advice on when exact
9797
* equality assertions are appropriate.
9898
*
99-
* @param tolerance an inclusive upper bound on the difference between the subject and object
100-
* allowed by the check, which must be a non-negative finite value, i.e. not {@link
101-
* Double#NaN}, {@link Double#POSITIVE_INFINITY}, or negative, including {@code -0.0}
99+
* @param tolerance an inclusive upper bound on the difference between the actual value and
100+
* expected value allowed by the check, which must be a non-negative finite value, i.e. not
101+
* {@link Double#NaN}, {@link Double#POSITIVE_INFINITY}, or negative, including {@code -0.0}
102102
*/
103103
public TolerantDoubleComparison isWithin(double tolerance) {
104104
return new TolerantDoubleComparison() {
@@ -120,12 +120,12 @@ public void of(double expected) {
120120
}
121121

122122
/**
123-
* Prepares for a check that the subject is a finite number not within the given tolerance of an
124-
* expected value that will be provided in the next call in the fluent chain.
123+
* Prepares for a check that the actual value is a finite number not within the given tolerance of
124+
* an expected value that will be provided in the next call in the fluent chain.
125125
*
126-
* <p>The check will fail if either the subject or the object is {@link Double#POSITIVE_INFINITY},
127-
* {@link Double#NEGATIVE_INFINITY}, or {@link Double#NaN}. See {@link #isFinite}, {@link
128-
* #isNotNaN}, or {@link #isNotEqualTo} for checks with other behaviours.
126+
* <p>The check will fail if either the actual value or the expected value is {@link
127+
* Double#POSITIVE_INFINITY}, {@link Double#NEGATIVE_INFINITY}, or {@link Double#NaN}. See {@link
128+
* #isFinite}, {@link #isNotNaN}, or {@link #isNotEqualTo} for checks with other behaviours.
129129
*
130130
* <p>The check will fail if both values are zero, even if one is {@code 0.0} and the other is
131131
* {@code -0.0}. Use {@link #isNotEqualTo} for a test which fails for a value of exactly zero with
@@ -135,9 +135,9 @@ public void of(double expected) {
135135
* but sometimes {@link #isNotEqualTo} is preferable (note the different behaviours around
136136
* non-finite values and {@code -0.0}).
137137
*
138-
* @param tolerance an exclusive lower bound on the difference between the subject and object
139-
* allowed by the check, which must be a non-negative finite value, i.e. not {@code
140-
* Double.NaN}, {@code Double.POSITIVE_INFINITY}, or negative, including {@code -0.0}
138+
* @param tolerance an exclusive lower bound on the difference between the actual value and
139+
* expected value allowed by the check, which must be a non-negative finite value, i.e. not
140+
* {@code Double.NaN}, {@code Double.POSITIVE_INFINITY}, or negative, including {@code -0.0}
141141
*/
142142
public TolerantDoubleComparison isNotWithin(double tolerance) {
143143
return new TolerantDoubleComparison() {
@@ -159,7 +159,7 @@ public void of(double expected) {
159159
}
160160

161161
/**
162-
* Asserts that the subject is exactly equal to the given value, with equality defined as by
162+
* Asserts that the actual value is exactly equal to the given value, with equality defined as by
163163
* {@code Double#equals}. This method is <i>not</i> recommended when the code under test is doing
164164
* any kind of arithmetic: use {@link #isWithin} with a suitable tolerance in that case. (Remember
165165
* that the exact result of floating point arithmetic is sensitive to apparently trivial changes
@@ -179,9 +179,9 @@ public void isEqualTo(@Nullable Object other) {
179179
}
180180

181181
/**
182-
* Asserts that the subject is not exactly equal to the given value, with equality defined as by
183-
* {@code Double#equals}. See {@link #isEqualTo} for advice on when exact equality is recommended.
184-
* Use {@link #isNotWithin} for an assertion with a tolerance.
182+
* Asserts that the actual value is not exactly equal to the given value, with equality defined as
183+
* by {@code Double#equals}. See {@link #isEqualTo} for advice on when exact equality is
184+
* recommended. Use {@link #isNotWithin} for an assertion with a tolerance.
185185
*
186186
* <p><b>Note:</b> The assertion {@code isNotEqualTo(0.0)} passes for {@code -0.0}, and vice
187187
* versa. For an assertion that fails for either {@code 0.0} or {@code -0.0}, use {@link
@@ -201,15 +201,15 @@ public void isEquivalentAccordingToCompareTo(@Nullable Double other) {
201201
super.isEquivalentAccordingToCompareTo(other);
202202
}
203203

204-
/** Asserts that the subject is zero (i.e. it is either {@code 0.0} or {@code -0.0}). */
204+
/** Asserts that the actual value is zero (i.e. it is either {@code 0.0} or {@code -0.0}). */
205205
public void isZero() {
206206
if (actual == null || actual != 0.0) {
207207
failWithActual(simpleFact("expected zero"));
208208
}
209209
}
210210

211211
/**
212-
* Asserts that the subject is a non-null value other than zero (i.e. it is not {@code 0.0},
212+
* Asserts that the actual value is a non-null value other than zero (i.e. it is not {@code 0.0},
213213
* {@code -0.0} or {@code null}).
214214
*/
215215
public void isNonZero() {
@@ -220,23 +220,23 @@ public void isNonZero() {
220220
}
221221
}
222222

223-
/** Asserts that the subject is {@link Double#POSITIVE_INFINITY}. */
223+
/** Asserts that the actual value is {@link Double#POSITIVE_INFINITY}. */
224224
public void isPositiveInfinity() {
225225
isEqualTo(Double.POSITIVE_INFINITY);
226226
}
227227

228-
/** Asserts that the subject is {@link Double#NEGATIVE_INFINITY}. */
228+
/** Asserts that the actual value is {@link Double#NEGATIVE_INFINITY}. */
229229
public void isNegativeInfinity() {
230230
isEqualTo(Double.NEGATIVE_INFINITY);
231231
}
232232

233-
/** Asserts that the subject is {@link Double#NaN}. */
233+
/** Asserts that the actual value is {@link Double#NaN}. */
234234
public void isNaN() {
235235
isEqualTo(NaN);
236236
}
237237

238238
/**
239-
* Asserts that the subject is finite, i.e. not {@link Double#POSITIVE_INFINITY}, {@link
239+
* Asserts that the actual value is finite, i.e. not {@link Double#POSITIVE_INFINITY}, {@link
240240
* Double#NEGATIVE_INFINITY}, or {@link Double#NaN}.
241241
*/
242242
public void isFinite() {
@@ -246,7 +246,7 @@ public void isFinite() {
246246
}
247247

248248
/**
249-
* Asserts that the subject is a non-null value other than {@link Double#NaN} (but it may be
249+
* Asserts that the actual value is a non-null value other than {@link Double#NaN} (but it may be
250250
* {@link Double#POSITIVE_INFINITY} or {@link Double#NEGATIVE_INFINITY}).
251251
*/
252252
public void isNotNaN() {
@@ -258,39 +258,39 @@ public void isNotNaN() {
258258
}
259259

260260
/**
261-
* Checks that the subject is greater than {@code other}.
261+
* Checks that the actual value is greater than {@code other}.
262262
*
263-
* <p>To check that the subject is greater than <i>or equal to</i> {@code other}, use {@link
263+
* <p>To check that the actual value is greater than <i>or equal to</i> {@code other}, use {@link
264264
* #isAtLeast}.
265265
*/
266266
public void isGreaterThan(int other) {
267267
isGreaterThan((double) other);
268268
}
269269

270270
/**
271-
* Checks that the subject is less than {@code other}.
271+
* Checks that the actual value is less than {@code other}.
272272
*
273-
* <p>To check that the subject is less than <i>or equal to</i> {@code other}, use {@link
273+
* <p>To check that the actual value is less than <i>or equal to</i> {@code other}, use {@link
274274
* #isAtMost} .
275275
*/
276276
public void isLessThan(int other) {
277277
isLessThan((double) other);
278278
}
279279

280280
/**
281-
* Checks that the subject is less than or equal to {@code other}.
281+
* Checks that the actual value is less than or equal to {@code other}.
282282
*
283-
* <p>To check that the subject is <i>strictly</i> less than {@code other}, use {@link
283+
* <p>To check that the actual value is <i>strictly</i> less than {@code other}, use {@link
284284
* #isLessThan}.
285285
*/
286286
public void isAtMost(int other) {
287287
isAtMost((double) other);
288288
}
289289

290290
/**
291-
* Checks that the subject is greater than or equal to {@code other}.
291+
* Checks that the actual value is greater than or equal to {@code other}.
292292
*
293-
* <p>To check that the subject is <i>strictly</i> greater than {@code other}, use {@link
293+
* <p>To check that the actual value is <i>strictly</i> greater than {@code other}, use {@link
294294
* #isGreaterThan}.
295295
*/
296296
public void isAtLeast(int other) {

0 commit comments

Comments
 (0)