source: java2python/src/test/java/tudelft/utilities/j2p/PersonJsonTest.java@ 353

Last change on this file since 353 was 346, checked in by wouter, 2 years ago

version 0.1 of automatic java to python translator. Can translate some simple programs, lot of work remains to be done

File size: 807 bytes
Line 
1package tudelft.utilities.j2p;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.IOException;
6import java.util.Arrays;
7import java.util.List;
8
9import org.junit.Test;
10
11public class PersonJsonTest extends PyTest {
12
13 private static final String TESTDIR = "src/test/java/";
14 private static final String FULLNAME = "testcode/PersonJson.java";
15
16 @Test
17 public void test() throws IOException, ClassNotFoundException {
18 System.out.println("TRANSLATION:");
19 System.out.println(translate(TESTDIR + FULLNAME));
20 }
21
22 @Test
23 public void runInPython() throws Exception {
24
25 List<String> res = runPython(translate(TESTDIR + FULLNAME),
26 FULLNAME.replace(".java", ".py"));
27 assertEquals(Arrays.asList("Person[Kees,25]\n"
28 + "{\"PersonJson\":{\"name\":\"Kees\",\"age\":25}}\n" + "true"),
29 res);
30 }
31
32}
Note: See TracBrowser for help on using the repository browser.