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());
}
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());
}
}
Aggregations