Skip to content

Commit

Permalink
GROOVY-8219, GROOVY-11142
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Aug 9, 2023
1 parent e2c2144 commit 6f1419f
Showing 1 changed file with 49 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,25 @@ public void testTraits5() {
runConformTest(sources, "class Foo");
}

@Test
public void testTraits5a() {
//@formatter:off
String[] sources = {
"Script.groovy",
"trait Introspector {\n" +
" void whoAmI() { print this }\n" +
"}\n" +
"class Foo implements Introspector {\n" +
" String toString() { 'Foo' }\n" +
"}\n" +
"def foo = new Foo()\n" +
"foo.whoAmI()\n",
};
//@formatter:on

runConformTest(sources, "Foo");
}

@Test // Interfaces
public void testTraits6() {
//@formatter:off
Expand Down Expand Up @@ -939,7 +958,7 @@ public void testTraits36() {
"----------\n");
}

@Test // Test @Trait annotation
@Test // @Trait annotation
public void testTraits37() {
//@formatter:off
String[] sources = {
Expand All @@ -958,7 +977,7 @@ public void testTraits37() {
runConformTest(sources, "a");
}

@Test // Test @Trait annotation
@Test // @Trait annotation
public void testTraits38() {
//@formatter:off
String[] sources = {
Expand All @@ -978,7 +997,7 @@ public void testTraits38() {
runConformTest(sources, "a");
}

@Test // Test @Trait annotation
@Test // @Trait annotation
public void testTraits39() {
//@formatter:off
String[] sources = {
Expand All @@ -998,7 +1017,7 @@ public void testTraits39() {
runConformTest(sources, "a");
}

@Test // Negative test for @Trait annotation
@Test // @Trait annotation
public void testTraits40() {
//@formatter:off
String[] sources = {
Expand All @@ -1022,7 +1041,7 @@ public void testTraits40() {
"----------\n");
}

@Test // Negative test for @Trait annotation
@Test // @Trait annotation
public void testTraits41() {
//@formatter:off
String[] sources = {
Expand Down Expand Up @@ -1050,7 +1069,7 @@ public void testTraits41() {
"----------\n");
}

@Test // Negative test for @Trait annotation
@Test // @Trait annotation
public void testTraits42() {
//@formatter:off
String[] sources = {
Expand All @@ -1076,7 +1095,7 @@ public void testTraits42() {
"----------\n");
}

@Test // Negative test for @Trait annotation
@Test // @Trait annotation
public void testTraits43() {
//@formatter:off
String[] sources = {
Expand Down Expand Up @@ -1218,7 +1237,7 @@ public void testTraits48() {
runConformTest(sources, "a");
}

@Test // Test protected method of superclass overriding by trait method - different packages
@Test // protected method of superclass overriding by trait method - different packages
public void testTraits49() {
//@formatter:off
String[] sources = {
Expand Down Expand Up @@ -1249,7 +1268,7 @@ public void testTraits49() {
runConformTest(sources, "a");
}

@Test // Test protected method of superclass and traits method overriding by class
@Test // protected method of superclass and traits method overriding by class
public void testTraits50() {
//@formatter:off
String[] sources = {
Expand Down Expand Up @@ -1297,7 +1316,7 @@ public void testTraits51() {
"----------\n");
}

@Test // Test protected method of superclass and traits method overriding by class - positive test
@Test // protected method of superclass and traits method overriding by class - positive test
public void testTraits52() {
//@formatter:off
String[] sources = {
Expand Down Expand Up @@ -2125,7 +2144,7 @@ public void testTraits8049() {
runConformTest(sources, "WORKS");
}

@Ignore @Test // see also GROOVY-7950
@Test // see also GROOVY-7950
public void testTraits8219() {
//@formatter:off
String[] sources = {
Expand All @@ -2142,7 +2161,7 @@ public void testTraits8219() {
};
//@formatter:on

runConformTest(sources, "42");
runConformTest(sources, isAtLeastGroovy(50) ? "42" : "null");
}

@Test
Expand Down Expand Up @@ -3131,4 +3150,22 @@ public void testTraits11012() {

runConformTest(sources);
}

@Test
public void testTraits11142() {
//@formatter:off
String[] sources = {
"Script.groovy",
"trait T {\n" +
" def m() { print proxyTarget }\n" + // what about "this"
"}\n" +
"class C {\n" +
" String toString() { 'C' }\n" +
"}\n" +
"(new C() as T).m()\n",
};
//@formatter:on

runConformTest(sources, "C");
}
}

0 comments on commit 6f1419f

Please sign in to comment.