code stringlengths 23 201k | docstring stringlengths 17 96.2k | func_name stringlengths 0 235 | language stringclasses 1
value | repo stringlengths 8 72 | path stringlengths 11 317 | url stringlengths 57 377 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
static @Nullable String describeActualValue(String className, String methodName, int lineNumber) {
InferenceClassVisitor visitor;
try {
// TODO(cpovirk): Verify that methodName is correct for constructors and static initializers.
visitor = new InferenceClassVisitor(methodName);
} catch (IllegalA... | <b>Call {@link Platform#inferDescription} rather than calling this directly.</b> | describeActualValue | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
boolean isSubject() {
return false;
} | An entry on the stack (or the local-variable table) with a {@linkplain InferredType type} and
sometimes a description of {@linkplain DescribedEntry how the value was produced} or, as a
special case, whether {@linkplain SubjectEntry the value is a Truth subject}. | isSubject | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
StackEntry actualValue() {
throw new ClassCastException(getClass().getName());
} | An entry on the stack (or the local-variable table) with a {@linkplain InferredType type} and
sometimes a description of {@linkplain DescribedEntry how the value was produced} or, as a
special case, whether {@linkplain SubjectEntry the value is a Truth subject}. | actualValue | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Nullable String description() {
return null;
} | An entry on the stack (or the local-variable table) with a {@linkplain InferredType type} and
sometimes a description of {@linkplain DescribedEntry how the value was produced} or, as a
special case, whether {@linkplain SubjectEntry the value is a Truth subject}. | description | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public final String toString() {
return "unknown";
} | An entry that we know nothing about except for its type. | toString | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static StackEntry opaque(InferredType type) {
return new AutoValue_ActualValueInference_OpaqueEntry(type);
} | An entry that we know nothing about except for its type. | opaque | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public final String toString() {
return description();
} | An entry that contains a description of how it was created. Currently, the only case in which
we provide a description is when the value comes from a method call whose name looks
"interesting." | toString | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static StackEntry described(InferredType type, String description) {
return new AutoValue_ActualValueInference_DescribedEntry(type, description);
} | An entry that contains a description of how it was created. Currently, the only case in which
we provide a description is when the value comes from a method call whose name looks
"interesting." | described | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
final boolean isSubject() {
return true;
} | An entry for a {@link Subject} (or a similar object derived with a {@code Subject}, like {@link
Ordered}).
<p>The entry contains the "root actual value" of the assertion. In an assertion like {@code
assertThat(e).hasMessageThat().contains("foo")}, the root actual value is the {@code Throwable}
{@code e}, even though t... | isSubject | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public final String toString() {
return String.format("subjectFor(%s)", actualValue());
} | An entry for a {@link Subject} (or a similar object derived with a {@code Subject}, like {@link
Ordered}).
<p>The entry contains the "root actual value" of the assertion. In an assertion like {@code
assertThat(e).hasMessageThat().contains("foo")}, the root actual value is the {@code Throwable}
{@code e}, even though t... | toString | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static StackEntry subjectFor(InferredType type, StackEntry actual) {
return new AutoValue_ActualValueInference_SubjectEntry(type, actual);
} | An entry for a {@link Subject} (or a similar object derived with a {@code Subject}, like {@link
Ordered}).
<p>The entry contains the "root actual value" of the assertion. In an assertion like {@code
assertThat(e).hasMessageThat().contains("foo")}, the root actual value is the {@code Throwable}
{@code e}, even though t... | subjectFor | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitCode() {
checkState(!used, "Cannot reuse this method visitor.");
used = true;
super.visitCode();
} | The output of this process: a mapping from line number to the root actual values with
assertions on that line. This builder is potentially shared across multiple method visitors
for the same class visitor. | visitCode | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitEnd() {
if (seenJump) {
/*
* If there are multiple paths through a method, we'd have to examine them all and make sure
* that the values still match up. We could try someday, but it's hard.
*/
super.visitEnd();
return;
}
... | The output of this process: a mapping from line number to the root actual values with
assertions on that line. This builder is potentially shared across multiple method visitors
for the same class visitor. | visitEnd | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static ImmutableSet<Integer> lineNumbers(
ImmutableList<Label> labels, ImmutableSetMultimap<Label, Integer> lineNumbersAtLabel) {
for (Label label : labels.reverse()) {
if (lineNumbersAtLabel.containsKey(label)) {
return lineNumbersAtLabel.get(label);
}
}
retu... | The output of this process: a mapping from line number to the root actual values with
assertions on that line. This builder is potentially shared across multiple method visitors
for the same class visitor. | lineNumbers | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitLineNumber(int line, Label start) {
lineNumbersAtLabel.put(start, line);
super.visitLineNumber(line, start);
} | The output of this process: a mapping from line number to the root actual values with
assertions on that line. This builder is potentially shared across multiple method visitors
for the same class visitor. | visitLineNumber | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitLabel(Label label) {
labelsSeen.add(label);
super.visitLabel(label);
} | The output of this process: a mapping from line number to the root actual values with
assertions on that line. This builder is potentially shared across multiple method visitors
for the same class visitor. | visitLabel | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private StackEntry getOperandFromTop(int offsetFromTop) {
int index = operandStack.size() - 1 - offsetFromTop;
checkState(
index >= 0,
"Invalid offset %s in the list of size %s. The current method is %s",
offsetFromTop,
operandStack.size(),
methodSignature);... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | getOperandFromTop | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitInsn(int opcode) {
switch (opcode) {
case Opcodes.NOP:
case Opcodes.INEG:
case Opcodes.LNEG:
case Opcodes.FNEG:
case Opcodes.DNEG:
case Opcodes.I2B:
case Opcodes.I2C:
case Opcodes.I2S:
case Opcodes.RETURN:
... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitIntInsn(int opcode, int operand) {
switch (opcode) {
case Opcodes.BIPUSH:
case Opcodes.SIPUSH:
push(InferredType.INT);
break;
case Opcodes.NEWARRAY:
pop();
switch (operand) {
case Opcodes.T_BOOLEAN:
... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitIntInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitVarInsn(int opcode, int var) {
switch (opcode) {
case Opcodes.ILOAD:
push(InferredType.INT);
break;
case Opcodes.LLOAD:
push(InferredType.LONG);
push(InferredType.TOP);
break;
case Opcodes.FLOAD:
pus... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitVarInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitTypeInsn(int opcode, String type) {
String descriptor = convertToDescriptor(type);
switch (opcode) {
case Opcodes.NEW:
// This should be UNINITIALIZED(label). Okay for type inference.
pushDescriptor(descriptor);
break;
case Opcodes... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitTypeInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
switch (opcode) {
case Opcodes.GETSTATIC:
pushDescriptor(desc);
break;
case Opcodes.PUTSTATIC:
popDescriptor(desc);
break;
case Opcodes.GETFIELD:
... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitFieldInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
if (opcode == Opcodes.INVOKESPECIAL && name.equals("<init>")) {
int argumentSize = (Type.getArgumentsAndReturnSizes(desc) >> 2);
InferredType receiverType = getOperandFromTop(argumentSize -... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitMethodInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) {
popDescriptor(desc);
pushDescriptor(desc);
super.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
} | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitInvokeDynamicInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitJumpInsn(int opcode, Label label) {
seenJump = true;
switch (opcode) {
case Opcodes.IFEQ:
case Opcodes.IFNE:
case Opcodes.IFLT:
case Opcodes.IFGE:
case Opcodes.IFGT:
case Opcodes.IFLE:
pop();
break;
ca... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitJumpInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitLdcInsn(Object cst) {
if (cst instanceof Integer) {
push(InferredType.INT);
} else if (cst instanceof Float) {
push(InferredType.FLOAT);
} else if (cst instanceof Long) {
push(InferredType.LONG);
push(InferredType.TOP);
} else if (cs... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitLdcInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitIincInsn(int var, int increment) {
setLocalVariable(var, opaque(InferredType.INT));
super.visitIincInsn(var, increment);
} | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitIincInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) {
seenJump = true;
pop();
super.visitTableSwitchInsn(min, max, dflt, labels);
} | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitTableSwitchInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
seenJump = true;
pop();
super.visitLookupSwitchInsn(dflt, keys, labels);
} | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitLookupSwitchInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
/*
* Inference already fails for at least some try-catch blocks, apparently because of the extra
* frames they create. Still, let's disable inference explicitly.
*/
seenJump = true;
... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitTryCatchBlock | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitMultiANewArrayInsn(String desc, int dims) {
pop(dims);
pushDescriptor(desc);
super.visitMultiANewArrayInsn(desc, dims);
} | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitMultiANewArrayInsn | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
switch (type) {
case Opcodes.F_NEW:
// Expanded form.
previousFrame =
FrameInfo.create(
convertTypesInStackMapFrame(nLocal, local),
... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | visitFrame | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static String convertToDescriptor(String type) {
return (type.length() > 1 && type.charAt(0) != '[') ? 'L' + type + ';' : type;
} | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | convertToDescriptor | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private void replaceUninitializedTypeInStack(InferredType oldType, InferredType newType) {
checkArgument(oldType.isUninitialized(), "The old type is NOT uninitialized. %s", oldType);
for (int i = 0, size = operandStack.size(); i < size; ++i) {
InferredType type = operandStack.get(i).type();
... | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | replaceUninitializedTypeInStack | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private void pushDescriptor(String desc) {
pushDescriptorAndMaybeProcessMethodCall(desc, /* invocation= */ null);
} | Returns the entry for the operand at the specified offset. 0 means the top of the stack. | pushDescriptor | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private void pushDescriptorAndMaybeProcessMethodCall(
String desc, @Nullable Invocation invocation) {
if (invocation != null && invocation.isOnSubjectInstance()) {
actualValueAtLocation.put(
labelsSeen.build(), checkNotNull(invocation.receiver()).actualValue());
}
boolean ... | Pushes entries onto the stack for the given arguments, and, if the descriptor is for a method
call, records the assertion made by that call (if any).
<p>If the descriptor is for a call, this method not only records the assertion made by it (if
any) but also examines its parameters to generate more detailed stack entri... | pushDescriptorAndMaybeProcessMethodCall | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private void pushMaybeDescribed(
InferredType type, @Nullable Invocation invocation, boolean hasParams) {
push(invocation == null ? opaque(type) : invocation.deriveEntry(type, hasParams));
} | Pushes entries onto the stack for the given arguments, and, if the descriptor is for a method
call, records the assertion made by that call (if any).
<p>If the descriptor is for a call, this method not only records the assertion made by it (if
any) but also examines its parameters to generate more detailed stack entri... | pushMaybeDescribed | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@CanIgnoreReturnValue
private StackEntry pop() {
return pop(1);
} | Pushes entries onto the stack for the given arguments, and, if the descriptor is for a method
call, records the assertion made by that call (if any).
<p>If the descriptor is for a call, this method not only records the assertion made by it (if
any) but also examines its parameters to generate more detailed stack entri... | pop | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@CanIgnoreReturnValue
private StackEntry pop(int count) {
checkArgument(
count >= 1, "The count should be at least one: %s (In %s)", count, methodSignature);
checkState(
operandStack.size() >= count,
"There are no enough elements in the stack. count=%s, stack=%s (In %s)",
... | Pop elements from the end of the operand stack, and return the last popped element. | pop | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private void popDescriptor(String desc) {
char c = desc.charAt(0);
switch (c) {
case '(':
int argumentSize = (Type.getArgumentsAndReturnSizes(desc) >> 2) - 1;
if (argumentSize > 0) {
pop(argumentSize);
}
break;
case 'J':
case 'D':
... | Pop elements from the end of the operand stack, and return the last popped element. | popDescriptor | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private StackEntry getLocalVariable(int index) {
checkState(
index < localVariableSlots.size(),
"Cannot find type for var %s in method %s",
index,
methodSignature);
return localVariableSlots.get(index);
} | Pop elements from the end of the operand stack, and return the last popped element. | getLocalVariable | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private void setLocalVariable(int index, StackEntry entry) {
while (localVariableSlots.size() <= index) {
localVariableSlots.add(opaque(InferredType.TOP));
}
localVariableSlots.set(index, entry);
} | Pop elements from the end of the operand stack, and return the last popped element. | setLocalVariable | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private StackEntry top() {
return Iterables.getLast(operandStack);
} | Pop elements from the end of the operand stack, and return the last popped element. | top | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static ArrayList<StackEntry> createInitialLocalVariableSlots(
int access, String ownerClass, String methodName, String methodDescriptor) {
ArrayList<StackEntry> entries = new ArrayList<>();
if (!isStatic(access)) {
// Instance method, and this is the receiver
entries.add(opa... | Create the slots for local variables at the very beginning of the method with the information
of the declaring class and the method descriptor. | createInitialLocalVariableSlots | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static ImmutableList<StackEntry> removeBackFromList(
ImmutableList<StackEntry> list, int countToRemove) {
int origSize = list.size();
int index = origSize - 1;
while (index >= 0 && countToRemove > 0) {
InferredType type = list.get(index).type();
if (type.equals(Inferre... | Create the slots for local variables at the very beginning of the method with the information
of the declaring class and the method descriptor. | removeBackFromList | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private ImmutableList<StackEntry> appendArrayToList(
ImmutableList<StackEntry> list, int size, Object[] array) {
ImmutableList.Builder<StackEntry> builder = ImmutableList.builder();
builder.addAll(list);
for (int i = 0; i < size; ++i) {
InferredType type = convertTypeInStackMapFrame(ar... | Create the slots for local variables at the very beginning of the method with the information
of the declaring class and the method descriptor. | appendArrayToList | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private InferredType convertTypeInStackMapFrame(Object typeInStackMapFrame) {
if (typeInStackMapFrame == Opcodes.TOP) {
return InferredType.TOP;
} else if (typeInStackMapFrame == Opcodes.INTEGER) {
return InferredType.INT;
} else if (typeInStackMapFrame == Opcodes.FLOAT) {
retu... | Convert the type in stack map frame to inference type. | convertTypeInStackMapFrame | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private ImmutableList<StackEntry> convertTypesInStackMapFrame(int size, Object[] array) {
ImmutableList.Builder<StackEntry> builder = ImmutableList.builder();
for (int i = 0; i < size; ++i) {
InferredType type = convertTypeInStackMapFrame(array[i]);
builder.add(opaque(type));
if (typ... | Convert the type in stack map frame to inference type. | convertTypesInStackMapFrame | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
final StackEntry deriveEntry(InferredType type, boolean hasParams) {
if (boxingInput() != null && boxingInput().description() != null) {
return described(type, boxingInput().description());
} else if (actualValue() != null) {
return subjectFor(type, actualValue());
} else if (isOnSubje... | The value being passed to this call if it is a boxing call (e.g., {@code Integer.valueOf}). | deriveEntry | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
final boolean isOnSubjectInstance() {
return receiver() != null && receiver().isSubject();
} | The value being passed to this call if it is a boxing call (e.g., {@code Integer.valueOf}). | isOnSubjectInstance | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
InferredType getElementTypeIfArrayOrThrow() {
String descriptor = descriptor();
checkState(descriptor.charAt(0) == '[', "This type %s is not an array.", this);
return create(descriptor.substring(1));
} | If the type is an array, return the element type. Otherwise, throw an exception. | getElementTypeIfArrayOrThrow | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public void visit(
int version,
int access,
String name,
String signature,
String superName,
String[] interfaces) {
className = name;
} | The method to visit.
<p>We don't really <i>need</i> the method name: We could just visit the whole class, since we
look at data for only the relevant line. But it's nice not to process the whole class,
especially during debugging. (And it might also help avoid triggering any bugs in the
inference code.) | visit | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
@Override
public @Nullable MethodVisitor visitMethod(
int access, String name, String desc, String signature, String[] exceptions) {
/*
* Each InferenceMethodVisitor instance may be used only once. Still, it might seem like we
* can get away with creating a single instance at constructio... | The method to visit.
<p>We don't really <i>need</i> the method name: We could just visit the whole class, since we
look at data for only the relevant line. But it's nice not to process the whole class,
especially during debugging. (And it might also help avoid triggering any bugs in the
inference code.) | visitMethod | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static boolean isThatOrAssertThat(String owner, String name) {
/*
* TODO(cpovirk): Handle CustomSubjectBuilder. That requires looking at the type hierarchy, as
* users always have an instance of a specific subtype. Also keep in mind that the that(...)
* method might accept more than 1 paramet... | The method to visit.
<p>We don't really <i>need</i> the method name: We could just visit the whole class, since we
look at data for only the relevant line. But it's nice not to process the whole class,
especially during debugging. (And it might also help avoid triggering any bugs in the
inference code.) | isThatOrAssertThat | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static boolean isBoxing(String owner, String name, String desc) {
return name.equals("valueOf")
&& PRIMITIVE_WRAPPERS.contains(owner)
/*
* Don't handle valueOf(String s[, int radix]). The valueOf support is really here for
* autoboxing, as in "assertThat(primitive)," not fo... | The method to visit.
<p>We don't really <i>need</i> the method name: We could just visit the whole class, since we
look at data for only the relevant line. But it's nice not to process the whole class,
especially during debugging. (And it might also help avoid triggering any bugs in the
inference code.) | isBoxing | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static boolean isStatic(int access) {
return isSet(access, Opcodes.ACC_STATIC);
} | The method to visit.
<p>We don't really <i>need</i> the method name: We could just visit the whole class, since we
look at data for only the relevant line. But it's nice not to process the whole class,
especially during debugging. (And it might also help avoid triggering any bugs in the
inference code.) | isStatic | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static boolean isSet(int flags, int bitmask) {
return (flags & bitmask) == bitmask;
} | Returns {@code true} iff <b>all</b> bits in {@code bitmask} are set in {@code flags}. Trivially
returns {@code true} if {@code bitmask} is 0. | isSet | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
private static void closeQuietly(@Nullable InputStream stream) {
if (stream == null) {
return;
}
try {
stream.close();
} catch (IOException e) {
// TODO(cpovirk): Log a warning?
}
} | Returns {@code true} iff <b>all</b> bits in {@code bitmask} are set in {@code flags}. Trivially
returns {@code true} if {@code bitmask} is 0. | closeQuietly | java | google/truth | core/src/main/java/com/google/common/truth/ActualValueInference.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ActualValueInference.java | Apache-2.0 |
static AssertionErrorWithFacts create(
ImmutableList<String> messages, ImmutableList<Fact> facts, @Nullable Throwable cause) {
return new AssertionErrorWithFacts(messages, facts, cause);
} | An {@link AssertionError} composed of structured {@link Fact} instances and other string
messages. | create | java | google/truth | core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | Apache-2.0 |
static AssertionError createWithoutFacts(String message, @Nullable Throwable cause) {
return create(ImmutableList.of(message), ImmutableList.of(), cause);
} | An {@link AssertionError} composed of structured {@link Fact} instances and other string
messages. | createWithoutFacts | java | google/truth | core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | Apache-2.0 |
static AssertionError createWithoutFactsOrStack(String message, @Nullable Throwable cause) {
AssertionError error = createWithoutFacts(message, cause);
error.setStackTrace(new StackTraceElement[0]);
return error;
} | An {@link AssertionError} composed of structured {@link Fact} instances and other string
messages. | createWithoutFactsOrStack | java | google/truth | core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | Apache-2.0 |
static AssertionError createWithoutFactsOrStack(String message) {
return createWithoutFactsOrStack(message, /* cause= */ null);
} | An {@link AssertionError} composed of structured {@link Fact} instances and other string
messages. | createWithoutFactsOrStack | java | google/truth | core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | Apache-2.0 |
@Override
public String toString() {
return checkNotNull(getLocalizedMessage());
} | An {@link AssertionError} composed of structured {@link Fact} instances and other string
messages. | toString | java | google/truth | core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | Apache-2.0 |
@Override
public ImmutableList<Fact> facts() {
return facts;
} | An {@link AssertionError} composed of structured {@link Fact} instances and other string
messages. | facts | java | google/truth | core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java | Apache-2.0 |
public void isEqualToIgnoringScale(String expected) {
compareValues(new BigDecimal(expected));
} | Checks that the actual value is equal to the value of the {@link BigDecimal} created from the
expected string (i.e., checks that {@code actual.comparesTo(new BigDecimal(expected)) == 0}).
<p><b>Note:</b> The scale of the BigDecimal is ignored. If you want to compare the values and
the scales, use {@link #isEqualTo(Obj... | isEqualToIgnoringScale | java | google/truth | core/src/main/java/com/google/common/truth/BigDecimalSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/BigDecimalSubject.java | Apache-2.0 |
public void isEqualToIgnoringScale(long expected) {
compareValues(new BigDecimal(expected));
} | Checks that the actual value is equal to the value of the {@link BigDecimal} created from the
expected {@code long} (i.e., checks that {@code actual.comparesTo(new BigDecimal(expected)) ==
0}).
<p><b>Note:</b> The scale of the BigDecimal is ignored. If you want to compare the values and
the scales, use {@link #isEqual... | isEqualToIgnoringScale | java | google/truth | core/src/main/java/com/google/common/truth/BigDecimalSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/BigDecimalSubject.java | Apache-2.0 |
@Override // To express more specific javadoc
public void isEqualTo(@Nullable Object expected) {
super.isEqualTo(expected);
} | Checks that the actual value (including scale) is equal to the given {@link BigDecimal}.
<p><b>Note:</b> If you only want to compare the values of the BigDecimals and not their scales,
use {@link #isEqualToIgnoringScale(BigDecimal)} instead. | isEqualTo | java | google/truth | core/src/main/java/com/google/common/truth/BigDecimalSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/BigDecimalSubject.java | Apache-2.0 |
@Override
public void isEquivalentAccordingToCompareTo(@Nullable BigDecimal expected) {
compareValues(expected);
} | Checks that the actual value is equivalent to the given value according to {@link
Comparable#compareTo}, (i.e., checks that {@code a.comparesTo(b) == 0}). This method behaves
identically to (the more clearly named) {@link #isEqualToIgnoringScale(BigDecimal)}.
<p><b>Note:</b> Do not use this method for checking object ... | isEquivalentAccordingToCompareTo | java | google/truth | core/src/main/java/com/google/common/truth/BigDecimalSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/BigDecimalSubject.java | Apache-2.0 |
private void compareValues(@Nullable BigDecimal expected) {
if (checkNotNull(actual).compareTo(checkNotNull(expected)) != 0) {
failWithoutActual(
numericFact("expected", expected),
numericFact("but was", actual),
simpleFact("(scale is ignored)"));
}
} | Checks that the actual value is equivalent to the given value according to {@link
Comparable#compareTo}, (i.e., checks that {@code a.comparesTo(b) == 0}). This method behaves
identically to (the more clearly named) {@link #isEqualToIgnoringScale(BigDecimal)}.
<p><b>Note:</b> Do not use this method for checking object ... | compareValues | java | google/truth | core/src/main/java/com/google/common/truth/BigDecimalSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/BigDecimalSubject.java | Apache-2.0 |
static Factory<BigDecimalSubject, BigDecimal> bigDecimals() {
return BigDecimalSubject::new;
} | Checks that the actual value is equivalent to the given value according to {@link
Comparable#compareTo}, (i.e., checks that {@code a.comparesTo(b) == 0}). This method behaves
identically to (the more clearly named) {@link #isEqualToIgnoringScale(BigDecimal)}.
<p><b>Note:</b> Do not use this method for checking object ... | bigDecimals | java | google/truth | core/src/main/java/com/google/common/truth/BigDecimalSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/BigDecimalSubject.java | Apache-2.0 |
public void isTrue() {
if (actual == null) {
isEqualTo(true); // fails
} else if (!actual) {
failWithoutActual(simpleFact("expected to be true"));
}
} | Checks that the actual value is {@code true}. | isTrue | java | google/truth | core/src/main/java/com/google/common/truth/BooleanSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/BooleanSubject.java | Apache-2.0 |
public void isFalse() {
if (actual == null) {
isEqualTo(false); // fails
} else if (actual) {
failWithoutActual(simpleFact("expected to be false"));
}
} | Checks that the actual value is {@code false}. | isFalse | java | google/truth | core/src/main/java/com/google/common/truth/BooleanSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/BooleanSubject.java | Apache-2.0 |
static Factory<BooleanSubject, Boolean> booleans() {
return BooleanSubject::new;
} | Checks that the actual value is {@code false}. | booleans | java | google/truth | core/src/main/java/com/google/common/truth/BooleanSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/BooleanSubject.java | Apache-2.0 |
public void isAssignableTo(Class<?> clazz) {
if (actual == null || !clazz.isAssignableFrom(actual)) {
failWithActual("expected to be assignable to", clazz.getName());
}
} | Checks that the actual value is a subclass of the given class. Classes are considered to be
subclasses of themselves. | isAssignableTo | java | google/truth | core/src/main/java/com/google/common/truth/ClassSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ClassSubject.java | Apache-2.0 |
static Factory<ClassSubject, Class<?>> classes() {
return ClassSubject::new;
} | Checks that the actual value is a subclass of the given class. Classes are considered to be
subclasses of themselves. | classes | java | google/truth | core/src/main/java/com/google/common/truth/ClassSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ClassSubject.java | Apache-2.0 |
public final void isIn(@Nullable Range<T> range) {
T actual = actualAsT();
if (range == null) {
failWithoutActual(
simpleFact("could not perform range check because range is null"),
fact("value to test for membership was", actual));
} else if (actual == null || !range.contains(actu... | Checks that the actual value is in {@code range}. | isIn | java | google/truth | core/src/main/java/com/google/common/truth/ComparableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparableSubject.java | Apache-2.0 |
public final void isNotIn(@Nullable Range<T> range) {
T actual = actualAsT();
if (range == null) {
failWithoutActual(
simpleFact("could not perform range check because range is null"),
fact("value to test for membership was", actual));
} else if (actual == null) {
failWithAct... | Checks that the actual value is <i>not</i> in {@code range}. | isNotIn | java | google/truth | core/src/main/java/com/google/common/truth/ComparableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparableSubject.java | Apache-2.0 |
public void isEquivalentAccordingToCompareTo(@Nullable T expected) {
Comparable<Object> actual = actualAsComparable();
if (expected == null) {
failWithoutActual(
simpleFact(
"expected a value equivalent to null according to compareTo, but compareTo is"
+ " require... | Checks that the actual value is equivalent to {@code other} according to {@link
Comparable#compareTo}, (i.e., checks that {@code a.comparesTo(b) == 0}).
<p><b>Note:</b> Do not use this method for checking object equality. Instead, use {@link
#isEqualTo(Object)}. | isEquivalentAccordingToCompareTo | java | google/truth | core/src/main/java/com/google/common/truth/ComparableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparableSubject.java | Apache-2.0 |
public final void isGreaterThan(@Nullable T other) {
Comparable<Object> actual = actualAsComparable();
if (other == null) {
failWithoutActual(
simpleFact(
"expected a value greater than null according to compareTo, but compareTo is required"
+ " to reject null"),
... | Checks that the actual value is greater than {@code other}.
<p>To check that the actual value is greater than <i>or equal to</i> {@code other}, use {@link
#isAtLeast}. | isGreaterThan | java | google/truth | core/src/main/java/com/google/common/truth/ComparableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparableSubject.java | Apache-2.0 |
public final void isLessThan(@Nullable T other) {
Comparable<Object> actual = actualAsComparable();
if (other == null) {
failWithoutActual(
simpleFact(
"expected a value less than null according to compareTo, but compareTo is required to"
+ " reject null"),
... | Checks that the actual value is less than {@code other}.
<p>To check that the actual value is less than <i>or equal to</i> {@code other}, use {@link
#isAtMost}. | isLessThan | java | google/truth | core/src/main/java/com/google/common/truth/ComparableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparableSubject.java | Apache-2.0 |
public final void isAtMost(@Nullable T other) {
Comparable<Object> actual = actualAsComparable();
if (other == null) {
failWithoutActual(
simpleFact(
"expected a value that is at most null according to compareTo, but compareTo is"
+ " required to reject null"),
... | Checks that the actual value is less than or equal to {@code other}.
<p>To check that the actual value is <i>strictly</i> less than {@code other}, use {@link
#isLessThan}. | isAtMost | java | google/truth | core/src/main/java/com/google/common/truth/ComparableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparableSubject.java | Apache-2.0 |
public final void isAtLeast(@Nullable T other) {
Comparable<Object> actual = actualAsComparable();
if (other == null) {
failWithoutActual(
simpleFact(
"expected a value that is at least null according to compareTo, but compareTo is"
+ " required to reject null"),
... | Checks that the actual value is greater than or equal to {@code other}.
<p>To check that the actual value is <i>strictly</i> greater than {@code other}, use {@link
#isGreaterThan}. | isAtLeast | java | google/truth | core/src/main/java/com/google/common/truth/ComparableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparableSubject.java | Apache-2.0 |
static <T extends Comparable<?>> Factory<ComparableSubject<T>, Object> comparables() {
return (metadata, actual) -> new ComparableSubject<T>(metadata, actual) {};
} | Factory for {@link ComparableSubject}, with an actual-value type of {@code Object} to work
around the J2CL strangeness documented on {@link #actual}. | comparables | java | google/truth | core/src/main/java/com/google/common/truth/ComparableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparableSubject.java | Apache-2.0 |
@SuppressWarnings("unchecked")
private @Nullable Comparable<Object> actualAsComparable() {
return (Comparable<Object>) actual;
} | Factory for {@link ComparableSubject}, with an actual-value type of {@code Object} to work
around the J2CL strangeness documented on {@link #actual}. | actualAsComparable | java | google/truth | core/src/main/java/com/google/common/truth/ComparableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparableSubject.java | Apache-2.0 |
@SuppressWarnings("unchecked")
private @Nullable T actualAsT() {
return (T) actual;
} | Factory for {@link ComparableSubject}, with an actual-value type of {@code Object} to work
around the J2CL strangeness documented on {@link #actual}. | actualAsT | java | google/truth | core/src/main/java/com/google/common/truth/ComparableSubject.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparableSubject.java | Apache-2.0 |
static ImmutableList<Fact> makeComparisonFailureFacts(
ImmutableList<Fact> headFacts,
ImmutableList<Fact> tailFacts,
String expected,
String actual) {
return concat(headFacts, formatExpectedAndActual(expected, actual), tailFacts);
} | Contains part of the code responsible for creating a JUnit {@code ComparisonFailure} (if
available) or a plain {@code AssertionError} (if not).
<p>This particular class is responsible for the fallback when a platform offers {@code
ComparisonFailure} but it is not available in a particular test environment. In practice... | makeComparisonFailureFacts | java | google/truth | core/src/main/java/com/google/common/truth/ComparisonFailures.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparisonFailures.java | Apache-2.0 |
@Override
public ImmutableList<Fact> facts() {
return facts;
} | An {@link AssertionError} (usually a JUnit {@code ComparisonFailure}, but not under GWT) composed
of structured {@link Fact} instances and other string messages. | facts | java | google/truth | core/src/main/java/com/google/common/truth/ComparisonFailureWithFacts.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparisonFailureWithFacts.java | Apache-2.0 |
@UsedByReflection
static ComparisonFailureWithFacts create(
ImmutableList<String> messages,
ImmutableList<Fact> facts,
String expected,
String actual,
@Nullable Throwable cause) {
return new ComparisonFailureWithFacts(messages, facts, expected, actual, cause);
} | An {@link AssertionError} (usually a JUnit {@code ComparisonFailure}, but not under GWT) composed
of structured {@link Fact} instances and other string messages. | create | java | google/truth | core/src/main/java/com/google/common/truth/ComparisonFailureWithFacts.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/ComparisonFailureWithFacts.java | Apache-2.0 |
public static <A extends @Nullable Object, E extends @Nullable Object> Correspondence<A, E> from(
BinaryPredicate<A, E> predicate, String description) {
return FromBinaryPredicate.create(predicate, description);
} | Constructs a {@link Correspondence} that compares actual and expected elements using the given
binary predicate.
<p>The correspondence does not support formatting of diffs (see {@link #formatDiff}). You can
add that behaviour by calling {@link Correspondence#formattingDiffsUsing}.
<p>Note that, if the data you are as... | from | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
@Override
public boolean compare(A actual, E expected) {
return predicate.apply(actual, expected);
} | Returns whether or not the actual and expected values satisfy the condition defined by this
predicate. | compare | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
@Override
public String toString() {
return description;
} | Returns whether or not the actual and expected values satisfy the condition defined by this
predicate. | toString | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
static <A extends @Nullable Object, E extends @Nullable Object>
FromBinaryPredicate<A, E> create(BinaryPredicate<A, E> predicate, String description) {
return new FromBinaryPredicate<>(predicate, description);
} | Returns whether or not the actual and expected values satisfy the condition defined by this
predicate. | create | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
public static <A extends @Nullable Object, E extends @Nullable Object>
Correspondence<A, E> transforming(
Function<A, ? extends E> actualTransform, String description) {
return Transforming.create(actualTransform, identity(), description);
} | Constructs a {@link Correspondence} that compares elements by transforming the actual elements
using the given function and testing for equality with the expected elements. If the
transformed actual element (i.e. the output of the given function) is null, it will correspond
to a null expected element.
<p>The correspon... | transforming | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
public static <A extends @Nullable Object, E extends @Nullable Object>
Correspondence<A, E> transforming(
Function<A, ?> actualTransform, Function<E, ?> expectedTransform, String description) {
return Transforming.create(actualTransform, expectedTransform, description);
} | Constructs a {@link Correspondence} that compares elements by transforming the actual and the
expected elements using the given functions and testing the transformed values for equality. If
an actual element is transformed to null, it will correspond to an expected element that is
also transformed to null.
<p>The corr... | transforming | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
@Override
public boolean compare(A actual, E expected) {
return Objects.equals(actualTransform.apply(actual), expectedTransform.apply(expected));
} | Constructs a {@link Correspondence} that compares elements by transforming the actual and the
expected elements using the given functions and testing the transformed values for equality. If
an actual element is transformed to null, it will correspond to an expected element that is
also transformed to null.
<p>The corr... | compare | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
@Override
public String toString() {
return description;
} | Constructs a {@link Correspondence} that compares elements by transforming the actual and the
expected elements using the given functions and testing the transformed values for equality. If
an actual element is transformed to null, it will correspond to an expected element that is
also transformed to null.
<p>The corr... | toString | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
static <A extends @Nullable Object, E extends @Nullable Object> Transforming<A, E> create(
Function<? super A, ?> actualTransform,
Function<? super E, ?> expectedTransform,
String description) {
return new Transforming<>(actualTransform, expectedTransform, description);
} | Constructs a {@link Correspondence} that compares elements by transforming the actual and the
expected elements using the given functions and testing the transformed values for equality. If
an actual element is transformed to null, it will correspond to an expected element that is
also transformed to null.
<p>The corr... | create | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
public static Correspondence<Number, Number> tolerance(double tolerance) {
return TolerantNumericEquality.create(tolerance);
} | Returns a {@link Correspondence} between {@link Number} instances that considers instances to
correspond (i.e. {@link Correspondence#compare(Object, Object)} returns {@code true}) if the
double values of each instance (i.e. the result of calling {@link Number#doubleValue()} on
them) are finite values within {@code tole... | tolerance | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
@Override
public boolean compare(Number actual, Number expected) {
double actualDouble = checkNotNull(actual).doubleValue();
double expectedDouble = checkNotNull(expected).doubleValue();
return MathUtil.equalWithinTolerance(actualDouble, expectedDouble, tolerance);
} | Returns a {@link Correspondence} between {@link Number} instances that considers instances to
correspond (i.e. {@link Correspondence#compare(Object, Object)} returns {@code true}) if the
double values of each instance (i.e. the result of calling {@link Number#doubleValue()} on
them) are finite values within {@code tole... | compare | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
@Override
public String toString() {
return "is a finite number within " + tolerance + " of";
} | Returns a {@link Correspondence} between {@link Number} instances that considers instances to
correspond (i.e. {@link Correspondence#compare(Object, Object)} returns {@code true}) if the
double values of each instance (i.e. the result of calling {@link Number#doubleValue()} on
them) are finite values within {@code tole... | toString | java | google/truth | core/src/main/java/com/google/common/truth/Correspondence.java | https://github.com/google/truth/blob/master/core/src/main/java/com/google/common/truth/Correspondence.java | Apache-2.0 |
Java CodeSearch Dataset (Shuu12121/java-treesitter-filtered-datasetsV2)
Dataset Description
This dataset contains Java methods paired with their Javadoc comments, extracted from open-source Java repositories on GitHub. It is formatted similarly to the CodeSearchNet challenge dataset.
Each entry includes:
code: The source code of a java function or method.docstring: The docstring or Javadoc associated with the function/method.func_name: The name of the function/method.language: The programming language (always "java").repo: The GitHub repository from which the code was sourced (e.g., "owner/repo").path: The file path within the repository where the function/method is located.url: A direct URL to the function/method's source file on GitHub (approximated to master/main branch).license: The SPDX identifier of the license governing the source repository (e.g., "MIT", "Apache-2.0"). Additional metrics if available (from Lizard tool):ccn: Cyclomatic Complexity Number.params: Number of parameters of the function/method.nloc: Non-commenting lines of code.token_count: Number of tokens in the function/method.
Dataset Structure
The dataset is divided into the following splits:
train: 8,956,411 examplesvalidation: 71,533 examplestest: 109,081 examples
Data Collection
The data was collected by:
- Identifying popular and relevant Java repositories on GitHub.
- Cloning these repositories.
- Parsing Java files (
.java) using tree-sitter to extract functions/methods and their docstrings/Javadoc. - Filtering functions/methods based on code length and presence of a non-empty docstring/Javadoc.
- Using the
lizardtool to calculate code metrics (CCN, NLOC, params). - Storing the extracted data in JSONL format, including repository and license information.
- Splitting the data by repository to ensure no data leakage between train, validation, and test sets.
Intended Use
This dataset can be used for tasks such as:
- Training and evaluating models for code search (natural language to code).
- Code summarization / docstring generation (code to natural language).
- Studies on Java code practices and documentation habits.
Licensing
The code examples within this dataset are sourced from repositories with permissive licenses (typically MIT, Apache-2.0, BSD).
Each sample includes its original license information in the license field.
The dataset compilation itself is provided under a permissive license (e.g., MIT or CC-BY-SA-4.0),
but users should respect the original licenses of the underlying code.
Example Usage
from datasets import load_dataset
# Load the dataset
dataset = load_dataset("Shuu12121/java-treesitter-filtered-datasetsV2")
# Access a split (e.g., train)
train_data = dataset["train"]
# Print the first example
print(train_data[0])
- Downloads last month
- 52