Search in sources :

Example 11 with RealConstant

use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.

the class CallVM method METHOD_BEGIN_PARAM.

@Override
public void METHOD_BEGIN_PARAM(int nr, int index, float value) {
    if (!env.callerFrame().weInvokedInstrumentedCode()) {
        RealConstant literal_value = ExpressionFactory.buildNewRealConstant(value);
        env.topFrame().localsTable.setFp32Local(index, literal_value);
    }
}
Also used : RealConstant(org.evosuite.symbolic.expr.fp.RealConstant)

Example 12 with RealConstant

use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.

the class CallVM method METHOD_BEGIN_PARAM.

@Override
public void METHOD_BEGIN_PARAM(int nr, int index, double value) {
    if (!env.callerFrame().weInvokedInstrumentedCode()) {
        RealConstant literal_value = ExpressionFactory.buildNewRealConstant(value);
        env.topFrame().localsTable.setFp64Local(index, literal_value);
    }
}
Also used : RealConstant(org.evosuite.symbolic.expr.fp.RealConstant)

Example 13 with RealConstant

use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.

the class TestRealSearch method testEvosuiteExample3.

// @Test
public void testEvosuiteExample3() {
    // ((1102.5 + var22__SYM(12.220999717712402)) *
    // var19__SYM(-45.633541107177734)) == 2.772399987618165E32
    double var1 = 12.220999717712402;
    double var2 = -45.633541107177734;
    RealVariable realVar1 = new RealVariable("test1", var1, -1000000, 1000000);
    RealVariable realVar2 = new RealVariable("test2", var2, -1000000, 1000000);
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    constraints.add(new RealConstraint(new RealBinaryExpression(new RealBinaryExpression(new RealConstant(1102.5), Operator.PLUS, realVar1, 1.22209997177135E16), Operator.MUL, realVar2, -5.57687492989087E32), Comparator.EQ, new RealConstant(2.772399987618165E32)));
    assert (DistanceEstimator.getDistance(constraints) > 0);
    EvoSuiteSolver skr = new EvoSuiteSolver();
    Map<String, Object> result;
    try {
        result = solve(skr, constraints);
        assertNotNull(result);
        if (result.containsKey("test1"))
            var1 = ((Number) result.get("test1")).doubleValue();
        if (result.containsKey("test2"))
            var2 = ((Number) result.get("test2")).doubleValue();
        assertEquals(var1, var2, 0.0001);
    } catch (SolverTimeoutException e) {
        fail();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) Constraint(org.evosuite.symbolic.expr.Constraint) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) RealVariable(org.evosuite.symbolic.expr.fp.RealVariable) RealConstant(org.evosuite.symbolic.expr.fp.RealConstant) RealBinaryExpression(org.evosuite.symbolic.expr.fp.RealBinaryExpression) RealConstraint(org.evosuite.symbolic.expr.RealConstraint)

Example 14 with RealConstant

use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.

the class TestRealSearch method testGEConstant.

@Test
public void testGEConstant() {
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    constraints.add(new RealConstraint(new RealVariable("test1", 0, -1000000.0, 1000000.0), Comparator.GE, 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();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) RealConstant(org.evosuite.symbolic.expr.fp.RealConstant) Constraint(org.evosuite.symbolic.expr.Constraint) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) RealVariable(org.evosuite.symbolic.expr.fp.RealVariable) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) Test(org.junit.Test)

Example 15 with RealConstant

use of org.evosuite.symbolic.expr.fp.RealConstant in project evosuite by EvoSuite.

the class TestRealSearch method testLEConstant.

@Test
public void testLEConstant() {
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    constraints.add(new RealConstraint(new RealVariable("test1", 5.35086, -1000000.0, 1000000.0), Comparator.LE, 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();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) RealConstant(org.evosuite.symbolic.expr.fp.RealConstant) Constraint(org.evosuite.symbolic.expr.Constraint) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) RealVariable(org.evosuite.symbolic.expr.fp.RealVariable) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) Test(org.junit.Test)

Aggregations

RealConstant (org.evosuite.symbolic.expr.fp.RealConstant)22 Constraint (org.evosuite.symbolic.expr.Constraint)16 RealConstraint (org.evosuite.symbolic.expr.RealConstraint)16 RealVariable (org.evosuite.symbolic.expr.fp.RealVariable)16 ArrayList (java.util.ArrayList)15 SolverTimeoutException (org.evosuite.symbolic.solver.SolverTimeoutException)15 EvoSuiteSolver (org.evosuite.symbolic.solver.avm.EvoSuiteSolver)15 Test (org.junit.Test)14 RealBinaryExpression (org.evosuite.symbolic.expr.fp.RealBinaryExpression)3