@Test
public void testParseType() throws Exception {
{
FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
DefaultJavadocScanner scanner = string("A");
IrDocBlock block = parser.parse(null, scanner);
List<? extends IrDocFragment> fragments = block.getFragments();
assertKinds(fragments, NAMED_TYPE);
assertEquals("A", ((IrDocNamedType) fragments.get(0)).getName().asString());
}
{
FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
DefaultJavadocScanner scanner = string("hoge.foo.Bar");
IrDocBlock block = parser.parse(null, scanner);
List<? extends IrDocFragment> fragments = block.getFragments();
assertKinds(fragments, NAMED_TYPE);
assertEquals("hoge.foo.Bar", ((IrDocNamedType) fragments.get(0)).getName().asString());
}
{
FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
DefaultJavadocScanner scanner = string(
"\n"
+ " * hoge.foo.Bar");
IrDocBlock block = parser.parse(null, scanner);
List<? extends IrDocFragment> fragments = block.getFragments();
assertKinds(fragments, NAMED_TYPE);
assertEquals("hoge.foo.Bar", ((IrDocNamedType) fragments.get(0)).getName().asString());
}
{
FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
DefaultJavadocScanner scanner = string(
"\n"
+ " * hoge.foo.Bar?");
IrDocBlock block = parser.parse(null, scanner);
List<? extends IrDocFragment> fragments = block.getFragments();
assertKinds(fragments, TEXT);
assertTextEquals("hoge.foo.Bar?", fragments.get(0));
}
{
FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
DefaultJavadocScanner scanner = string(
" hoge.foo.Bar This is a pen.");
IrDocBlock block = parser.parse(null, scanner);
List<? extends IrDocFragment> fragments = block.getFragments();
assertKinds(fragments, NAMED_TYPE, TEXT);
assertEquals("hoge.foo.Bar", ((IrDocNamedType) fragments.get(0)).getName().asString());
assertTextEquals(" This is a pen.", fragments.get(1));
}
}