@@ -887,14 +887,14 @@ public void testClosure5() {
887
887
}
888
888
889
889
@ Test
890
- public void testClosure5a () {
890
+ public void testClosure6 () {
891
891
assumeTrue (isParrotParser ());
892
892
String contents = "def fn = String[]::new" ;
893
893
assertType (contents , "fn" , "groovy.lang.Closure<java.lang.String[]>" );
894
894
}
895
895
896
896
@ Test
897
- public void testClosure6 () {
897
+ public void testClosure7 () {
898
898
String contents =
899
899
"void test(List<String> list) {\n " +
900
900
" def array = list.stream().toArray {\n " +
@@ -905,7 +905,7 @@ public void testClosure6() {
905
905
}
906
906
907
907
@ Test
908
- public void testClosure6a () {
908
+ public void testClosure8 () {
909
909
assumeTrue (isParrotParser ());
910
910
String contents =
911
911
"void test(List<String> list) {\n " +
@@ -916,7 +916,7 @@ public void testClosure6a() {
916
916
}
917
917
918
918
@ Test
919
- public void testClosure6b () {
919
+ public void testClosure9 () {
920
920
assumeTrue (isAtLeastGroovy (30 ));
921
921
String contents =
922
922
"void test(List<String> list) {\n " +
@@ -927,7 +927,7 @@ public void testClosure6b() {
927
927
}
928
928
929
929
@ Test // incorrect LHS type should not alter RHS type
930
- public void testClosure6c () {
930
+ public void testClosure10 () {
931
931
String contents =
932
932
"void test(List<String> list) {\n " +
933
933
" Number[] array = list.stream().toArray(String[].&new)\n " +
@@ -937,7 +937,7 @@ public void testClosure6c() {
937
937
}
938
938
939
939
@ Test // GROOVY-9803
940
- public void testClosure7 () {
940
+ public void testClosure11 () {
941
941
for (String toSet : new String [] {"D.&wrap" , "Collections.&singleton" , "{x -> [x].toSet()}" , "{Collections.singleton(it)}" }) {
942
942
String contents =
943
943
"class C<T> {\n " +
@@ -963,27 +963,27 @@ public void testClosure7() {
963
963
}
964
964
965
965
@ Test // https://github.com/groovy/groovy-eclipse/issues/1194
966
- public void testClosure8 () {
966
+ public void testClosure12 () {
967
967
String contents = "Optional.of(1).map(Arrays.&asList).map{x -> x.first()}\n " ;
968
968
assertType (contents , "asList" , "java.util.List<java.lang.Integer>" );
969
969
assertType (contents , "x" , "java.util.List<java.lang.Integer>" );
970
970
}
971
971
972
972
@ Test // https://github.com/groovy/groovy-eclipse/issues/1194
973
- public void testClosure9 () {
973
+ public void testClosure13 () {
974
974
String contents = "Optional.of(1).map(Collections.&singletonList).map{x -> x.first()}\n " ;
975
975
assertType (contents , "singletonList" , "java.util.List<java.lang.Integer>" );
976
976
assertType (contents , "x" , "java.util.List<java.lang.Integer>" );
977
977
}
978
978
979
979
@ Test // https://github.com/groovy/groovy-eclipse/issues/1194
980
- public void testClosure10 () {
980
+ public void testClosure14 () {
981
981
String contents = "void test(Closure<List<Integer>> cl) {}\n " + "test(Arrays.&asList)\n " ;
982
982
assertType (contents , "asList" , "java.util.List<java.lang.Integer>" );
983
983
}
984
984
985
985
@ Test // https://github.com/groovy/groovy-eclipse/issues/1194
986
- public void testClosure11 () {
986
+ public void testClosure15 () {
987
987
String contents = "import groovy.transform.stc.*\n " +
988
988
"def m(@ClosureParams(value=SimpleType,options='java.lang.Integer') Closure c) {}\n " +
989
989
"def <T> String test(T t) {}\n " +
@@ -996,22 +996,25 @@ public void testClosure11() {
996
996
}
997
997
998
998
@ Test // https://github.com/groovy/groovy-eclipse/issues/1198
999
- public void testClosure12 () {
999
+ public void testClosure16 () {
1000
1000
assumeTrue (isParrotParser ());
1001
1001
String contents = "Optional.of(21).map(num -> num * 2).get()\n " ;
1002
1002
assertType (contents , "get" , "java.lang.Integer" );
1003
1003
assertDeclaringType (contents , "get" , "java.util.Optional<java.lang.Integer>" );
1004
1004
}
1005
1005
1006
1006
@ Test // https://github.com/groovy/groovy-eclipse/issues/1199
1007
- public void testClosure13 () {
1007
+ public void testClosure17 () {
1008
1008
String contents = "java.util.function.Function<Integer, List<Integer>> f = Arrays.&asList\n " ;
1009
1009
assertType (contents , "asList" , "java.util.List<java.lang.Integer>" );
1010
1010
}
1011
1011
1012
1012
@ Test // https://github.com/groovy/groovy-eclipse/issues/1199
1013
- public void testClosure14 () {
1014
- String contents = "def <T> String test(T t) {}\n " + "java.util.function.Function<Integer, String> f = this.&test\n " ;
1013
+ public void testClosure18 () {
1014
+ String contents =
1015
+ "def <T> String test(T t) {}\n " +
1016
+ "java.util.function.Function<Integer, String> f = this.&test\n " ;
1017
+
1015
1018
int offset = contents .lastIndexOf ("test" );
1016
1019
1017
1020
MethodNode m = assertDeclaration (contents , offset , offset + 4 , "Search" , "test" , DeclarationKind .METHOD );
@@ -1020,16 +1023,44 @@ public void testClosure14() {
1020
1023
}
1021
1024
1022
1025
@ Test // https://github.com/groovy/groovy-eclipse/issues/1282
1023
- public void testClosure15 () {
1026
+ public void testClosure19 () {
1024
1027
String contents =
1025
1028
"def <T> void test(Iterator<T> it) {\n " +
1026
- " it.forEachRemaining{e->}\n " +
1029
+ " it.forEachRemaining{t->}\n " +
1030
+ "}\n " ;
1031
+ assertType (contents , "t" , "T" );
1032
+ }
1033
+
1034
+ @ Test // https://github.com/groovy/groovy-eclipse/issues/1000
1035
+ public void testClosure20 () {
1036
+ String contents =
1037
+ "void test(Collection<Integer> c) {\n " +
1038
+ " boolean b = c.removeIf{i->false}\n " +
1039
+ "}\n " ;
1040
+ assertType (contents , "i" , "java.lang.Integer" );
1041
+ }
1042
+
1043
+ @ Test // https://github.com/groovy/groovy-eclipse/issues/1000
1044
+ public void testClosure21 () {
1045
+ assumeTrue (isParrotParser ());
1046
+ String contents =
1047
+ "void test(Collection<Integer> c) {\n " +
1048
+ " boolean b = c.removeIf(i->false)\n " +
1027
1049
"}\n " ;
1028
- assertType (contents , "e " , "T " );
1050
+ assertType (contents , "i " , "java.lang.Integer " );
1029
1051
}
1030
1052
1031
1053
@ Test
1032
- public void testClosure16 () {
1054
+ public void testClosure22 () {
1055
+ String contents =
1056
+ "void test(Collection<Integer> c) {\n " +
1057
+ " boolean b = c.removeIf{Number n->}\n " +
1058
+ "}\n " ;
1059
+ assertType (contents , "n" , "java.lang.Number" );
1060
+ }
1061
+
1062
+ @ Test
1063
+ public void testClosure23 () {
1033
1064
String contents =
1034
1065
"void test(List list) {\n " +
1035
1066
" list.stream().map{e->}\n " +
0 commit comments