use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.
the class LocalsVM method LDC.
@Override
public void LDC(float x) {
RealConstant realConstant = ExpressionFactory.buildNewRealConstant(x);
env.topFrame().operandStack.pushFp32(realConstant);
}
use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.
the class ExpressionFactory method buildAddNormalized.
private static RealValue buildAddNormalized(RealValue right, RealValue left, double con) {
// can only optimize if left is a literal
if (!(left instanceof RealConstant))
return new RealBinaryExpression(left, Operator.PLUS, right, con);
/*
* (add 0 x) --> x
*/
if (((RealConstant) left).getConcreteValue() == 0) {
return right;
}
/*
* (add a b) --> result of a+b
*/
if (right instanceof RealConstant) {
double a = left.getConcreteValue();
double b = right.getConcreteValue();
return buildNewRealConstant(a + b);
}
/*
* (add a (add b x)) --> (add (a+b) x)
*/
if (right instanceof RealBinaryExpression && ((RealBinaryExpression) right).getOperator() == Operator.PLUS) {
RealBinaryExpression add = (RealBinaryExpression) right;
if (add.getLeftOperand() instanceof RealConstant) {
double a = left.getConcreteValue();
double b = add.getLeftOperand().getConcreteValue();
RealConstant a_plus_b = buildNewRealConstant(a + b);
return new RealBinaryExpression(a_plus_b, Operator.PLUS, add.getRightOperand(), con);
}
}
return new RealBinaryExpression(left, Operator.PLUS, right, con);
}
use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.
the class TestRealSearch method testEQConstantAfterComma.
@Test
public void testEQConstantAfterComma() {
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(new RealVariable("test1", 0, -1000000.0, 1000000.0), Comparator.EQ, new RealConstant(0.35082)));
EvoSuiteSolver skr = new EvoSuiteSolver();
Map<String, Object> result;
try {
result = solve(skr, constraints);
assertNotNull(result);
assertNotNull(result.get("test1"));
assertTrue(0.35082 == ((Number) result.get("test1")).doubleValue());
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.
the class TestRealSearch method testGTConstantAfterComma.
@Test
public void testGTConstantAfterComma() {
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(new RealVariable("test1", 2.0, -1000000.0, 1000000.0), Comparator.GT, new RealConstant(2.35082)));
EvoSuiteSolver skr = new EvoSuiteSolver();
Map<String, Object> result;
try {
result = solve(skr, constraints);
assertNotNull(result);
assertNotNull(result.get("test1"));
assertTrue(2.35082 < ((Number) result.get("test1")).doubleValue());
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.
the class TestRealSearch method testLTConstantAfterComma.
@Test
public void testLTConstantAfterComma() {
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(new RealVariable("test1", 2.35086, -1000000.0, 1000000.0), Comparator.LT, new RealConstant(2.35082)));
EvoSuiteSolver skr = new EvoSuiteSolver();
Map<String, Object> result;
try {
result = solve(skr, constraints);
assertNotNull(result);
assertNotNull(result.get("test1"));
assertTrue(2.35082 > ((Number) result.get("test1")).doubleValue());
} catch (SolverTimeoutException e) {
fail();
}
}
Aggregations