@Test
public void testLoopWithLabel() {
String orig = "public class SchemaParser {\n" +
" public static void parse(ParseContext context) {\n" +
" LOOP: while (context.hasNext()) {\n" +
" switch (context.next()) {\n" +
" case XMLEvent.START_ELEMENT:\n" +
" if (context.getTag(1).equals(\"SimpleField\")) {\n" +
" parseSimpleField(context, builder, oldSchema);\n" +
" }\n" +
" continue LOOP;\n" +
" case XMLEvent.CHARACTERS:\n" +
" switch (context.getTag(1)) {\n" +
" case \"name\":\n" +
" name = context.getText();\n" +
" continue LOOP;\n" +
" case \"parent\":\n" +
" parentId = context.getText();\n" +
" continue LOOP;\n" +
" default: continue LOOP;\n" +
" }\n" +
" default: continue LOOP;\n" +
" }\n" +
" }\n" +
" }\n" +
"}";
Parser parser = new OracleJdkParser();
Tr.CompilationUnit cu = parser.parse(orig);
assertEquals("Should parse the file correctly", orig, cu.print());
}
The above test fails because an extra : is appended at the end of the closing brace of the while loop. Admittedly this is some ugly looking code, but it should still work.
It is worth noting that if you take the method out of the class and parse it by itself, it does actually work. So this test only fails as long as this method is inside of a class.
The above test fails because an extra
:
is appended at the end of the closing brace of the while loop. Admittedly this is some ugly looking code, but it should still work.It is worth noting that if you take the method out of the class and parse it by itself, it does actually work. So this test only fails as long as this method is inside of a class.