use of spoon.test.template.testclasses.SubstitutionByExpressionTemplate in project spoon by INRIA.
the class TemplateInvocationSubstitutionTest method testSubstitutionByExpression.
@Test
public void testSubstitutionByExpression() throws Exception {
// contract: the template engine understands fields whose type extends from TemplateParameter as template parameter automatically. No need for extra annotation
Launcher spoon = new Launcher();
spoon.addTemplateResource(new FileSystemFile("./src/test/java/spoon/test/template/testclasses/SubstitutionByExpressionTemplate.java"));
spoon.buildModel();
Factory factory = spoon.getFactory();
CtClass<?> resultKlass = factory.Class().create("Result");
CtBlock<?> result = new SubstitutionByExpressionTemplate(factory.createLiteral("abc")).apply(resultKlass);
assertEquals("java.lang.System.out.println(\"abc\".substring(1))", result.getStatement(0).toString());
}
Aggregations