Skip to content

Commit 6f1419f

Browse files
committed
GROOVY-8219, GROOVY-11142
1 parent e2c2144 commit 6f1419f

File tree

1 file changed

+49
-12
lines changed
  • base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic

1 file changed

+49
-12
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/TraitsTests.java

+49-12
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,25 @@ public void testTraits5() {
189189
runConformTest(sources, "class Foo");
190190
}
191191

192+
@Test
193+
public void testTraits5a() {
194+
//@formatter:off
195+
String[] sources = {
196+
"Script.groovy",
197+
"trait Introspector {\n" +
198+
" void whoAmI() { print this }\n" +
199+
"}\n" +
200+
"class Foo implements Introspector {\n" +
201+
" String toString() { 'Foo' }\n" +
202+
"}\n" +
203+
"def foo = new Foo()\n" +
204+
"foo.whoAmI()\n",
205+
};
206+
//@formatter:on
207+
208+
runConformTest(sources, "Foo");
209+
}
210+
192211
@Test // Interfaces
193212
public void testTraits6() {
194213
//@formatter:off
@@ -939,7 +958,7 @@ public void testTraits36() {
939958
"----------\n");
940959
}
941960

942-
@Test // Test @Trait annotation
961+
@Test // @Trait annotation
943962
public void testTraits37() {
944963
//@formatter:off
945964
String[] sources = {
@@ -958,7 +977,7 @@ public void testTraits37() {
958977
runConformTest(sources, "a");
959978
}
960979

961-
@Test // Test @Trait annotation
980+
@Test // @Trait annotation
962981
public void testTraits38() {
963982
//@formatter:off
964983
String[] sources = {
@@ -978,7 +997,7 @@ public void testTraits38() {
978997
runConformTest(sources, "a");
979998
}
980999

981-
@Test // Test @Trait annotation
1000+
@Test // @Trait annotation
9821001
public void testTraits39() {
9831002
//@formatter:off
9841003
String[] sources = {
@@ -998,7 +1017,7 @@ public void testTraits39() {
9981017
runConformTest(sources, "a");
9991018
}
10001019

1001-
@Test // Negative test for @Trait annotation
1020+
@Test // @Trait annotation
10021021
public void testTraits40() {
10031022
//@formatter:off
10041023
String[] sources = {
@@ -1022,7 +1041,7 @@ public void testTraits40() {
10221041
"----------\n");
10231042
}
10241043

1025-
@Test // Negative test for @Trait annotation
1044+
@Test // @Trait annotation
10261045
public void testTraits41() {
10271046
//@formatter:off
10281047
String[] sources = {
@@ -1050,7 +1069,7 @@ public void testTraits41() {
10501069
"----------\n");
10511070
}
10521071

1053-
@Test // Negative test for @Trait annotation
1072+
@Test // @Trait annotation
10541073
public void testTraits42() {
10551074
//@formatter:off
10561075
String[] sources = {
@@ -1076,7 +1095,7 @@ public void testTraits42() {
10761095
"----------\n");
10771096
}
10781097

1079-
@Test // Negative test for @Trait annotation
1098+
@Test // @Trait annotation
10801099
public void testTraits43() {
10811100
//@formatter:off
10821101
String[] sources = {
@@ -1218,7 +1237,7 @@ public void testTraits48() {
12181237
runConformTest(sources, "a");
12191238
}
12201239

1221-
@Test // Test protected method of superclass overriding by trait method - different packages
1240+
@Test // protected method of superclass overriding by trait method - different packages
12221241
public void testTraits49() {
12231242
//@formatter:off
12241243
String[] sources = {
@@ -1249,7 +1268,7 @@ public void testTraits49() {
12491268
runConformTest(sources, "a");
12501269
}
12511270

1252-
@Test // Test protected method of superclass and traits method overriding by class
1271+
@Test // protected method of superclass and traits method overriding by class
12531272
public void testTraits50() {
12541273
//@formatter:off
12551274
String[] sources = {
@@ -1297,7 +1316,7 @@ public void testTraits51() {
12971316
"----------\n");
12981317
}
12991318

1300-
@Test // Test protected method of superclass and traits method overriding by class - positive test
1319+
@Test // protected method of superclass and traits method overriding by class - positive test
13011320
public void testTraits52() {
13021321
//@formatter:off
13031322
String[] sources = {
@@ -2125,7 +2144,7 @@ public void testTraits8049() {
21252144
runConformTest(sources, "WORKS");
21262145
}
21272146

2128-
@Ignore @Test // see also GROOVY-7950
2147+
@Test // see also GROOVY-7950
21292148
public void testTraits8219() {
21302149
//@formatter:off
21312150
String[] sources = {
@@ -2142,7 +2161,7 @@ public void testTraits8219() {
21422161
};
21432162
//@formatter:on
21442163

2145-
runConformTest(sources, "42");
2164+
runConformTest(sources, isAtLeastGroovy(50) ? "42" : "null");
21462165
}
21472166

21482167
@Test
@@ -3131,4 +3150,22 @@ public void testTraits11012() {
31313150

31323151
runConformTest(sources);
31333152
}
3153+
3154+
@Test
3155+
public void testTraits11142() {
3156+
//@formatter:off
3157+
String[] sources = {
3158+
"Script.groovy",
3159+
"trait T {\n" +
3160+
" def m() { print proxyTarget }\n" + // what about "this"
3161+
"}\n" +
3162+
"class C {\n" +
3163+
" String toString() { 'C' }\n" +
3164+
"}\n" +
3165+
"(new C() as T).m()\n",
3166+
};
3167+
//@formatter:on
3168+
3169+
runConformTest(sources, "C");
3170+
}
31343171
}

0 commit comments

Comments
 (0)