Skip to content

Commit be17bad

Browse files
sclassenGodin
authored andcommitted
Add validation tests for Groovy AST transformations (bazel-contrib#863)
* groovy.beans.Bindable * groovy.beans.Vetoable * groovy.transform.AutoExternalize * groovy.transform.IndexedProperty
1 parent d6ffbce commit be17bad

10 files changed

+245
-16
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Stephan Classen
10+
* Vadim Bauer
11+
*
12+
*******************************************************************************/
13+
package org.jacoco.core.test.validation.groovy;
14+
15+
import org.jacoco.core.test.validation.ValidationTestBase;
16+
import org.jacoco.core.test.validation.groovy.targets.GroovyAutoExternalizeClassTarget;
17+
import org.junit.Test;
18+
19+
/**
20+
* Test of class with {@link groovy.transform.AutoExternalize} annotation.
21+
*/
22+
public class GroovyAutoExternalizeClassTest extends ValidationTestBase {
23+
public GroovyAutoExternalizeClassTest() {
24+
super(GroovyAutoExternalizeClassTarget.class);
25+
}
26+
27+
@Test
28+
public void test_method_count() {
29+
assertMethodCount(1);
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Stephan Classen
10+
* Vadim Bauer
11+
*
12+
*******************************************************************************/
13+
package org.jacoco.core.test.validation.groovy;
14+
15+
import org.jacoco.core.test.validation.ValidationTestBase;
16+
import org.jacoco.core.test.validation.groovy.targets.GroovyBindableClassTarget;
17+
import org.junit.Test;
18+
19+
/**
20+
* Test of class with {@link groovy.beans.Bindable} annotation.
21+
*/
22+
public class GroovyBindableClassTest extends ValidationTestBase {
23+
public GroovyBindableClassTest() {
24+
super(GroovyBindableClassTarget.class);
25+
}
26+
27+
@Test
28+
public void test_method_count() {
29+
assertMethodCount(1);
30+
}
31+
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
package org.jacoco.core.test.validation.groovy;
1313

1414
import org.jacoco.core.test.validation.ValidationTestBase;
15-
import org.jacoco.core.test.validation.groovy.targets.GroovyDataClassTarget;
15+
import org.jacoco.core.test.validation.groovy.targets.GroovyCanonicalClassTarget;
1616
import org.junit.Test;
1717

1818
/**
19-
* Test of <code>data class</code>es.
19+
* Test of class with {@link groovy.transform.Canonical} annotation.
2020
*/
21-
public class GroovyDataClassTest extends ValidationTestBase {
22-
public GroovyDataClassTest() {
23-
super(GroovyDataClassTarget.class);
21+
public class GroovyCanonicalClassTest extends ValidationTestBase {
22+
public GroovyCanonicalClassTest() {
23+
super(GroovyCanonicalClassTarget.class);
2424
}
2525

2626
@Test
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Stephan Classen
10+
* Vadim Bauer
11+
*
12+
*******************************************************************************/
13+
package org.jacoco.core.test.validation.groovy;
14+
15+
import org.jacoco.core.test.validation.ValidationTestBase;
16+
import org.jacoco.core.test.validation.groovy.targets.GroovyIndexPropertyClassTarget;
17+
import org.junit.Test;
18+
19+
/**
20+
* Test of class with fields annotated by {@link groovy.transform.IndexedProperty} annotation.
21+
*/
22+
public class GroovyIndexPropertyClassTest extends ValidationTestBase {
23+
public GroovyIndexPropertyClassTest() {
24+
super(GroovyIndexPropertyClassTarget.class);
25+
}
26+
27+
@Test
28+
public void test_method_count() {
29+
assertMethodCount(1);
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Stephan Classen
10+
* Vadim Bauer
11+
*
12+
*******************************************************************************/
13+
package org.jacoco.core.test.validation.groovy;
14+
15+
import org.jacoco.core.test.validation.ValidationTestBase;
16+
import org.jacoco.core.test.validation.groovy.targets.GroovyVetoableClassTarget;
17+
import org.junit.Test;
18+
19+
/**
20+
* Test of class with {@link groovy.beans.Vetoable} annotation.
21+
*/
22+
public class GroovyVetoableClassTest extends ValidationTestBase {
23+
public GroovyVetoableClassTest() {
24+
super(GroovyVetoableClassTarget.class);
25+
}
26+
27+
@Test
28+
public void test_method_count() {
29+
assertMethodCount(1);
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Stephan Classen
10+
* Vadim Bauer
11+
*
12+
*******************************************************************************/
13+
package org.jacoco.core.test.validation.groovy.targets
14+
15+
import groovy.transform.AutoExternalize
16+
17+
@AutoExternalize
18+
class GroovyAutoExternalizeClassTarget { // assertEmpty()
19+
20+
String first // assertEmpty()
21+
List favItems // assertEmpty()
22+
Date since // assertEmpty()
23+
24+
static void main(String[] args) {
25+
new GroovyAutoExternalizeClassTarget() // assertFullyCovered()
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Stephan Classen
10+
* Vadim Bauer
11+
*
12+
*******************************************************************************/
13+
package org.jacoco.core.test.validation.groovy.targets
14+
15+
import groovy.beans.Bindable
16+
17+
class GroovyBindableClassTarget { // assertEmpty()
18+
19+
@Bindable
20+
String firstName // assertEmpty()
21+
22+
@Bindable
23+
def zipCode // assertEmpty()
24+
25+
static void main(String[] args) {
26+
new GroovyBindableClassTarget() // assertFullyCovered()
27+
}
28+
}
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,14 @@
1111
*******************************************************************************/
1212
package org.jacoco.core.test.validation.groovy.targets
1313

14-
/* This annotation generates the following
15-
* - a constructor that takes an int as argument
16-
* - a suitable implementation of toString()
17-
* - a suitable implementation of hashCode()
18-
* - a suitable implementation of equals(Object)
19-
* - a public method named canEqual(Object)
20-
* - a getter & setter for the valRead property
21-
*/
22-
@groovy.transform.Canonical
23-
class GroovyDataClassTarget { // assertEmpty()
14+
import groovy.transform.Canonical
15+
16+
@Canonical
17+
class GroovyCanonicalClassTarget { // assertEmpty()
2418

2519
int valRead // assertEmpty()
2620

2721
static void main(String[] args) {
28-
new GroovyDataClassTarget() // assertFullyCovered()
22+
new GroovyCanonicalClassTarget() // assertFullyCovered()
2923
}
3024
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Stephan Classen
10+
* Vadim Bauer
11+
*
12+
*******************************************************************************/
13+
package org.jacoco.core.test.validation.groovy.targets
14+
15+
import groovy.io.FileType
16+
import groovy.transform.IndexedProperty
17+
18+
class GroovyIndexPropertyClassTarget { // assertEmpty()
19+
20+
@IndexedProperty
21+
FileType[] someField // assertEmpty()
22+
@IndexedProperty
23+
List otherField // assertEmpty()
24+
@IndexedProperty
25+
List furtherField // assertEmpty()
26+
27+
static void main(String[] args) {
28+
new GroovyIndexPropertyClassTarget() // assertFullyCovered()
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Stephan Classen
10+
* Vadim Bauer
11+
*
12+
*******************************************************************************/
13+
package org.jacoco.core.test.validation.groovy.targets
14+
15+
import groovy.beans.Vetoable
16+
17+
@Vetoable
18+
class GroovyVetoableClassTarget { // assertEmpty()
19+
20+
String firstName // assertEmpty()
21+
def zipCode // assertEmpty()
22+
23+
static void main(String[] args) {
24+
new GroovyVetoableClassTarget() // assertFullyCovered()
25+
}
26+
}

0 commit comments

Comments
 (0)