Search in sources :

Example 1 with InlinePartialEvaluator

use of spoon.support.reflect.eval.InlinePartialEvaluator in project spoon by INRIA.

the class EvalTest method testVisitorPartialEvaluatorScanner.

@Test
public void testVisitorPartialEvaluatorScanner() throws Exception {
    Launcher launcher = new Launcher();
    launcher.addInputResource("src/test/java/spoon/test/eval/Foo.java");
    launcher.buildModel();
    VisitorPartialEvaluator eval = new VisitorPartialEvaluator();
    CtType<?> foo = launcher.getFactory().Type().get((Class<?>) Foo.class);
    foo.accept(new InlinePartialEvaluator(eval));
    assertEquals("false", foo.getElements(new TypeFilter<>(CtLocalVariable.class)).get(0).getDefaultExpression().toString());
    // the if has been removed
    assertEquals(0, foo.getElements(new TypeFilter<>(CtIf.class)).size());
}
Also used : InlinePartialEvaluator(spoon.support.reflect.eval.InlinePartialEvaluator) Launcher(spoon.Launcher) CtLocalVariable(spoon.reflect.code.CtLocalVariable) CtIf(spoon.reflect.code.CtIf) VisitorPartialEvaluator(spoon.support.reflect.eval.VisitorPartialEvaluator) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Launcher (spoon.Launcher)1 CtIf (spoon.reflect.code.CtIf)1 CtLocalVariable (spoon.reflect.code.CtLocalVariable)1 InlinePartialEvaluator (spoon.support.reflect.eval.InlinePartialEvaluator)1 VisitorPartialEvaluator (spoon.support.reflect.eval.VisitorPartialEvaluator)1