Skip to content

Commit bde659d

Browse files
committed
feat: added pitest and improved test suite.
1 parent 1867172 commit bde659d

2 files changed

Lines changed: 44 additions & 3 deletions

File tree

core/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
plugins {
2+
id 'info.solidsoft.pitest' version '1.7.0'
3+
}
4+
15
description = 'GumTree core module.'
26

37
dependencies {
@@ -7,6 +11,15 @@ dependencies {
711
implementation 'org.jgrapht:jgrapht-core:1.5.1'
812
}
913

14+
pitest {
15+
targetClasses = ['com.github.gumtreediff.tree*']
16+
targetTests = ['com.github.gumtreediff.test.TestTree', 'com.github.gumtreediff.test.TestMetadata', 'com.github.gumtreediff.test.TestTreeUtils']
17+
threads = 4
18+
outputFormats = ['XML', 'HTML']
19+
timestampedReports = false
20+
junit5PluginVersion = '0.15'
21+
}
22+
1023
allprojects {
1124
gradle.projectsEvaluated {
1225
tasks.withType(JavaCompile) {

core/src/test/java/com/github/gumtreediff/test/TestTree.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import com.github.gumtreediff.tree.*;
2828
import org.junit.jupiter.api.Test;
2929

30-
import javax.lang.model.type.ArrayType;
31-
3230
import static org.junit.jupiter.api.Assertions.*;
3331

3432
public class TestTree {
@@ -52,6 +50,27 @@ public void testSearchSubtree() {
5250
assertEquals(0, results.size());
5351
}
5452

53+
@Test
54+
public void testIsRoot() {
55+
Tree tree = new DefaultTree(TypeSet.type("a"));
56+
tree.addChild(new DefaultTree(TypeSet.type("b")));
57+
tree.addChild(new DefaultTree(TypeSet.type("c"), "foo"));
58+
assertTrue(tree.isRoot());
59+
assertFalse(tree.getChild(0).isRoot());
60+
assertFalse(tree.getChild(1).isRoot());
61+
}
62+
63+
@Test
64+
public void testInsertChild() {
65+
Tree tree = new DefaultTree(TypeSet.type("a"));
66+
tree.addChild(new DefaultTree(TypeSet.type("b")));
67+
tree.addChild(new DefaultTree(TypeSet.type("c"), "foo"));
68+
System.out.println(tree.getChildren().size());
69+
tree.insertChild(new DefaultTree(TypeSet.type("m")), 1);
70+
assertEquals(TypeSet.type("m"), tree.getChild(1).getType());
71+
assertEquals(tree, tree.getChild(1).getParent());
72+
}
73+
5574
@Test
5675
public void testTreesBetweenPositions() {
5776
Tree root = TreeLoader.getDummySrc();
@@ -179,7 +198,9 @@ public void testIsostructure() {
179198
assertTrue(root.isIsoStructuralTo(rootCpy));
180199
rootCpy.getChild("0.0").setLabel("foo");
181200
assertTrue(root.isIsoStructuralTo(rootCpy));
182-
root.getChild("0.0").setLabel("foo");
201+
rootCpy.getChild("0.1").setType(TypeSet.type("foo"));
202+
assertFalse(root.isIsoStructuralTo(rootCpy));
203+
root.getChild("0.1").setType(TypeSet.type("foo"));
183204
assertTrue(root.isIsoStructuralTo(rootCpy));
184205
root.addChild(new FakeTree());
185206
assertFalse(root.isIsoStructuralTo(rootCpy));
@@ -232,6 +253,13 @@ public void testFakeTree() {
232253

233254
@Test
234255
public void testTypesAndLabels() {
256+
Type origType = TypeSet.type("anewtype");
257+
Type otherType = TypeSet.type("othernewtype");
258+
Type origCopyType = TypeSet.type("anewtype");
259+
assertNotNull(origType);
260+
assertSame(origType, origCopyType);
261+
assertNotEquals(origType, otherType);
262+
assertEquals("anewtype", origType.name);
235263
Tree t1 = new DefaultTree(TypeSet.type("foo"));
236264
Tree t2 = new DefaultTree(TypeSet.type("foo"));
237265
assertTrue(t1.hasSameType(t2));

0 commit comments

Comments
 (0)