use of org.evosuite.testcase.variable.VariableReference in project evosuite by EvoSuite.
the class SymbolicObserver method after.
private void after(UrlPrimitiveStatement s, Scope scope) {
EvoSuiteURL conc_url = s.getValue();
VariableReference varRef = s.getReturnValue();
String varRefName = varRef.getName();
ReferenceExpression urlRef;
if (conc_url == null) {
urlRef = env.heap.getReference(null);
if (urlRef.getConcreteValue() != null) {
throw new IllegalStateException("Expected null concrete value");
}
} else {
urlRef = (ReferenceConstant) env.heap.getReference(conc_url);
if (urlRef.getConcreteValue() == null) {
throw new IllegalStateException("Expected non-null concrete value");
}
}
symb_references.put(varRefName, urlRef);
}
use of org.evosuite.testcase.variable.VariableReference in project evosuite by EvoSuite.
the class SymbolicObserver method after.
private void after(RemoteAddressPrimitiveStatement s, Scope scope) {
EvoSuiteRemoteAddress conc_remote_address = s.getValue();
VariableReference varRef = s.getReturnValue();
String varRefName = varRef.getName();
ReferenceExpression addressRef;
if (conc_remote_address == null) {
addressRef = env.heap.getReference(null);
if (addressRef.getConcreteValue() != null) {
throw new IllegalStateException("Expected null concrete value");
}
} else {
addressRef = env.heap.getReference(conc_remote_address);
if (addressRef.getConcreteValue() == null) {
throw new IllegalStateException("Expected non-null concrete value");
}
}
symb_references.put(varRefName, addressRef);
}
use of org.evosuite.testcase.variable.VariableReference in project evosuite by EvoSuite.
the class SymbolicObserver method after.
private void after(NullStatement s, Scope scope) {
VariableReference lhs = s.getReturnValue();
String lhs_name = lhs.getName();
ReferenceExpression nullConstant = ExpressionFactory.buildNewNullExpression();
symb_references.put(lhs_name, nullConstant);
}
use of org.evosuite.testcase.variable.VariableReference in project evosuite by EvoSuite.
the class SymbolicObserver method writeField.
private void writeField(FieldReference lhs, ReferenceExpressionPair readResult, Scope scope) {
Field field = lhs.getField().getField();
String className = field.getDeclaringClass().getName().replace('.', '/');
String fieldName = field.getName();
Class<?> fieldClass = field.getType();
Type fieldType = Type.getType(fieldClass);
if (isValue(fieldType) || fieldType.equals(Type.getType(String.class))) {
Expression<?> symb_value = readResult.getExpression();
symb_value = castIfNeeded(fieldType, symb_value);
VariableReference source = lhs.getSource();
if (source != null) {
/* write symbolic expression to instance field */
String source_name = source.getName();
Object conc_receiver;
try {
conc_receiver = source.getObject(scope);
} catch (CodeUnderTestException e) {
throw new RuntimeException(e);
}
ReferenceConstant symb_receiver = (ReferenceConstant) symb_references.get(source_name);
env.heap.putField(className, fieldName, conc_receiver, symb_receiver, symb_value);
} else {
/* write symbolic expression to static field */
env.heap.putStaticField(className, fieldName, symb_value);
}
} else {
/*
* ignore writing of references (DSE does not store Reference
* fields)
*/
}
}
use of org.evosuite.testcase.variable.VariableReference in project evosuite by EvoSuite.
the class SymbolicObserver method after.
private void after(ShortPrimitiveStatement statement, Scope scope) {
short valueOf = statement.getValue();
VariableReference varRef = statement.getReturnValue();
String varRefName = varRef.getName();
IntegerVariable integerVariable = buildIntegerVariable(varRefName, valueOf, Short.MIN_VALUE, Short.MAX_VALUE);
symb_expressions.put(varRefName, integerVariable);
Short short_instance;
try {
short_instance = (Short) varRef.getObject(scope);
} catch (CodeUnderTestException e) {
throw new EvosuiteError(e);
}
ReferenceConstant shortRef = newShortReference(short_instance, integerVariable);
symb_references.put(varRefName, shortRef);
}
Aggregations