use of eu.stamp_project.dspot.amplifier.amplifiers.ReturnValueAmplifier in project dspot by STAMP-project.
the class ReturnValueAmplifierTest method testStatementAddOnArrayObjects.
@Test
public void testStatementAddOnArrayObjects() throws Exception {
final String packageName = "fr.inria.statementaddarray";
final Factory factory = launcher.getFactory();
RandomHelper.setSeedRandom(32L);
ReturnValueAmplifier amplifier = new ReturnValueAmplifier();
amplifier.reset(factory.Class().get(packageName + ".ClassTargetAmplify"));
CtMethod<?> ctMethod = findMethod(factory.Class().get(packageName + ".TestClassTargetAmplify"), "test");
List<CtMethod> amplifiedMethods = amplifier.amplify(ctMethod, 0).collect(Collectors.toList());
assertEquals(1, amplifiedMethods.size());
List<String> expectedCalledMethod = Collections.singletonList("method1");
assertTrue(amplifiedMethods.stream().allMatch(amplifiedMethod -> amplifiedMethod.filterChildren(new TypeFilter<CtInvocation<?>>(CtInvocation.class) {
@Override
public boolean matches(CtInvocation<?> element) {
return expectedCalledMethod.contains(element.getExecutable().getSimpleName());
}
}).first() != null));
}
use of eu.stamp_project.dspot.amplifier.amplifiers.ReturnValueAmplifier in project dspot by STAMP-project.
the class ReturnValueAmplifierTest method testStatementAdd.
@Test
public void testStatementAdd() throws Exception {
/*
Test the StatementAdd amplifier. It reuse existing object to add method call of accessible method.
It can reuse return value to add method call. It results here with 7 new test cases.
*/
final String packageName = "fr.inria.statementadd";
final Factory factory = launcher.getFactory();
RandomHelper.setSeedRandom(42L);
ReturnValueAmplifier amplifier = new ReturnValueAmplifier();
amplifier.reset(factory.Class().get(packageName + ".TestClassTargetAmplify"));
CtMethod<?> ctMethod = findMethod(factory.Class().get(packageName + ".TestClassTargetAmplify"), "test");
List<CtMethod> amplifiedMethods = amplifier.amplify(ctMethod, 0).collect(Collectors.toList());
System.out.println(amplifiedMethods);
assertEquals(1, amplifiedMethods.size());
List<String> expectedCalledMethod = Collections.singletonList("method1");
assertTrue(amplifiedMethods.stream().allMatch(amplifiedMethod -> amplifiedMethod.filterChildren(new TypeFilter<CtInvocation<?>>(CtInvocation.class) {
@Override
public boolean matches(CtInvocation<?> element) {
return expectedCalledMethod.contains(element.getExecutable().getSimpleName());
}
}).first() != null));
}
use of eu.stamp_project.dspot.amplifier.amplifiers.ReturnValueAmplifier 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());
}
Aggregations