Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ void testComments() throws ParseException {
assertEquals("# bye ", converter.doConvert("/* bye */").replace("\n", ""));
}

@Test
void testSlashSlashInString() throws ParseException {
assertEquals("x = 'https://autoplog.org/'", converter.doConvert("String x = \"https://autoplog.org/\";"));
}

@Test
void testArithmeticOps() throws ParseException {
assertEquals("-x * y + z / 2 - 5", converter.doConvert("-x*y+z/2-5"));
Expand Down Expand Up @@ -119,5 +124,24 @@ void testSwitch() throws ParseException {
" return result");
assertLinesMatch(expectedPython, Arrays.asList(converter.doConvert(javaProgram).split("\n+")));
}

@Test
void testFullClassWithSlashSlashInString() throws ParseException {
String javaProgram = "package test;\n" +
"public class TestServletPWD {\n" +
" public static void main( String[] args ) {\n" +
" String vapurl= \"https://github.com/autoplot/dev/blob/master/demos/2024/20240907/kodalith.vap\";\n" +
" System.out.println(vapurl);\n" +
" }\n" +
"}";
// Currently strips the class definition
List<String> expectedPython = Arrays.asList("",
"def main(args):",
" vapurl = 'https://github.com/autoplot/dev/blob/master/demos/2024/20240907/kodalith.vap'",
" print(vapurl)",
"if __name__ == '__main__':",
" main([])");
assertLinesMatch(expectedPython, Arrays.asList(converter.doConvert(javaProgram).split("\n+")));
}
}