public void testParse() throws Exception {
JavadocParserBuilder builder = new JavadocParserBuilder();
JavadocParser parser = builder.build();
{
DefaultJavadocScanner scanner = string("/***/");
IrDocComment doc = parser.parse(scanner);
List<? extends IrDocBlock> blocks = doc.getBlocks();
assertEquals(0, blocks.size());
}
{
DefaultJavadocScanner scanner = string("/** a */");
IrDocComment doc = parser.parse(scanner);
List<? extends IrDocBlock> blocks = doc.getBlocks();
assertEquals(1, blocks.size());
}
{
DefaultJavadocScanner scanner = string(
"/**\n"
+ " * a\n"
+ " * @tag\n"
+ " */");
IrDocComment doc = parser.parse(scanner);
List<? extends IrDocBlock> blocks = doc.getBlocks();
assertEquals(2, blocks.size());
assertNull(blocks.get(0).getTag());
assertEquals("@tag", blocks.get(1).getTag());
}
{
DefaultJavadocScanner scanner = string(
"/**\n"
+ " * a\n"
+ " * @tag1\n"
+ " * @tag2\n"
+ " */");
IrDocComment doc = parser.parse(scanner);
List<? extends IrDocBlock> blocks = doc.getBlocks();
assertEquals(3, blocks.size());
assertNull(blocks.get(0).getTag());
assertEquals("@tag1", blocks.get(1).getTag());
assertEquals("@tag2", blocks.get(2).getTag());
}