use of eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier in project dspot by STAMP-project.
the class NumberLiteralAmplifierTest method setup.
@Before
public void setup() throws Exception {
super.setUp();
literalMutationClass = findClass("fr.inria.amp.LiteralMutation");
RandomHelper.setSeedRandom(42L);
amplifier = new NumberLiteralAmplifier();
}
use of eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier in project dspot by STAMP-project.
the class LiteralAmplifiersTest method testAllHasBeenAmplified.
@Ignore
@Test
public void testAllHasBeenAmplified() throws Exception {
/*
The amplifiers must keep doing the amplification in case of all the combination of amplification has been explored.
*/
final CtClass testClass = launcher.getFactory().Class().get("fr.inria.workload.WorkloadTest");
List<CtMethod<?>> allTest = TestFramework.getAllTest(testClass);
Amplifier amplifier = new NumberLiteralAmplifier();
allTest = allTest.stream().flatMap(// we apply twice the NumberLiteralAmplifier. In one iteration, it explores every amplification that can be done
method -> amplifier.amplify(method, 0)).flatMap(// however, we can continue to amplify since there is some random
method -> amplifier.amplify(method, 0)).collect(Collectors.toList());
assertFalse(allTest.isEmpty());
}
use of eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier 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.NumberLiteralAmplifier 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());
}
}
use of eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier in project dspot by STAMP-project.
the class NumberLiteralAmplifierTest method testDoubleMutation.
@Test
public void testDoubleMutation() {
final String nameMethod = "methodDouble";
final double originalValue = 23.0D;
CtClass<Object> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
RandomHelper.setSeedRandom(42L);
NumberLiteralAmplifier amplifier = getAmplifier(literalMutationClass);
CtMethod method = literalMutationClass.getMethod(nameMethod);
List<Double> expectedValues = Arrays.asList(22.0D, 24.0D, 0.0D, 0.7275636800328681);
List<String> expectedFieldReads = Arrays.asList("java.lang.Double.MAX_VALUE", "java.lang.Double.MIN_VALUE", "java.lang.Double.MIN_NORMAL", "java.lang.Double.NaN", "java.lang.Double.POSITIVE_INFINITY", "java.lang.Double.NEGATIVE_INFINITY");
List<CtMethod> mutantMethods = amplifier.amplify(method, 0).collect(Collectors.toList());
callAssertions(mutantMethods, nameMethod, expectedValues, expectedFieldReads, originalValue, 10);
}
Aggregations