File tree 2 files changed +60
-1
lines changed
core/src/test/java/org/bsc/java2typescript
2 files changed +60
-1
lines changed Original file line number Diff line number Diff line change
1
+ package org .bsc .java2typescript ;
2
+
3
+ import org .junit .Assert ;
4
+ import org .junit .Before ;
5
+ import org .junit .Test ;
6
+
7
+ import java .util .Arrays ;
8
+ import java .util .Collections ;
9
+ import java .util .Optional ;
10
+
11
+ public class Issue34Test extends AbstractConverterTest {
12
+
13
+ @ Test
14
+ public void convertListTest () {
15
+
16
+ final Java2TSConverter converter =
17
+ Java2TSConverter .builder ()
18
+ .compatibility (Java2TSConverter .Compatibility .GRAALJS )
19
+ .foreignObjectPrototype (true )
20
+ .build ();
21
+
22
+ int level = 0 ;
23
+
24
+ final String conversion = converter .javaClass2DeclarationTransformer (
25
+ level ,
26
+ TSType .of ( java .util .List .class ),
27
+ Collections .emptyMap ()
28
+ );
29
+
30
+ Assert .assertNotNull (conversion );
31
+
32
+ final String [] lines = conversion .split ( "\n " );
33
+
34
+ Assert .assertTrue ( lines .length > 3 );
35
+ Assert .assertEquals (
36
+ "interface List<E> extends Array<E>/* extends Collection<E> */ {" ,
37
+ lines [2 ] );
38
+
39
+ Optional <String > result = Arrays .stream (lines )
40
+ .map ( String ::trim )
41
+ .filter ( l -> l .startsWith ("forEach" ))
42
+ .filter ( l -> l .startsWith ("indexOf" ))
43
+ .filter ( l -> l .startsWith ("lastIndexOf" ))
44
+ .filter ( l -> l .startsWith ("sort" ))
45
+ .findFirst ();
46
+
47
+ Assert .assertFalse ( result .isPresent () );
48
+ }
49
+ }
Original file line number Diff line number Diff line change 1
1
package org .bsc .java2typescript ;
2
2
3
+ import org .junit .Before ;
3
4
import org .junit .Test ;
4
5
5
6
import java .lang .reflect .Constructor ;
15
16
* @author bsorrentino
16
17
*
17
18
*/
18
- public class TestIssue7 extends AbstractConverterTest {
19
+ public class Issue7Test extends AbstractConverterTest {
19
20
20
21
interface TestBean <K ,V > {
21
22
@@ -36,6 +37,15 @@ public TestBean1() {
36
37
}
37
38
}
38
39
40
+ private Java2TSConverter converter ;
41
+
42
+ @ Before
43
+ public void initConverter () {
44
+ converter = Java2TSConverter .builder ()
45
+ .compatibility (Java2TSConverter .Compatibility .NASHORN )
46
+ .build ();
47
+ }
48
+
39
49
@ Test
40
50
public void testMethod1 () throws Exception {
41
51
final Class <?> type = TestBean .class ;
You can’t perform that action at this time.
0 commit comments