Skip to content

Commit 905ed3f

Browse files
committed
Make EmptyArray testcase runs with python unittest and junit 3.8
1 parent 1beb792 commit 905ed3f

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

java2python/tests/EmptyArray.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
class EmptyArray {
2-
int [] b;
3-
public static void main(String[] args) {
1+
import junit.framework.*;
2+
3+
public class EmptyArray extends TestCase {
4+
5+
public void testEmptyArray() {
6+
int [] b;
47
}
58

69
}

java2python/tests/Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
PYTHONPATH=../../:.
2+
CLASSPATH:=.:/usr/share/junit/lib/junit.jar
3+
4+
PYOBJS=AssignInExpr.py EmptyArray.py
5+
JAVAOBJS=AssignInExpr EmptyArray
6+
7+
all: python-test
8+
9+
python-test: $(PYOBJS)
10+
11+
java-test: $(JAVAOBJS)
12+
13+
%.py: %.java testconfig.py
14+
../bin/j2py -i $< -o $@ -c testconfig
15+
python $@
16+
17+
%: %.java
18+
javac $<
19+
java junit.textui.TestRunner $@
20+
21+
clean:
22+
rm -f $(PYOBJS)
23+
rm -f *.class *.pyc

java2python/tests/testconfig.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
5+
## lines written at the beginning of each generated module. this value
6+
## is cumulative, so when user-defined configuration modules specify
7+
## this value, those lines are written after these.
8+
modulePreamble = [
9+
'import unittest',
10+
'from unittest import TestCase',
11+
]
12+
13+
## lines written at the end of each generated module. this value is
14+
## cumulative, so user-defined configuration modules may specify
15+
## additional values.
16+
moduleEpilogue = [
17+
'if __name__ == "__main__":\n'
18+
' unittest.main()',
19+
]
20+
21+
variableNameMapping = {
22+
'Assert':'self',
23+
}
24+
25+

0 commit comments

Comments
 (0)