Package com.google.common.truth
Class ActualValueInference
- java.lang.Object
-
- com.google.common.truth.ActualValueInference
-
final class ActualValueInference extends java.lang.ObjectGiven 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();containsExactlyorinOrderfails,ActualValueInferencereports (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 ...
ActualValueInferenceaccomplishes 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 classActualValueInference.DescribedEntryAn entry that contains a description of how it was created.(package private) static classActualValueInference.FrameInfoA value class to represent a frame.private static classActualValueInference.InferenceClassVisitorprivate static classActualValueInference.InferenceMethodVisitor(package private) static classActualValueInference.InferredTypeThis is the type used for type inference.(package private) static classActualValueInference.InvocationA method invocation.(package private) static interfaceActualValueInference.Nullable(package private) static classActualValueInference.OpaqueEntryAn entry that we know nothing about except for its type.(package private) static classActualValueInference.StackEntryAn 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 classActualValueInference.SubjectEntry
-
Field Summary
Fields Modifier and Type Field Description private static com.google.common.collect.ImmutableSet<java.lang.String>BORING_NAMESprivate static com.google.common.collect.ImmutableSet<java.lang.String>PRIMITIVE_WRAPPERS
-
Constructor Summary
Constructors Modifier Constructor Description privateActualValueInference()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static voidcloseQuietly(java.io.InputStream stream)(package private) static java.lang.StringdescribeActualValue(java.lang.String className, java.lang.String methodName, int lineNumber)CallPlatform.inferDescription()rather than calling this directly.private static ActualValueInference.StackEntrydescribed(ActualValueInference.InferredType type, java.lang.String description)private static booleanisBoxing(java.lang.String owner, java.lang.String name, java.lang.String desc)private static booleanisSet(int flags, int bitmask)Returnstrueiff all bits inbitmaskare set inflags.private static booleanisStatic(int access)private static booleanisThatOrAssertThat(java.lang.String owner, java.lang.String name)private static ActualValueInference.StackEntryopaque(ActualValueInference.InferredType type)private static ActualValueInference.StackEntrysubjectFor(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)Returnstrueiff all bits inbitmaskare set inflags. Trivially returnstrueifbitmaskis 0.
-
closeQuietly
private static void closeQuietly(java.io.InputStream stream)
-
-