Skip to content

Commit

Permalink
Merge pull request #542 from ruslansennov/functionTest
Browse files Browse the repository at this point in the history
Function*.parameterType*() tests added #477
  • Loading branch information
danieldietrich committed Sep 2, 2015
2 parents ba29c92 + d184711 commit 64a872d
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions generator/Generator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ def generateTestClasses(): Unit = {
public void shouldGetType() {
final $name$i<${(1 to i + 1).gen(j => "Integer")(", ")}> f = (${(1 to i).gen(j => s"i$j")(", ")}) -> null;
final $name$i.Type<${(1 to i + 1).gen(j => "Integer")(", ")}> type = f.getType();
${(1 to i).gen(j => s"assertThat(type.parameterType$j()).isEqualTo(Integer.class);")("\n")}
$assertThat(type.toString()).isEqualTo("(${(1 to i).gen(j => "java.lang.Integer")(", ")}) -> java.lang.Integer");
}
}
Expand Down
1 change: 1 addition & 0 deletions src-gen/test/java/javaslang/CheckedFunction0Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final CheckedFunction0<Integer> f = () -> null;
final CheckedFunction0.Type<Integer> type = f.getType();

assertThat(type.toString()).isEqualTo("() -> java.lang.Integer");
}
}
1 change: 1 addition & 0 deletions src-gen/test/java/javaslang/CheckedFunction1Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public void shouldComposeWithCompose() {
public void shouldGetType() {
final CheckedFunction1<Integer, Integer> f = (i1) -> null;
final CheckedFunction1.Type<Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer) -> java.lang.Integer");
}
}
2 changes: 2 additions & 0 deletions src-gen/test/java/javaslang/CheckedFunction2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final CheckedFunction2<Integer, Integer, Integer> f = (i1, i2) -> null;
final CheckedFunction2.Type<Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
3 changes: 3 additions & 0 deletions src-gen/test/java/javaslang/CheckedFunction3Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final CheckedFunction3<Integer, Integer, Integer, Integer> f = (i1, i2, i3) -> null;
final CheckedFunction3.Type<Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
4 changes: 4 additions & 0 deletions src-gen/test/java/javaslang/CheckedFunction4Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final CheckedFunction4<Integer, Integer, Integer, Integer, Integer> f = (i1, i2, i3, i4) -> null;
final CheckedFunction4.Type<Integer, Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.parameterType4()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
5 changes: 5 additions & 0 deletions src-gen/test/java/javaslang/CheckedFunction5Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final CheckedFunction5<Integer, Integer, Integer, Integer, Integer, Integer> f = (i1, i2, i3, i4, i5) -> null;
final CheckedFunction5.Type<Integer, Integer, Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.parameterType4()).isEqualTo(Integer.class);
assertThat(type.parameterType5()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
6 changes: 6 additions & 0 deletions src-gen/test/java/javaslang/CheckedFunction6Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final CheckedFunction6<Integer, Integer, Integer, Integer, Integer, Integer, Integer> f = (i1, i2, i3, i4, i5, i6) -> null;
final CheckedFunction6.Type<Integer, Integer, Integer, Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.parameterType4()).isEqualTo(Integer.class);
assertThat(type.parameterType5()).isEqualTo(Integer.class);
assertThat(type.parameterType6()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
7 changes: 7 additions & 0 deletions src-gen/test/java/javaslang/CheckedFunction7Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final CheckedFunction7<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> f = (i1, i2, i3, i4, i5, i6, i7) -> null;
final CheckedFunction7.Type<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.parameterType4()).isEqualTo(Integer.class);
assertThat(type.parameterType5()).isEqualTo(Integer.class);
assertThat(type.parameterType6()).isEqualTo(Integer.class);
assertThat(type.parameterType7()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
8 changes: 8 additions & 0 deletions src-gen/test/java/javaslang/CheckedFunction8Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final CheckedFunction8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> f = (i1, i2, i3, i4, i5, i6, i7, i8) -> null;
final CheckedFunction8.Type<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.parameterType4()).isEqualTo(Integer.class);
assertThat(type.parameterType5()).isEqualTo(Integer.class);
assertThat(type.parameterType6()).isEqualTo(Integer.class);
assertThat(type.parameterType7()).isEqualTo(Integer.class);
assertThat(type.parameterType8()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
1 change: 1 addition & 0 deletions src-gen/test/java/javaslang/Function0Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final Function0<Integer> f = () -> null;
final Function0.Type<Integer> type = f.getType();

assertThat(type.toString()).isEqualTo("() -> java.lang.Integer");
}
}
1 change: 1 addition & 0 deletions src-gen/test/java/javaslang/Function1Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public void shouldComposeWithCompose() {
public void shouldGetType() {
final Function1<Integer, Integer> f = (i1) -> null;
final Function1.Type<Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer) -> java.lang.Integer");
}
}
2 changes: 2 additions & 0 deletions src-gen/test/java/javaslang/Function2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final Function2<Integer, Integer, Integer> f = (i1, i2) -> null;
final Function2.Type<Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
3 changes: 3 additions & 0 deletions src-gen/test/java/javaslang/Function3Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final Function3<Integer, Integer, Integer, Integer> f = (i1, i2, i3) -> null;
final Function3.Type<Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
4 changes: 4 additions & 0 deletions src-gen/test/java/javaslang/Function4Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final Function4<Integer, Integer, Integer, Integer, Integer> f = (i1, i2, i3, i4) -> null;
final Function4.Type<Integer, Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.parameterType4()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
5 changes: 5 additions & 0 deletions src-gen/test/java/javaslang/Function5Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final Function5<Integer, Integer, Integer, Integer, Integer, Integer> f = (i1, i2, i3, i4, i5) -> null;
final Function5.Type<Integer, Integer, Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.parameterType4()).isEqualTo(Integer.class);
assertThat(type.parameterType5()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
6 changes: 6 additions & 0 deletions src-gen/test/java/javaslang/Function6Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final Function6<Integer, Integer, Integer, Integer, Integer, Integer, Integer> f = (i1, i2, i3, i4, i5, i6) -> null;
final Function6.Type<Integer, Integer, Integer, Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.parameterType4()).isEqualTo(Integer.class);
assertThat(type.parameterType5()).isEqualTo(Integer.class);
assertThat(type.parameterType6()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
7 changes: 7 additions & 0 deletions src-gen/test/java/javaslang/Function7Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final Function7<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> f = (i1, i2, i3, i4, i5, i6, i7) -> null;
final Function7.Type<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.parameterType4()).isEqualTo(Integer.class);
assertThat(type.parameterType5()).isEqualTo(Integer.class);
assertThat(type.parameterType6()).isEqualTo(Integer.class);
assertThat(type.parameterType7()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}
8 changes: 8 additions & 0 deletions src-gen/test/java/javaslang/Function8Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ public void shouldComposeWithAndThen() {
public void shouldGetType() {
final Function8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> f = (i1, i2, i3, i4, i5, i6, i7, i8) -> null;
final Function8.Type<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> type = f.getType();
assertThat(type.parameterType1()).isEqualTo(Integer.class);
assertThat(type.parameterType2()).isEqualTo(Integer.class);
assertThat(type.parameterType3()).isEqualTo(Integer.class);
assertThat(type.parameterType4()).isEqualTo(Integer.class);
assertThat(type.parameterType5()).isEqualTo(Integer.class);
assertThat(type.parameterType6()).isEqualTo(Integer.class);
assertThat(type.parameterType7()).isEqualTo(Integer.class);
assertThat(type.parameterType8()).isEqualTo(Integer.class);
assertThat(type.toString()).isEqualTo("(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer) -> java.lang.Integer");
}
}

0 comments on commit 64a872d

Please sign in to comment.