You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/CategoryTests.java
+36-12
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2009-2019 the original author or authors.
2
+
* Copyright 2009-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ public final class CategoryTests extends GroovyCompilerTestSuite {
27
27
publicvoidtestCategory0() {
28
28
//@formatter:off
29
29
String[] sources = {
30
-
"Demo.groovy",
30
+
"Main.groovy",
31
31
"use(NumberCategory) {\n" +
32
32
" def dist = 300.meters\n" +
33
33
" \n" +
@@ -58,7 +58,7 @@ public void testCategory0() {
58
58
publicvoidtestCategory1() {
59
59
//@formatter:off
60
60
String[] sources = {
61
-
"Demo.groovy",
61
+
"Main.groovy",
62
62
"use(NumberCategory) {\n" +
63
63
" def dist = 300.meters\n" +
64
64
" \n" +
@@ -89,7 +89,7 @@ public void testCategory1() {
89
89
publicvoidtestCategory2() {
90
90
//@formatter:off
91
91
String[] sources = {
92
-
"Foo.groovy",
92
+
"Main.groovy",
93
93
"assert new Plane().fly() ==\n" +
94
94
" \"I'm the Concorde and I fly!\"\n" +
95
95
"assert new Submarine().dive() ==\n" +
@@ -139,11 +139,35 @@ public void testCategory2() {
139
139
runConformTest(sources, "I'm the James Bond's vehicle and I dive!");
140
140
}
141
141
142
+
@Test
143
+
publicvoidtestCategory8433() {
144
+
//@formatter:off
145
+
String[] sources = {
146
+
"Main.groovy",
147
+
"use(NumberCategory) {\n" +
148
+
" print 1.something()\n" +
149
+
"}\n",
150
+
151
+
"NumberCategory.groovy",
152
+
"@Category(Number) class NumberCategory {\n" +
153
+
" def something() {\n" +
154
+
" String variable = 'works'\n" +
155
+
" new Object() {\n" + // cast exception due to implicit first param "this"
156
+
" String toString() { variable }\n" +
157
+
" }\n" +
158
+
" }\n" +
159
+
"}\n",
160
+
};
161
+
//@formatter:on
162
+
163
+
runConformTest(sources, "works");
164
+
}
165
+
142
166
@Test// not a great test, needs work
143
167
publicvoidtestCategory_STS3822() {
144
168
//@formatter:off
145
169
String[] sources = {
146
-
"bad.groovy",
170
+
"Bad.groovy",
147
171
"@Category(C.class) \n" +
148
172
"@ScriptMixin(C.class)\n" +
149
173
"class Bad {\n" +
@@ -156,37 +180,37 @@ public void testCategory_STS3822() {
156
180
157
181
runNegativeTest(sources,
158
182
"----------\n" +
159
-
"1. ERROR in bad.groovy (at line 1)\n" +
183
+
"1. ERROR in Bad.groovy (at line 1)\n" +
160
184
"\t@Category(C.class) \n" +
161
185
"\t^^^^^^^^^^^^^^^^^^\n" +
162
186
"Groovy:@groovy.lang.Category must define \'value\' which is the class to apply this category to\n" +
163
187
"----------\n" +
164
-
"2. ERROR in bad.groovy (at line 1)\n" +
188
+
"2. ERROR in Bad.groovy (at line 1)\n" +
165
189
"\t@Category(C.class) \n" +
166
190
"\t ^\n" +
167
191
"Groovy:unable to find class \'C.class\' for annotation attribute constant\n" +
168
192
"----------\n" +
169
-
"3. ERROR in bad.groovy (at line 1)\n" +
193
+
"3. ERROR in Bad.groovy (at line 1)\n" +
170
194
"\t@Category(C.class) \n" +
171
195
"\t ^^^^^^^\n" +
172
196
"Groovy:Only classes and closures can be used for attribute \'value\' in @groovy.lang.Category\n" +
173
197
"----------\n" +
174
-
"4. ERROR in bad.groovy (at line 2)\n" +
198
+
"4. ERROR in Bad.groovy (at line 2)\n" +
175
199
"\t@ScriptMixin(C.class)\n" +
176
200
"\t^^^^^^^^^^^^\n" +
177
201
"Groovy:class ScriptMixin is not an annotation in @ScriptMixin\n" +
178
202
"----------\n" +
179
-
"5. ERROR in bad.groovy (at line 2)\n" +
203
+
"5. ERROR in Bad.groovy (at line 2)\n" +
180
204
"\t@ScriptMixin(C.class)\n" +
181
205
"\t ^^^^^^^^^^^\n" +
182
206
"Groovy:unable to resolve class ScriptMixin for annotation\n" +
183
207
"----------\n" +
184
-
"6. ERROR in bad.groovy (at line 2)\n" +
208
+
"6. ERROR in Bad.groovy (at line 2)\n" +
185
209
"\t@ScriptMixin(C.class)\n" +
186
210
"\t ^\n" +
187
211
"Groovy:unable to find class \'C.class\' for annotation attribute constant\n" +
188
212
"----------\n" +
189
-
"7. ERROR in bad.groovy (at line 4)\n" +
213
+
"7. ERROR in Bad.groovy (at line 4)\n" +
190
214
"\t@Override\n" +
191
215
"\t^^^^^^^^^\n" +
192
216
"Groovy:Method \'toString\' from class \'Bad\' does not override method from its superclass or interfaces but is annotated with @Override.\n" +
0 commit comments