use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class Pattern_Matcher method executeFunction.
@Override
public Object executeFunction() {
// receiver
@SuppressWarnings("unused") ReferenceConstant symb_receiver = this.getSymbReceiver();
// argument
CharSequence conc_char_seq = (CharSequence) this.getConcArgument(0);
ReferenceExpression symb_char_seq = this.getSymbArgument(0);
// return value
Matcher conc_matcher = (Matcher) this.getConcRetVal();
ReferenceConstant symb_matcher = (ReferenceConstant) this.getSymbRetVal();
if (conc_char_seq != null && conc_char_seq instanceof String) {
assert symb_char_seq instanceof ReferenceConstant;
ReferenceConstant symb_string = (ReferenceConstant) symb_char_seq;
String string = (String) conc_char_seq;
StringValue symb_input = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, string, symb_string, string);
env.heap.putField(Types.JAVA_UTIL_REGEX_MATCHER, SymbolicHeap.$MATCHER_INPUT, conc_matcher, symb_matcher, symb_input);
}
return symb_matcher;
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class CompareTo method executeFunction.
@Override
public Object executeFunction() {
String conc_left = (String) this.getConcReceiver();
ReferenceConstant symb_left = this.getSymbReceiver();
StringValue left_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_left, symb_left, conc_left);
String conc_right = (String) this.getConcArgument(0);
ReferenceConstant symb_right = (ReferenceConstant) this.getSymbArgument(0);
StringValue right_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_right, symb_right, conc_right);
int res = this.getConcIntRetVal();
if (left_expr.containsSymbolicVariable() || right_expr.containsSymbolicVariable()) {
StringBinaryToIntegerExpression strBExpr = new StringBinaryToIntegerExpression(left_expr, Operator.COMPARETO, right_expr, (long) res);
return strBExpr;
} else {
return this.getSymbIntegerRetVal();
}
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class EndsWith method executeFunction.
@Override
public Object executeFunction() {
String conc_left = (String) this.getConcReceiver();
ReferenceConstant symb_left = this.getSymbReceiver();
StringValue left_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_left, symb_left, conc_left);
String conc_right = (String) this.getConcArgument(0);
ReferenceConstant symb_right = (ReferenceConstant) this.getSymbArgument(0);
StringValue right_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_right, symb_right, conc_right);
boolean res = this.getConcBooleanRetVal();
if (left_expr.containsSymbolicVariable() || right_expr.containsSymbolicVariable()) {
int conV = res ? 1 : 0;
StringBinaryComparison strBExpr = new StringBinaryComparison(left_expr, Operator.ENDSWITH, right_expr, (long) conV);
return strBExpr;
} else {
return this.getSymbIntegerRetVal();
}
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class EqualsIgnoreCase method executeFunction.
@Override
public Object executeFunction() {
String conc_left = (String) this.getConcReceiver();
ReferenceConstant symb_left = this.getSymbReceiver();
String conc_right = (String) this.getConcArgument(0);
ReferenceExpression symb_right = this.getSymbArgument(0);
boolean res = this.getConcBooleanRetVal();
StringValue left_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_left, symb_left, conc_left);
if (symb_right instanceof ReferenceConstant && conc_right != null) {
ReferenceConstant ref_constant_right = (ReferenceConstant) symb_right;
StringValue right_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_right, ref_constant_right, conc_right);
if (left_expr.containsSymbolicVariable() || right_expr.containsSymbolicVariable()) {
int conV = res ? 1 : 0;
StringBinaryComparison strBExpr = new StringBinaryComparison(left_expr, Operator.EQUALSIGNORECASE, right_expr, (long) conV);
return strBExpr;
}
}
return this.getSymbIntegerRetVal();
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class RegionMatches5 method executeFunction.
@Override
public Object executeFunction() {
ReferenceConstant symb_receiver = (ReferenceConstant) this.getSymbReceiver();
String conc_receiver = (String) this.getConcReceiver();
StringValue stringReceiverExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_receiver, symb_receiver, conc_receiver);
IntegerValue ignoreCaseExpr = new IntegerConstant(0);
IntegerValue toffsetExpr = this.getSymbIntegerArgument(0);
ReferenceConstant symb_other = (ReferenceConstant) this.getSymbArgument(1);
String conc_other = (String) this.getConcArgument(1);
StringValue otherExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_other, symb_other, conc_other);
IntegerValue ooffsetExpr = this.getSymbIntegerArgument(2);
IntegerValue lenExpr = this.getSymbIntegerArgument(3);
boolean res = this.getConcBooleanRetVal();
if (stringReceiverExpr.containsSymbolicVariable() || ignoreCaseExpr.containsSymbolicVariable() || toffsetExpr.containsSymbolicVariable() || otherExpr.containsSymbolicVariable() || ooffsetExpr.containsSymbolicVariable() || lenExpr.containsSymbolicVariable()) {
ArrayList<Expression<?>> other = new ArrayList<Expression<?>>();
other.add(toffsetExpr);
other.add(ooffsetExpr);
other.add(lenExpr);
other.add(ignoreCaseExpr);
int conV = res ? 1 : 0;
StringMultipleComparison strComp = new StringMultipleComparison(stringReceiverExpr, Operator.REGIONMATCHES, otherExpr, other, (long) conV);
return strComp;
}
return this.getSymbIntegerRetVal();
}
Aggregations