-
Notifications
You must be signed in to change notification settings - Fork 20
/
StopMethodRecognizerTest.java
50 lines (40 loc) · 1.59 KB
/
StopMethodRecognizerTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package eu.stamp_project.mutationtest.descartes.bodyanalysis;
import eu.stamp_project.mutationtest.test.Calculator;
import eu.stamp_project.mutationtest.test.StopMethods;
import eu.stamp_project.mutationtest.test.TestUtils;
import org.junit.Ignore;
import org.junit.Test;
import org.pitest.reloc.asm.tree.AbstractInsnNode;
import org.pitest.reloc.asm.tree.MethodNode;
import java.util.ListIterator;
import static eu.stamp_project.utils.Utils.isConstructor;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@Ignore
public class StopMethodRecognizerTest {
@Test
public void shouldRecognize() {
for (MethodNode method :
TestUtils.getMethodNodes(StopMethods.class)) {
if(!isConstructor(method.name))
assertTrue("Stop method " + method.name + " not recognized", isStopMethod(method));
}
}
@Test
public void shouldNotRecognize() {
for (MethodNode method :
TestUtils.getMethodNodes(Calculator.class)) {
if(!method.name.equals("<init>"))
assertFalse("Non-stop method " + method.name + " recognized.", isStopMethod(method));
}
}
private boolean isStopMethod(MethodNode method) {
StopMethodRecognizer recognizer = new StopMethodRecognizer();
ListIterator<AbstractInsnNode> iterator = method.instructions.iterator();
while(iterator.hasNext()) {
AbstractInsnNode instruction = iterator.next();
recognizer.advance(instruction.getOpcode());
}
return recognizer.isOnFinalState();
}
}