diff --git a/src/test/java/org/cqfn/astranaut/core/base/HoleTest.java b/src/test/java/org/cqfn/astranaut/core/base/HoleTest.java index 81fcdfd..867dff0 100644 --- a/src/test/java/org/cqfn/astranaut/core/base/HoleTest.java +++ b/src/test/java/org/cqfn/astranaut/core/base/HoleTest.java @@ -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); } } diff --git a/src/test/java/org/cqfn/astranaut/core/base/MutableNodeTest.java b/src/test/java/org/cqfn/astranaut/core/base/MutableNodeTest.java index 4c25201..4e6747f 100644 --- a/src/test/java/org/cqfn/astranaut/core/base/MutableNodeTest.java +++ b/src/test/java/org/cqfn/astranaut/core/base/MutableNodeTest.java @@ -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"); @@ -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); + } }