Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private static final class InferenceMethodVisitor extends MethodVisitor {
localVariableSlots = createInitialLocalVariableSlots(access, owner, name, methodDescriptor);
previousFrame =
FrameInfo.create(
ImmutableList.copyOf(localVariableSlots), ImmutableList.<StackEntry>of());
ImmutableList.copyOf(localVariableSlots), ImmutableList.of());
this.methodSignature = owner + "." + name + methodDescriptor;
this.actualValueAtLine = actualValueAtLine;
}
Expand Down Expand Up @@ -894,7 +894,7 @@ public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[
case Opcodes.F_SAME:
// This frame type indicates that the frame has exactly the same local variables as the
// previous frame and that the operand stack is empty.
previousFrame = FrameInfo.create(previousFrame.locals(), ImmutableList.<StackEntry>of());
previousFrame = FrameInfo.create(previousFrame.locals(), ImmutableList.of());
break;
case Opcodes.F_SAME1:
// This frame type indicates that the frame has exactly the same local variables as the
Expand All @@ -908,7 +908,7 @@ public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[
previousFrame =
FrameInfo.create(
appendArrayToList(previousFrame.locals(), nLocal, local),
ImmutableList.<StackEntry>of());
ImmutableList.of());
break;
case Opcodes.F_CHOP:
// This frame type indicates that the frame has the same local variables as the previous
Expand All @@ -917,7 +917,7 @@ public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[
previousFrame =
FrameInfo.create(
removeBackFromList(previousFrame.locals(), nLocal),
ImmutableList.<StackEntry>of());
ImmutableList.of());
break;
case Opcodes.F_FULL:
previousFrame =
Expand Down
18 changes: 9 additions & 9 deletions core/src/main/java/com/google/common/truth/Correspondence.java
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,15 @@ boolean isEquality() {
*/
public abstract boolean compare(A actual, E expected);

private static class StoredException {
private static class StoredExceptionDescritor {

private static final Joiner ARGUMENT_JOINER = Joiner.on(", ").useForNull("null");

private final Exception exception;
private final String methodName;
private final List<Object> methodArguments;

StoredException(Exception exception, String methodName, List<Object> methodArguments) {
StoredExceptionDescritor(Exception exception, String methodName, List<Object> methodArguments) {
this.exception = checkNotNull(exception);
this.methodName = checkNotNull(methodName);
this.methodArguments = checkNotNull(methodArguments);
Expand All @@ -552,9 +552,9 @@ private String describe() {
static final class ExceptionStore {

private final String argumentLabel;
private StoredException firstCompareException = null;
private StoredException firstPairingException = null;
private StoredException firstFormatDiffException = null;
private StoredExceptionDescritor firstCompareException = null;
private StoredExceptionDescritor firstPairingException = null;
private StoredExceptionDescritor firstFormatDiffException = null;

static ExceptionStore forIterable() {
return new ExceptionStore("elements");
Expand Down Expand Up @@ -583,7 +583,7 @@ void addCompareException(
Class<?> callingClass, Exception exception, Object actual, Object expected) {
if (firstCompareException == null) {
truncateStackTrace(exception, callingClass);
firstCompareException = new StoredException(exception, "compare", asList(actual, expected));
firstCompareException = new StoredExceptionDescritor(exception, "compare", asList(actual, expected));
}
}

Expand All @@ -601,7 +601,7 @@ void addActualKeyFunctionException(Class<?> callingClass, Exception exception, O
if (firstPairingException == null) {
truncateStackTrace(exception, callingClass);
firstPairingException =
new StoredException(exception, "actualKeyFunction.apply", asList(actual));
new StoredExceptionDescritor(exception, "actualKeyFunction.apply", asList(actual));
}
}

Expand All @@ -620,7 +620,7 @@ void addExpectedKeyFunctionException(
if (firstPairingException == null) {
truncateStackTrace(exception, callingClass);
firstPairingException =
new StoredException(exception, "expectedKeyFunction.apply", asList(expected));
new StoredExceptionDescritor(exception, "expectedKeyFunction.apply", asList(expected));
}
}

Expand All @@ -640,7 +640,7 @@ void addFormatDiffException(
if (firstFormatDiffException == null) {
truncateStackTrace(exception, callingClass);
firstFormatDiffException =
new StoredException(exception, "formatDiff", asList(actual, expected));
new StoredExceptionDescritor(exception, "formatDiff", asList(actual, expected));
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/com/google/common/truth/Expect.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,6 @@ public void evaluate() throws Throwable {
enum TestPhase {
BEFORE,
DURING,
AFTER;
AFTER
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
public final class FailureMetadata {
static FailureMetadata forFailureStrategy(FailureStrategy failureStrategy) {
return new FailureMetadata(
failureStrategy, ImmutableList.<LazyMessage>of(), ImmutableList.<Step>of());
failureStrategy, ImmutableList.of(), ImmutableList.of());
}

private final FailureStrategy strategy;
Expand Down Expand Up @@ -153,7 +153,7 @@ FailureMetadata updateForCheckCall(
*/
enum OldAndNewValuesAreSimilar {
SIMILAR,
DIFFERENT;
DIFFERENT
}

/**
Expand Down Expand Up @@ -247,7 +247,7 @@ private ImmutableList<Fact> description() {
}
return descriptionIsInteresting
? ImmutableList.of(fact("value of", description))
: ImmutableList.<Fact>of();
: ImmutableList.of();
}

/**
Expand Down Expand Up @@ -312,7 +312,7 @@ private ImmutableList<Fact> rootUnlessThrowable() {
// TODO(cpovirk): Use inferDescription() here when appropriate? But it can be long.
rootSubject.subject.typeDescription() + " was",
rootSubject.subject.actualCustomStringRepresentationForPackageMembersToCall()))
: ImmutableList.<Fact>of();
: ImmutableList.of();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ private static boolean containsEmptyOrLong(Iterable<Multiset.Entry<?>> entries)
*/
enum ElementFactGrouping {
ALL_IN_ONE_FACT,
FACT_PER_ELEMENT;
FACT_PER_ELEMENT
}

/**
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/com/google/common/truth/MathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static boolean equalWithinTolerance(double left, double right, double tol
* either {@code left} or {@code right} is infinite or NaN.
*/
public static boolean equalWithinTolerance(float left, float right, float tolerance) {
return equalWithinTolerance((double) left, (double) right, (double) tolerance);
return equalWithinTolerance(left, right, (double) tolerance);
}

/**
Expand All @@ -59,6 +59,6 @@ public static boolean notEqualWithinTolerance(double left, double right, double
* either {@code left} or {@code right} is infinite or NaN.
*/
public static boolean notEqualWithinTolerance(float left, float right, float tolerance) {
return notEqualWithinTolerance((double) left, (double) right, (double) tolerance);
return notEqualWithinTolerance(left, right, (double) tolerance);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ private static <V> Collection<V> get(Multimap<?, V> multimap, @Nullable Object k
}

private static List<?> difference(List<?> minuend, List<?> subtrahend) {
LinkedHashMultiset<Object> remaining = LinkedHashMultiset.<Object>create(subtrahend);
LinkedHashMultiset<Object> remaining = LinkedHashMultiset.create(subtrahend);
List<Object> difference = Lists.newArrayList();
for (Object elem : minuend) {
if (!remaining.remove(elem)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final class MultisetSubject extends IterableSubject {
/** Fails if the element does not have the given count. */
public final void hasCount(@Nullable Object element, int expectedCount) {
checkArgument(expectedCount >= 0, "expectedCount(%s) must be >= 0", expectedCount);
int actualCount = ((Multiset<?>) actual).count(element);
int actualCount = actual.count(element);
check("count(%s)", element).that(actualCount).isEqualTo(expectedCount);
}
}
3 changes: 1 addition & 2 deletions core/src/main/java/com/google/common/truth/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ static AssertionError makeComparisonFailure(
}

private static LinkageError newLinkageError(Throwable cause) {
LinkageError error = new LinkageError(cause.toString());
error.initCause(cause);
LinkageError error = new LinkageError(cause.toString(), cause);
return error;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class StackTraceCleaner {
* the bottom. Collapses the frames for various frameworks in the middle of the trace as well.
*/
static void cleanStackTrace(Throwable throwable) {
new StackTraceCleaner(throwable).clean(Sets.<Throwable>newIdentityHashSet());
new StackTraceCleaner(throwable).clean(Sets.newIdentityHashSet());
}

private final Throwable throwable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public final <CustomSubjectBuilderT extends CustomSubjectBuilder> CustomSubjectB
* {@link Truth#assertWithMessage}).
*/
public final void fail() {
metadata().fail(ImmutableList.<Fact>of());
metadata().fail(ImmutableList.of());
}

private FailureMetadata metadata() {
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/com/google/common/truth/Subject.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void fail(AssertionError failure) {}

private final FailureMetadata metadata;
private final Object actual;
private String customName = null;
private final String customName = null;
private final @Nullable String typeDescriptionOverride;

/**
Expand Down Expand Up @@ -255,7 +255,7 @@ private static boolean isIntegralBoxedPrimitive(@Nullable Object o) {

private static long integralValue(Object o) {
if (o instanceof Character) {
return (long) ((Character) o).charValue();
return ((Character) o).charValue();
} else if (o instanceof Number) {
return ((Number) o).longValue();
} else {
Expand Down Expand Up @@ -489,7 +489,7 @@ static ComparisonResult differentNoDescription() {

private static final ComparisonResult EQUAL = new ComparisonResult(null);
private static final ComparisonResult DIFFERENT_NO_DESCRIPTION =
new ComparisonResult(ImmutableList.<Fact>of());
new ComparisonResult(ImmutableList.of());

private final @Nullable ImmutableList<Fact> facts;

Expand All @@ -502,7 +502,7 @@ boolean valuesAreEqual() {
}

ImmutableList<Fact> factsOrEmpty() {
return firstNonNull(facts, ImmutableList.<Fact>of());
return firstNonNull(facts, ImmutableList.of());
}

/** Returns an instance with the same "equal"/"not-equal" bit but with no description. */
Expand Down Expand Up @@ -1193,7 +1193,7 @@ private ImmutableList<Fact> prependNameIfAny(ImmutableList<Fact> facts) {

private ImmutableList<Fact> nameAsFacts() {
return customName == null
? ImmutableList.<Fact>of()
? ImmutableList.of()
: ImmutableList.of(fact("name", customName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static DuplicateGroupedAndTyped countDuplicatesAndMaybeAddTypeInfoReturnObject(
} else {
return new DuplicateGroupedAndTyped(
countDuplicatesToMultiset(itemsIterable),
/* homogeneousTypeToDisplay= */ Optional.<String>absent());
/* homogeneousTypeToDisplay= */ Optional.absent());
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/com/google/common/truth/TableSubject.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void doesNotContain(@Nullable Object rowKey, @Nullable Object columnKey)
/** Fails if the table does not contain the given cell. */
public void containsCell(
@Nullable Object rowKey, @Nullable Object colKey, @Nullable Object value) {
containsCell(Tables.<Object, Object, Object>immutableCell(rowKey, colKey, value));
containsCell(Tables.immutableCell(rowKey, colKey, value));
}

/** Fails if the table does not contain the given cell. */
Expand All @@ -86,7 +86,7 @@ public void containsCell(Cell<?, ?, ?> cell) {
/** Fails if the table contains the given cell. */
public void doesNotContainCell(
@Nullable Object rowKey, @Nullable Object colKey, @Nullable Object value) {
doesNotContainCell(Tables.<Object, Object, Object>immutableCell(rowKey, colKey, value));
doesNotContainCell(Tables.immutableCell(rowKey, colKey, value));
}

/** Fails if the table contains the given cell. */
Expand Down
14 changes: 7 additions & 7 deletions core/src/test/java/com/google/common/truth/FactTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,52 +41,52 @@ public void stringWithoutValue() {

@Test
public void oneFacts() {
assertThat(makeMessage(ImmutableList.<String>of(), ImmutableList.of(fact("foo", "bar"))))
assertThat(makeMessage(ImmutableList.of(), ImmutableList.of(fact("foo", "bar"))))
.isEqualTo("foo: bar");
}

@Test
public void twoFacts() {
assertThat(
makeMessage(
ImmutableList.<String>of(),
ImmutableList.of(),
ImmutableList.of(fact("foo", "bar"), fact("longer name", "other value"))))
.isEqualTo("foo : bar\nlonger name: other value");
}

@Test
public void oneFactWithoutValue() {
assertThat(makeMessage(ImmutableList.<String>of(), ImmutableList.of(simpleFact("foo"))))
assertThat(makeMessage(ImmutableList.of(), ImmutableList.of(simpleFact("foo"))))
.isEqualTo("foo");
}

@Test
public void twoFactsOneWithoutValue() {
assertThat(
makeMessage(
ImmutableList.<String>of(),
ImmutableList.of(),
ImmutableList.of(fact("hello", "there"), simpleFact("foo"))))
.isEqualTo("hello: there\nfoo");
}

@Test
public void newline() {
assertThat(makeMessage(ImmutableList.<String>of(), ImmutableList.of(fact("foo", "bar\nbaz"))))
assertThat(makeMessage(ImmutableList.of(), ImmutableList.of(fact("foo", "bar\nbaz"))))
.isEqualTo("foo:\n bar\n baz");
}

@Test
public void newlineWithoutValue() {
assertThat(
makeMessage(
ImmutableList.<String>of(),
ImmutableList.of(),
ImmutableList.of(fact("hello", "there\neveryone"), simpleFact("xyz"))))
.isEqualTo("hello:\n there\n everyone\nxyz");
}

@Test
public void withMessage() {
assertThat(makeMessage(ImmutableList.<String>of("hello"), ImmutableList.of(fact("foo", "bar"))))
assertThat(makeMessage(ImmutableList.of("hello"), ImmutableList.of(fact("foo", "bar"))))
.isEqualTo("hello\nfoo: bar");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private static class TestInstance {

/** Generates a test instance with an empty bipartite graph. */
static TestInstance empty() {
return new TestInstance(ImmutableListMultimap.<String, String>of());
return new TestInstance(ImmutableListMultimap.of());
}

/**
Expand Down
Loading