use of eu.stamp_project.dspot.amplifier.amplifiers.Amplifier in project dspot by STAMP-project.
the class StringLiteralAmplifierTest method testDoesNotAmplifyChar.
@Test
public void testDoesNotAmplifyChar() throws Exception {
final String nameMethod = "methodCharacter";
CtClass<Object> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
RandomHelper.setSeedRandom(42L);
Amplifier mutator = new StringLiteralAmplifier();
mutator.reset(literalMutationClass);
CtMethod method = literalMutationClass.getMethod(nameMethod);
List<CtMethod> mutantMethods = mutator.amplify(method, 0).collect(Collectors.toList());
assertTrue(mutantMethods.isEmpty());
}
use of eu.stamp_project.dspot.amplifier.amplifiers.Amplifier in project dspot by STAMP-project.
the class StringLiteralAmplifierTest method testOneLitExisting.
@Test
public void testOneLitExisting() throws Exception {
CtClass<Object> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.OneLiteralTest");
Amplifier amplifier = new StringLiteralAmplifier();
amplifier.reset(literalMutationClass);
final Stream<CtMethod<?>> test = amplifier.amplify(findMethod(literalMutationClass, "test"), 0);
System.out.println(test.collect(Collectors.toList()));
}
use of eu.stamp_project.dspot.amplifier.amplifiers.Amplifier 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.Amplifier in project dspot by STAMP-project.
the class NullifierAmplifierTest method testOnIntegerMethodCall.
@Test
public void testOnIntegerMethodCall() throws Exception {
/*
test the result of the NullifierAmplifier: it can nullify non primitive type but not primitive
*/
final String nameMethod = "methodCall";
CtClass<?> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.ClassWithMethodCall");
RandomHelper.setSeedRandom(42L);
Amplifier amplifier = new NullifierAmplifier();
final CtMethod method = findMethod(literalMutationClass, nameMethod);
List<CtMethod<?>> amplification = amplifier.amplify(method, 0).collect(Collectors.toList());
assertEquals(2, amplification.size());
amplification = amplification.stream().flatMap(testMethod -> amplifier.amplify(testMethod, 0)).collect(Collectors.toList());
assertEquals(2, amplification.size());
}
use of eu.stamp_project.dspot.amplifier.amplifiers.Amplifier in project dspot by STAMP-project.
the class PerformanceTest method test.
@Ignore
@Test
public void test() throws Exception {
/*
* This test aims at measuring the time execution of multiple applications of Amplifiers.
* This test is meant to be run manually
*/
final int numberOfIteration = 3;
final CtClass testClass = findClass("fr.inria.ampl.ToBeAmplifiedLiteralTest");
final CtMethod originalTest = findMethod(testClass, "testInt");
List<CtMethod> amplifiedTestMethod1 = Collections.singletonList(originalTest);
List<CtMethod> amplifiedTestMethod2 = Collections.singletonList(originalTest);
Amplifier testDataMutator = new FastLiteralAmplifier();
testDataMutator.reset(testClass);
Amplifier allLiteralAmplifiers = new AllLiteralAmplifiers();
allLiteralAmplifiers.reset(testClass);
long start = System.currentTimeMillis();
for (int i = 0; i < numberOfIteration; i++) {
amplifiedTestMethod1 = amplifiedTestMethod1.stream().flatMap(testMethod -> allLiteralAmplifiers.amplify(testMethod, 0)).collect(Collectors.toList());
System.out.println("(" + i + ")Number of Amplification:" + amplifiedTestMethod1.size());
}
final long timeAllLiteral = System.currentTimeMillis() - start;
System.out.println(timeAllLiteral + "ms");
long start2 = System.currentTimeMillis();
for (int i = 0; i < numberOfIteration; i++) {
amplifiedTestMethod2 = amplifiedTestMethod2.stream().flatMap(testMethod -> testDataMutator.amplify(testMethod, 0)).collect(Collectors.toList());
System.out.println("(" + i + ")Number of Amplification:" + amplifiedTestMethod2.size());
}
final long timeTestDataMutator = System.currentTimeMillis() - start2;
System.out.println(timeTestDataMutator + "ms");
assertTrue(timeTestDataMutator > timeAllLiteral);
assertTrue(amplifiedTestMethod2.size() > amplifiedTestMethod1.size());
}
Aggregations