Search in sources :

Example 1 with NullifierAmplifier

use of eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier in project dspot by STAMP-project.

the class NullifierAmplifierTest method test.

@Test
public void test() throws Exception {
    // test the result of the NullifierAmplifier
    final String nameMethod = "methodString";
    CtClass<?> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
    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());
}
Also used : NullifierAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier) NullifierAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier) Amplifier(eu.stamp_project.dspot.amplifier.amplifiers.Amplifier) CtMethod(spoon.reflect.declaration.CtMethod) Test(org.junit.Test)

Example 2 with NullifierAmplifier

use of eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier in project dspot by STAMP-project.

the class NullifierAmplifierTest method testOnInteger.

@Test
public void testOnInteger() throws Exception {
    // test the result of the NullifierAmplifier
    final String nameMethod = "methodInteger";
    CtClass<?> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
    RandomHelper.setSeedRandom(42L);
    Amplifier amplifier = new NullifierAmplifier();
    final CtMethod method = findMethod(literalMutationClass, nameMethod);
    List<CtMethod<?>> amplification = amplifier.amplify(method, 0).collect(Collectors.toList());
    assertEquals(0, amplification.size());
}
Also used : NullifierAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier) NullifierAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier) Amplifier(eu.stamp_project.dspot.amplifier.amplifiers.Amplifier) CtMethod(spoon.reflect.declaration.CtMethod) Test(org.junit.Test)

Example 3 with NullifierAmplifier

use of eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier in project dspot by STAMP-project.

the class NullifierAmplifierTest method testOnArrayType.

@Test
public void testOnArrayType() throws Exception {
    final String nameMethod = "methodThatClassmethodWithCharArray";
    CtClass<?> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
    RandomHelper.setSeedRandom(42L);
    Amplifier amplifier = new NullifierAmplifier();
    final CtMethod<?> method = findMethod(literalMutationClass, nameMethod);
    List<CtMethod<?>> amplification = amplifier.amplify(method, 0).collect(Collectors.toList());
    assertTrue(amplification.isEmpty());
}
Also used : NullifierAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier) NullifierAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier) Amplifier(eu.stamp_project.dspot.amplifier.amplifiers.Amplifier) CtMethod(spoon.reflect.declaration.CtMethod) Test(org.junit.Test)

Example 4 with NullifierAmplifier

use of eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier 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());
}
Also used : NullifierAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier) NullifierAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier) Amplifier(eu.stamp_project.dspot.amplifier.amplifiers.Amplifier) CtMethod(spoon.reflect.declaration.CtMethod) Test(org.junit.Test)

Aggregations

Amplifier (eu.stamp_project.dspot.amplifier.amplifiers.Amplifier)4 NullifierAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.NullifierAmplifier)4 Test (org.junit.Test)4 CtMethod (spoon.reflect.declaration.CtMethod)4