use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class SymbolicObserver method newDoubleReference.
private ReferenceConstant newDoubleReference(Double conc_double, RealValue symb_value) {
ReferenceConstant doubleRef = (ReferenceConstant) env.heap.getReference(conc_double);
env.heap.putField(Types.JAVA_LANG_DOUBLE, SymbolicHeap.$DOUBLE_VALUE, conc_double, doubleRef, symb_value);
return doubleRef;
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class SymbolicObserver method after.
private void after(FunctionalMockStatement statement, Scope scope) {
Type returnType = Type.getType(statement.getReturnClass());
VariableReference varRef = statement.getReturnValue();
String varName = varRef.getName();
try {
if (varRef.getType().equals(void.class)) {
} else if (returnType.equals(Type.INT_TYPE) || returnType.equals(Type.BOOLEAN_TYPE) || returnType.equals(Type.DOUBLE_TYPE) || returnType.equals(Type.FLOAT_TYPE) || returnType.equals(Type.LONG_TYPE) || returnType.equals(Type.SHORT_TYPE) || returnType.equals(Type.BYTE_TYPE) || returnType.equals(Type.CHAR_TYPE)) {
throw new EvosuiteError("mocking of primitive types is not supported!");
} else {
Object res = varRef.getObject(scope);
ReferenceExpression ref = env.heap.getReference(res);
if (res != null && res instanceof String) {
String string = (String) res;
ReferenceConstant newStringRef = (ReferenceConstant) env.heap.getReference(string);
StringValue str_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, string, newStringRef, string);
symb_references.put(varName, newStringRef);
symb_expressions.put(varName, str_expr);
} else {
symb_references.put(varName, ref);
if (res != null && isWrapper(res)) {
ReferenceConstant nonNullRef = (ReferenceConstant) ref;
Expression<?> expr = findOrCreate(res, nonNullRef);
symb_expressions.put(varName, expr);
}
}
}
} catch (CodeUnderTestException e) {
throw new RuntimeException(e);
}
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class SymbolicObserver method after.
private void after(StringPrimitiveStatement statement, Scope scope) {
String valueOf = statement.getValue();
VariableReference varRef = statement.getReturnValue();
String varRefName = varRef.getName();
StringVariable stringVariable = buildStringVariable(varRefName, valueOf);
symb_expressions.put(varRefName, stringVariable);
String string_instance;
try {
String string_interned = (String) varRef.getObject(scope);
string_instance = new String(string_interned);
scope.setObject(varRef, string_instance);
} catch (CodeUnderTestException e) {
throw new EvosuiteError(e);
}
ReferenceConstant stringRef = newStringReference(string_instance, stringVariable);
symb_references.put(varRefName, stringRef);
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class SymbolicObserver method newCharacterReference.
private ReferenceConstant newCharacterReference(Character conc_char, IntegerValue symb_value) {
ReferenceConstant charRef = (ReferenceConstant) env.heap.getReference(conc_char);
env.heap.putField(Types.JAVA_LANG_CHARACTER, SymbolicHeap.$CHAR_VALUE, conc_char, charRef, symb_value);
return charRef;
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class SymbolicObserver method newFloatReference.
private ReferenceConstant newFloatReference(Float conc_float, RealValue symb_value) {
ReferenceConstant floatRef = (ReferenceConstant) env.heap.getReference(conc_float);
env.heap.putField(Types.JAVA_LANG_FLOAT, SymbolicHeap.$FLOAT_VALUE, conc_float, floatRef, symb_value);
return floatRef;
}
Aggregations