Skip to content

Commit

Permalink
fix #3
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed May 16, 2018
1 parent 0547ceb commit ca2cbf4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private final static void log( String fmt, Object ...args ) {

private final static void debug( String fmt, Object ...args ) {
System.out.print( "DEBUG: ");
System.out.println( format( fmt, (Object[])args));
System.out.println( format( fmt, args));
}


Expand Down Expand Up @@ -301,7 +301,7 @@ else if( t instanceof WildcardType ) {

// CHECK FOR NESTED WILDCARDTYPE
if( tt instanceof ParameterizedType &&
Stream.of((Type[])((ParameterizedType)tt).getActualTypeArguments())
Stream.of(((ParameterizedType)tt).getActualTypeArguments())
.anyMatch( arg -> (arg instanceof WildcardType) ))
{
final Class<?> clazz = (Class<?>) (((ParameterizedType)tt).getRawType());
Expand All @@ -314,7 +314,7 @@ else if( t instanceof WildcardType ) {
}
}
else if( t instanceof GenericArrayType ) {
throw new IllegalArgumentException( format("type argument <%s> 'GenericArrayType' is a not supported yet!", t));
//throw new IllegalArgumentException( format("type argument <%s> 'GenericArrayType' is a not supported yet!", t));
}

}
Expand Down
11 changes: 5 additions & 6 deletions core/src/test/java/org/bsc/java2typescript/ConverterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import java.util.function.Consumer;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
import org.junit.Assert;
import org.junit.Test;
Expand All @@ -26,10 +25,10 @@ interface Action2 {
public void functionalInterfaceTest() {


Assert.assertThat(TypescriptConverter.isFunctionalInterface(java.lang.Runnable.class) , is(true));
Assert.assertThat(TypescriptConverter.isFunctionalInterface(Consumer.class) , is(true));
Assert.assertThat(TypescriptConverter.isFunctionalInterface(Action.class) , is(true));
Assert.assertThat(TypescriptConverter.isFunctionalInterface(Action.class), is(true));
Assert.assertThat(TypescriptConverter.isFunctionalInterface(Action2.class) , is(false));
Assert.assertThat(TypescriptConverter.isFunctionalInterface(java.lang.Runnable.class) , equalTo(true));
Assert.assertThat(TypescriptConverter.isFunctionalInterface(Consumer.class) , equalTo(true));
Assert.assertThat(TypescriptConverter.isFunctionalInterface(Action.class) , equalTo(true));
Assert.assertThat(TypescriptConverter.isFunctionalInterface(Action.class), equalTo(true));
Assert.assertThat(TypescriptConverter.isFunctionalInterface(Action2.class) , equalTo(false));
}
}
18 changes: 18 additions & 0 deletions core/src/test/java/org/bsc/java2typescript/ProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,24 @@ public void testSample1() throws Exception {

}

@Test
public void testSample1_GenericArrayType() throws Exception {
final Class<?> type = Sample1.class;
final Object[] arr = {};

final Method m = type.getMethod("genericArrayType", arr.getClass());
final String result =
converter.getMethodParametersAndReturnDecl( m,
TSType.from(type),
declaredTypeMap( TSType.from(java.util.List.class)),
true) ;

Assert.assertThat( result, IsNull.notNullValue());
Assert.assertThat( result, IsEqual.equalTo("( c:[E] ):java.util.List<T[]>"));


}

String getReturnType( Class<?> type, String methonName, Class<?> ...args ) throws Exception {
return getReturnType(Collections.emptyMap(), type, methonName, (Class<?>[])args);
}
Expand Down
1 change: 1 addition & 0 deletions core/src/test/java/org/bsc/java2typescript/Sample1.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ public interface Sample1<E> {
<T> void merge(BiConsumer<E,Sample2<? extends Sample2<? extends T>>> source);
<T> T concatMap(Function<? super E, ? extends Sample2<? extends T>> mapper);

<T> java.util.List<T[]> genericArrayType( E[] c );
}

0 comments on commit ca2cbf4

Please sign in to comment.