Search in sources :

Example 1 with WildComments

use of spoon.test.comment.testclasses.WildComments in project spoon by INRIA.

the class CommentTest method testWildComments.

@Test
public void testWildComments() {
    // contract: tests that value of comment is correct even for wild combinations of characters. See WildComments class for details
    Factory f = getSpoonFactory();
    CtClass<?> type = (CtClass<?>) f.Type().get(WildComments.class);
    List<CtLiteral<String>> literals = (List) ((CtNewArray<?>) type.getField("comments").getDefaultExpression()).getElements();
    assertTrue(literals.size() > 10);
    /*
		 * each string literal has a comment and string value, which defines expected value of it's comment
		 */
    for (CtLiteral<String> literal : literals) {
        assertEquals(1, literal.getComments().size());
        CtComment comment = literal.getComments().get(0);
        String expected = literal.getValue();
        assertEquals(literal.getPosition().toString(), expected, comment.getContent());
    }
}
Also used : CtClass(spoon.reflect.declaration.CtClass) CtComment(spoon.reflect.code.CtComment) CtLiteral(spoon.reflect.code.CtLiteral) DefaultCoreFactory(spoon.support.DefaultCoreFactory) Factory(spoon.reflect.factory.Factory) List(java.util.List) ArrayList(java.util.ArrayList) WildComments(spoon.test.comment.testclasses.WildComments) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.Test)1 CtComment (spoon.reflect.code.CtComment)1 CtLiteral (spoon.reflect.code.CtLiteral)1 CtClass (spoon.reflect.declaration.CtClass)1 Factory (spoon.reflect.factory.Factory)1 DefaultCoreFactory (spoon.support.DefaultCoreFactory)1 WildComments (spoon.test.comment.testclasses.WildComments)1