Search in sources :

Example 1 with IterationDecoratorAmplifier

use of eu.stamp_project.dspot.amplifier.amplifiers.IterationDecoratorAmplifier in project dspot by STAMP-project.

the class SimpleInputAmplDistributorTest method test.

@Test
public void test() throws Exception {
    /*
            Test the simple input_ampl_distributor with different amplifier.
            The SimpleBudget should always provide a specific number of test Methods
         */
    final CtClass<?> testClass = findClass("fr.inria.statementadd.TestClassTargetAmplify");
    List<CtMethod<?>> ctMethods = TestFramework.getAllTest(testClass);
    final SimpleInputAmplDistributor simpleBudgetizer = new SimpleInputAmplDistributor(6, Arrays.asList(new IterationDecoratorAmplifier(new ReturnValueAmplifier(), 3), new IterationDecoratorAmplifier(new MethodAdderOnExistingObjectsAmplifier(), 2), new NumberLiteralAmplifier()));
    for (int i = 0; i < 3; i++) {
        // !
        ctMethods = simpleBudgetizer.inputAmplify(ctMethods, i);
    }
    assertEquals(6, ctMethods.size());
}
Also used : MethodAdderOnExistingObjectsAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.MethodAdderOnExistingObjectsAmplifier) SimpleInputAmplDistributor(eu.stamp_project.dspot.amplifier.SimpleInputAmplDistributor) CtMethod(spoon.reflect.declaration.CtMethod) IterationDecoratorAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.IterationDecoratorAmplifier) ReturnValueAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.ReturnValueAmplifier) NumberLiteralAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier) Test(org.junit.Test)

Example 2 with IterationDecoratorAmplifier

use of eu.stamp_project.dspot.amplifier.amplifiers.IterationDecoratorAmplifier in project dspot by STAMP-project.

the class IterationDecoratorAmplifierTest method test.

@Test
public void test() throws Exception {
    /*
            Test the application of IterationDecoratorAmplifier.
            This amplifier decorate the given amplifier to apply it at a given frequency
         */
    final String nameMethod = "methodInteger";
    CtClass<Object> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
    RandomHelper.setSeedRandom(42L);
    // we apply the given amplifier each 2 iteration, i.e. iteration 0, iteration 2, iteration 4 etc....
    Amplifier amplifier = new IterationDecoratorAmplifier(new NumberLiteralAmplifier(), 2);
    CtMethod method = literalMutationClass.getMethod(nameMethod);
    // 1 / 2 iteration produces something (the list is not empty)
    for (int i = 0; i < 10; i = i + 2) {
        assertFalse(amplifier.amplify(method, i).collect(Collectors.toList()).isEmpty());
        assertTrue(amplifier.amplify(method, i + 1).collect(Collectors.toList()).isEmpty());
    }
    amplifier = new IterationDecoratorAmplifier(new NumberLiteralAmplifier(), 3);
    // 1 / 3 iteration produces something (the list is not empty)
    for (int i = 0; i < 12; i = i + 3) {
        assertFalse(amplifier.amplify(method, i).collect(Collectors.toList()).isEmpty());
        assertTrue(amplifier.amplify(method, i + 1).collect(Collectors.toList()).isEmpty());
        assertTrue(amplifier.amplify(method, i + 2).collect(Collectors.toList()).isEmpty());
    }
}
Also used : IterationDecoratorAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.IterationDecoratorAmplifier) NumberLiteralAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier) Amplifier(eu.stamp_project.dspot.amplifier.amplifiers.Amplifier) IterationDecoratorAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.IterationDecoratorAmplifier) NumberLiteralAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier) CtMethod(spoon.reflect.declaration.CtMethod) Test(org.junit.Test)

Aggregations

IterationDecoratorAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.IterationDecoratorAmplifier)2 NumberLiteralAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier)2 Test (org.junit.Test)2 CtMethod (spoon.reflect.declaration.CtMethod)2 SimpleInputAmplDistributor (eu.stamp_project.dspot.amplifier.SimpleInputAmplDistributor)1 Amplifier (eu.stamp_project.dspot.amplifier.amplifiers.Amplifier)1 MethodAdderOnExistingObjectsAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.MethodAdderOnExistingObjectsAmplifier)1 ReturnValueAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.ReturnValueAmplifier)1