use of spoon.test.template.testclasses.InvocationSubstitutionByExpressionTemplate in project spoon by INRIA.
the class TemplateInvocationSubstitutionTest method testInvocationSubstitutionByExpression.
@Test
public void testInvocationSubstitutionByExpression() throws Exception {
// contract: the template engine supports substitution of any method invocation
Launcher spoon = new Launcher();
spoon.addTemplateResource(new FileSystemFile("./src/test/java/spoon/test/template/testclasses/InvocationSubstitutionByExpressionTemplate.java"));
spoon.buildModel();
Factory factory = spoon.getFactory();
CtClass<?> resultKlass = factory.Class().create("Result");
CtBlock<?> result = new InvocationSubstitutionByExpressionTemplate(factory.createLiteral("abc")).apply(resultKlass);
assertEquals("java.lang.System.out.println(\"abc\".substring(1))", result.getStatement(0).toString());
assertEquals("java.lang.System.out.println(\"abc\".substring(1))", result.getStatement(1).toString());
}
Aggregations