use of eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier in project dspot by STAMP-project.
the class LiteralAmplifiersTest method test.
@Test
public void test() throws Exception {
/*
This test the application of multiple amplifier, multiple time
The multiple applications of amplifiers should result with non-redundant amplified test
Here, we test that amplifiers marks amplified nodes and do not amplify them again
This avoid redundant transformation,
and thus improve the global performance in term of memory and execution time of DSpot
*/
final String nameMethod = "testInt";
CtClass<?> literalMutationClass = launcher.getFactory().Class().get("fr.inria.ampl.ToBeAmplifiedLiteralTest");
RandomHelper.setSeedRandom(42L);
Amplifier stringLiteralAmplifier = new StringLiteralAmplifier();
stringLiteralAmplifier.reset(literalMutationClass);
Amplifier numberLiteralAmplifier = new NumberLiteralAmplifier();
numberLiteralAmplifier.reset(literalMutationClass);
final CtMethod method = literalMutationClass.getMethodsByName(nameMethod).get(0);
// 1rst application of both amplifiers
List<CtMethod<?>> amplifiedStringMethods = stringLiteralAmplifier.amplify(method, 0).collect(Collectors.toList());
List<CtMethod<?>> amplifiedNumberMethods = numberLiteralAmplifier.amplify(method, 0).collect(Collectors.toList());
List<CtMethod<?>> amplifiedMethods = new ArrayList<>();
amplifiedMethods.addAll(amplifiedStringMethods);
amplifiedMethods.addAll(amplifiedNumberMethods);
assertEquals(47, amplifiedMethods.size());
// 2nd application of both amplifiers:
amplifiedStringMethods = amplifiedMethods.stream().flatMap(testMethod -> stringLiteralAmplifier.amplify(testMethod, 0)).collect(Collectors.toList());
amplifiedNumberMethods = amplifiedMethods.stream().flatMap(testMethod -> numberLiteralAmplifier.amplify(testMethod, 0)).collect(Collectors.toList());
amplifiedMethods.clear();
amplifiedMethods.addAll(amplifiedStringMethods);
amplifiedMethods.addAll(amplifiedNumberMethods);
// here, we have less amplified test method than before from more than 1630 to 1304
// TODO
assertEquals(1626, amplifiedMethods.size());
}
use of eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier in project dspot by STAMP-project.
the class NumberLiteralAmplifierTest method testIntMutation.
@Test
public void testIntMutation() {
final String nameMethod = "methodInteger";
final int originalValue = 23;
CtClass<Object> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
RandomHelper.setSeedRandom(42L);
NumberLiteralAmplifier amplifier = getAmplifier(literalMutationClass);
CtMethod method = literalMutationClass.getMethod(nameMethod);
List<Integer> expectedValues = Arrays.asList(22, 24, 2147483647, -2147483648, 0, -1170105035);
List<String> expectedFieldReads = Arrays.asList("java.lang.Integer.MAX_VALUE", "java.lang.Integer.MIN_VALUE");
List<CtMethod> mutantMethods = amplifier.amplify(method, 0).collect(Collectors.toList());
callAssertions(mutantMethods, nameMethod, expectedValues, expectedFieldReads, originalValue, 6);
}
use of eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier in project dspot by STAMP-project.
the class NumberLiteralAmplifierTest method testShortMutation.
@Test
public void testShortMutation() {
final String nameMethod = "methodShort";
final short originalValue = 23;
CtClass<Object> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
RandomHelper.setSeedRandom(42L);
NumberLiteralAmplifier amplifier = getAmplifier(literalMutationClass);
CtMethod method = literalMutationClass.getMethod(nameMethod);
List<Short> expectedValues = Arrays.asList((short) 22, (short) 24, (short) 0, (short) -25291);
List<String> expectedFieldReads = Arrays.asList("java.lang.Short.MAX_VALUE", "java.lang.Short.MIN_VALUE");
List<CtMethod> mutantMethods = amplifier.amplify(method, 0).collect(Collectors.toList());
callAssertions(mutantMethods, nameMethod, expectedValues, expectedFieldReads, originalValue, 6);
}
use of eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier in project dspot by STAMP-project.
the class NumberLiteralAmplifierTest method getAmplifier.
private NumberLiteralAmplifier getAmplifier(CtClass<?> testClassToBeAmplified) {
final NumberLiteralAmplifier numberLiteralAmplifier = new NumberLiteralAmplifier();
numberLiteralAmplifier.reset(testClassToBeAmplified);
return numberLiteralAmplifier;
}
use of eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier in project dspot by STAMP-project.
the class NumberLiteralAmplifierTest method testFloatMutation.
@Test
public void testFloatMutation() {
final String nameMethod = "methodFloat";
final double originalValue = 23.0F;
CtClass<Object> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
RandomHelper.setSeedRandom(42L);
NumberLiteralAmplifier amplifier = getAmplifier(literalMutationClass);
CtMethod method = literalMutationClass.getMethod(nameMethod);
List<Float> expectedValues = Arrays.asList(22.0F, 24.0F, 0.0F, 0.7275637F);
List<String> expectedFieldReads = Arrays.asList("java.lang.Float.MAX_VALUE", "java.lang.Float.MIN_VALUE", "java.lang.Float.MIN_NORMAL", "java.lang.Float.NaN", "java.lang.Float.POSITIVE_INFINITY", "java.lang.Float.NEGATIVE_INFINITY");
List<CtMethod> mutantMethods = amplifier.amplify(method, 0).collect(Collectors.toList());
callAssertions(mutantMethods, nameMethod, expectedValues, expectedFieldReads, originalValue, 10);
}
Aggregations