Search in sources :

Example 1 with NtonCodeTemplate

use of spoon.test.template.testclasses.NtonCodeTemplate in project spoon by INRIA.

the class TemplateTest method testSubstitutionInsertAllNtoN.

@Test
public void testSubstitutionInsertAllNtoN() {
    Launcher spoon = new Launcher();
    spoon.addTemplateResource(new FileSystemFile("./src/test/java/spoon/test/template/testclasses/NtonCodeTemplate.java"));
    spoon.addInputResource("./src/test/java/spoon/test/template/testclasses/C.java");
    spoon.buildModel();
    Factory factory = spoon.getFactory();
    CtClass<?> cclass = factory.Class().get("spoon.test.template.testclasses.C");
    new NtonCodeTemplate(cclass.getReference(), 5).apply(cclass);
    Set<CtMethod<?>> listMethods = cclass.getMethods();
    assertEquals(0, cclass.getMethodsByName("apply").size());
    assertEquals(4, listMethods.size());
}
Also used : Launcher(spoon.Launcher) Factory(spoon.reflect.factory.Factory) FileSystemFile(spoon.support.compiler.FileSystemFile) NtonCodeTemplate(spoon.test.template.testclasses.NtonCodeTemplate) CtMethod(spoon.reflect.declaration.CtMethod) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Launcher (spoon.Launcher)1 CtMethod (spoon.reflect.declaration.CtMethod)1 Factory (spoon.reflect.factory.Factory)1 FileSystemFile (spoon.support.compiler.FileSystemFile)1 NtonCodeTemplate (spoon.test.template.testclasses.NtonCodeTemplate)1