Skip to content

Commit 3747862

Browse files
hansonrhansonr
authored andcommitted
interface testing -- transpiler does allow static methods in interfaces
1 parent 91ab2db commit 3747862

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package test;
2+
3+
import swingjs.api.js.HTML5Canvas;
4+
5+
/**
6+
* called by JSmol JavaScript methods using
7+
*
8+
* this._appletPanel.xxxx$paramTypes()
9+
*
10+
*/
11+
public interface JSInterface {
12+
13+
public static int doTest(int i) {
14+
return i + 1;
15+
}
16+
17+
int cacheFileByName(String fileName, boolean isAdd); // $S$Z
18+
void cachePut(String key, Object data); // $S$O
19+
void destroy();
20+
String getFullName();
21+
void openFileAsyncSpecial(String fileName, int flags); // $S$I
22+
boolean processMouseEvent(int id, int x, int y, int modifiers, long time, Object jqevent, int scroll); // $I$I$I$I$J$O$I
23+
void processTwoPointGesture(float[][][] touches); // AFFF
24+
void setDisplay(HTML5Canvas canvas);
25+
void setScreenDimension(int width, int height);
26+
boolean setStatusDragDropped(int mode, int x, int y, String fileName);
27+
void startHoverWatcher(boolean enable);
28+
29+
}
30+

sources/net.sf.j2s.java.core/src/test/TApp2.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public TestGraphic(TApp2 tApp2) {
206206
}
207207

208208
void testGraphic() {
209-
Button b = new Button("g");
209+
Button b = new Button("MyM");
210210
b.setBounds(300, 300, 40, 20);
211211
// images are created only when a button is displayable
212212
Image i1 = b.createImage(100, 100);
@@ -220,6 +220,7 @@ void testGraphic() {
220220
Font f = g.getFont();
221221
System.out.println(f);
222222

223+
223224
// font/background/foreground are set when the graphic is created
224225
Font f0 = new Font(Font.DIALOG, Font.PLAIN, 30);
225226
b.setFont(f0);
@@ -235,6 +236,13 @@ void testGraphic() {
235236
assert (g.getFont().equals(f0));
236237
assert (g.getColor() == Color.green);
237238
assert (((Graphics2D) g).getBackground() == Color.red);
239+
240+
241+
b = new Button("XXX");
242+
b.setBounds(500, 100, 100, 100);
243+
tApp2.add(b);
244+
245+
238246
System.out.println("Tapp2 OK");
239247
}
240248
}

sources/net.sf.j2s.java.core/src/test/Test_Interface.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ String test(String s) {
1212
}
1313
}
1414

15-
15+
public static int doTest(int i) {
16+
return i + 1;
17+
}
18+
1619
public interface Test_Interface_inner {
1720
// This mus be wrapped, or C$ changes definitions
1821
}

sources/net.sf.j2s.java.core/src/test/Test_Interface2.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public static void main(String[] args) {
88
ClassLoader.getSystemClassLoader().setClassAssertionStatus("test.Test_Interface", true);
99
System.out.println("in the interface " + x + " " + y + " " + s.length);
1010
assert("5 y".equals(x + " " + y));
11+
assert(Test_Interface3.doTest(3) == 4);
1112
System.out.println("Test_Interface OK");
1213

1314
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package test;
2+
3+
public interface Test_Interface3 {
4+
5+
public static int doTest(int i) {
6+
return i + 1;
7+
}
8+
9+
10+
}

0 commit comments

Comments
 (0)