Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kniazkov committed Aug 23, 2024
1 parent 2bc2ef7 commit 2d16a26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/test/java/org/cqfn/astranaut/core/base/HoleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,19 @@ void testBaseInterface() {
hole.getProperties().getOrDefault("color", "")
);
Assertions.assertEquals(1, hole.getNumber());
Assertions.assertEquals("IntegerLiteral<#1>", hole.toString());
final Type type = hole.getType();
final String typename = "IntegerLiteral";
Assertions.assertEquals(typename, type.getName());
Assertions.assertEquals(typename, type.getHierarchy().get(0));
Assertions.assertFalse(type.getProperties().containsKey("abracadabra"));
Assertions.assertEquals(typename, node.getTypeName());
boolean oops = false;
try {
type.createBuilder();
} catch (final UnsupportedOperationException ignored) {
oops = true;
}
Assertions.assertTrue(oops);
}
}
16 changes: 13 additions & 3 deletions src/test/java/org/cqfn/astranaut/core/base/MutableNodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
* @since 1.0
*/
class MutableNodeTest {
/**
* Testing the transformation from 'typical' node to mutable.
*/
@Test
void testBaseInterface() {
final Node left = LittleTrees.createVariable("x");
Expand All @@ -59,4 +56,17 @@ void testBaseInterface() {
Assertions.assertFalse(result instanceof MutableNode);
Assertions.assertTrue(mutable.deepCompare(result));
}

@Test
void testBadTransformation() {
final Node left = LittleTrees.createIntegerLiteral(2);
final Node right = LittleTrees.createIntegerLiteral(3);
final Node original = LittleTrees.createAddition(left, right);
final MutableNode mutable = new MutableNode(original);
Assertions.assertTrue(
mutable.replaceChild(left, LittleTrees.createReturnStatement(null))
);
final Node result = mutable.rebuild();
Assertions.assertSame(DummyNode.INSTANCE, result);
}
}

0 comments on commit 2d16a26

Please sign in to comment.