Package com.google.common.truth
Class ActualValueInference
- java.lang.Object
-
- com.google.common.truth.ActualValueInference
-
final class ActualValueInference extends java.lang.Object
Given the stack frame of a failing assertion, tries to describe what the user passed toassertThat
.For example, suppose that the test contains:
If eitherassertThat(logService.fetchLogMessages(startDate, endDate)) .containsExactly(message1, message2) .inOrder();
containsExactly
orinOrder
fails,ActualValueInference
reports (if the rest of the test method is simple enough to analyze easily) that the user passedfetchLogMessages(...)
. This allows us to produce a failure message like:value of : fetchLogMessages(...) missing (1): message1 ...
ActualValueInference
accomplishes this by examining the bytecode of the test. Naturally, this is all best-effort.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ActualValueInference.DescribedEntry
An entry that contains a description of how it was created.(package private) static class
ActualValueInference.FrameInfo
A value class to represent a frame.private static class
ActualValueInference.InferenceClassVisitor
private static class
ActualValueInference.InferenceMethodVisitor
(package private) static class
ActualValueInference.InferredType
This is the type used for type inference.(package private) static class
ActualValueInference.Invocation
A method invocation.(package private) static interface
ActualValueInference.Nullable
(package private) static class
ActualValueInference.OpaqueEntry
An entry that we know nothing about except for its type.(package private) static class
ActualValueInference.StackEntry
An entry on the stack (or the local-variable table) with a type and sometimes a description of how the value was produced or, as a special case, whether the value is a Truth subject.(package private) static class
ActualValueInference.SubjectEntry
-
Field Summary
Fields Modifier and Type Field Description private static com.google.common.collect.ImmutableSet<java.lang.String>
BORING_NAMES
private static com.google.common.collect.ImmutableSet<java.lang.String>
PRIMITIVE_WRAPPERS
-
Constructor Summary
Constructors Modifier Constructor Description private
ActualValueInference()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
closeQuietly(java.io.InputStream stream)
(package private) static java.lang.String
describeActualValue(java.lang.String className, java.lang.String methodName, int lineNumber)
CallPlatform.inferDescription()
rather than calling this directly.private static ActualValueInference.StackEntry
described(ActualValueInference.InferredType type, java.lang.String description)
private static boolean
isBoxing(java.lang.String owner, java.lang.String name, java.lang.String desc)
private static boolean
isSet(int flags, int bitmask)
Returnstrue
iff all bits inbitmask
are set inflags
.private static boolean
isStatic(int access)
private static boolean
isThatOrAssertThat(java.lang.String owner, java.lang.String name)
private static ActualValueInference.StackEntry
opaque(ActualValueInference.InferredType type)
private static ActualValueInference.StackEntry
subjectFor(ActualValueInference.InferredType type, ActualValueInference.StackEntry actual)
-
-
-
Method Detail
-
describeActualValue
static java.lang.String describeActualValue(java.lang.String className, java.lang.String methodName, int lineNumber)
CallPlatform.inferDescription()
rather than calling this directly.
-
opaque
private static ActualValueInference.StackEntry opaque(ActualValueInference.InferredType type)
-
described
private static ActualValueInference.StackEntry described(ActualValueInference.InferredType type, java.lang.String description)
-
subjectFor
private static ActualValueInference.StackEntry subjectFor(ActualValueInference.InferredType type, ActualValueInference.StackEntry actual)
-
isThatOrAssertThat
private static boolean isThatOrAssertThat(java.lang.String owner, java.lang.String name)
-
isBoxing
private static boolean isBoxing(java.lang.String owner, java.lang.String name, java.lang.String desc)
-
isStatic
private static boolean isStatic(int access)
-
isSet
private static boolean isSet(int flags, int bitmask)
Returnstrue
iff all bits inbitmask
are set inflags
. Trivially returnstrue
ifbitmask
is 0.
-
closeQuietly
private static void closeQuietly(java.io.InputStream stream)
-
-