use of spoon.test.template.testclasses.SubstituteArrayLengthTemplate in project spoon by INRIA.
the class TemplateArrayAccessTest method testArrayLengthAccess.
@Test
public void testArrayLengthAccess() throws Exception {
// contract: the template engine replaces length of collection of parameter values by number
Launcher spoon = new Launcher();
spoon.addTemplateResource(new FileSystemFile("./src/test/java/spoon/test/template/testclasses/SubstituteArrayLengthTemplate.java"));
spoon.buildModel();
Factory factory = spoon.getFactory();
CtClass<?> resultKlass = factory.Class().create("Result");
CtStatement result = new SubstituteArrayLengthTemplate(new String[] { "a", null, "b" }).apply(resultKlass);
assertEquals("if (3 > 0);", result.toString());
}
Aggregations