Skip to content

Commit

Permalink
Add validation tests for Groovy AST transformations (bazelbuild#863)
Browse files Browse the repository at this point in the history
* groovy.beans.Bindable
* groovy.beans.Vetoable
* groovy.transform.AutoExternalize
* groovy.transform.IndexedProperty
  • Loading branch information
sclassen authored and Godin committed May 21, 2019
1 parent d6ffbce commit be17bad
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Stephan Classen
* Vadim Bauer
*
*******************************************************************************/
package org.jacoco.core.test.validation.groovy;

import org.jacoco.core.test.validation.ValidationTestBase;
import org.jacoco.core.test.validation.groovy.targets.GroovyAutoExternalizeClassTarget;
import org.junit.Test;

/**
* Test of class with {@link groovy.transform.AutoExternalize} annotation.
*/
public class GroovyAutoExternalizeClassTest extends ValidationTestBase {
public GroovyAutoExternalizeClassTest() {
super(GroovyAutoExternalizeClassTarget.class);
}

@Test
public void test_method_count() {
assertMethodCount(1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Stephan Classen
* Vadim Bauer
*
*******************************************************************************/
package org.jacoco.core.test.validation.groovy;

import org.jacoco.core.test.validation.ValidationTestBase;
import org.jacoco.core.test.validation.groovy.targets.GroovyBindableClassTarget;
import org.junit.Test;

/**
* Test of class with {@link groovy.beans.Bindable} annotation.
*/
public class GroovyBindableClassTest extends ValidationTestBase {
public GroovyBindableClassTest() {
super(GroovyBindableClassTarget.class);
}

@Test
public void test_method_count() {
assertMethodCount(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
package org.jacoco.core.test.validation.groovy;

import org.jacoco.core.test.validation.ValidationTestBase;
import org.jacoco.core.test.validation.groovy.targets.GroovyDataClassTarget;
import org.jacoco.core.test.validation.groovy.targets.GroovyCanonicalClassTarget;
import org.junit.Test;

/**
* Test of <code>data class</code>es.
* Test of class with {@link groovy.transform.Canonical} annotation.
*/
public class GroovyDataClassTest extends ValidationTestBase {
public GroovyDataClassTest() {
super(GroovyDataClassTarget.class);
public class GroovyCanonicalClassTest extends ValidationTestBase {
public GroovyCanonicalClassTest() {
super(GroovyCanonicalClassTarget.class);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Stephan Classen
* Vadim Bauer
*
*******************************************************************************/
package org.jacoco.core.test.validation.groovy;

import org.jacoco.core.test.validation.ValidationTestBase;
import org.jacoco.core.test.validation.groovy.targets.GroovyIndexPropertyClassTarget;
import org.junit.Test;

/**
* Test of class with fields annotated by {@link groovy.transform.IndexedProperty} annotation.
*/
public class GroovyIndexPropertyClassTest extends ValidationTestBase {
public GroovyIndexPropertyClassTest() {
super(GroovyIndexPropertyClassTarget.class);
}

@Test
public void test_method_count() {
assertMethodCount(1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Stephan Classen
* Vadim Bauer
*
*******************************************************************************/
package org.jacoco.core.test.validation.groovy;

import org.jacoco.core.test.validation.ValidationTestBase;
import org.jacoco.core.test.validation.groovy.targets.GroovyVetoableClassTarget;
import org.junit.Test;

/**
* Test of class with {@link groovy.beans.Vetoable} annotation.
*/
public class GroovyVetoableClassTest extends ValidationTestBase {
public GroovyVetoableClassTest() {
super(GroovyVetoableClassTarget.class);
}

@Test
public void test_method_count() {
assertMethodCount(1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Stephan Classen
* Vadim Bauer
*
*******************************************************************************/
package org.jacoco.core.test.validation.groovy.targets

import groovy.transform.AutoExternalize

@AutoExternalize
class GroovyAutoExternalizeClassTarget { // assertEmpty()

String first // assertEmpty()
List favItems // assertEmpty()
Date since // assertEmpty()

static void main(String[] args) {
new GroovyAutoExternalizeClassTarget() // assertFullyCovered()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Stephan Classen
* Vadim Bauer
*
*******************************************************************************/
package org.jacoco.core.test.validation.groovy.targets

import groovy.beans.Bindable

class GroovyBindableClassTarget { // assertEmpty()

@Bindable
String firstName // assertEmpty()

@Bindable
def zipCode // assertEmpty()

static void main(String[] args) {
new GroovyBindableClassTarget() // assertFullyCovered()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@
*******************************************************************************/
package org.jacoco.core.test.validation.groovy.targets

/* This annotation generates the following
* - a constructor that takes an int as argument
* - a suitable implementation of toString()
* - a suitable implementation of hashCode()
* - a suitable implementation of equals(Object)
* - a public method named canEqual(Object)
* - a getter & setter for the valRead property
*/
@groovy.transform.Canonical
class GroovyDataClassTarget { // assertEmpty()
import groovy.transform.Canonical

@Canonical
class GroovyCanonicalClassTarget { // assertEmpty()

int valRead // assertEmpty()

static void main(String[] args) {
new GroovyDataClassTarget() // assertFullyCovered()
new GroovyCanonicalClassTarget() // assertFullyCovered()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Stephan Classen
* Vadim Bauer
*
*******************************************************************************/
package org.jacoco.core.test.validation.groovy.targets

import groovy.io.FileType
import groovy.transform.IndexedProperty

class GroovyIndexPropertyClassTarget { // assertEmpty()

@IndexedProperty
FileType[] someField // assertEmpty()
@IndexedProperty
List otherField // assertEmpty()
@IndexedProperty
List furtherField // assertEmpty()

static void main(String[] args) {
new GroovyIndexPropertyClassTarget() // assertFullyCovered()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Stephan Classen
* Vadim Bauer
*
*******************************************************************************/
package org.jacoco.core.test.validation.groovy.targets

import groovy.beans.Vetoable

@Vetoable
class GroovyVetoableClassTarget { // assertEmpty()

String firstName // assertEmpty()
def zipCode // assertEmpty()

static void main(String[] args) {
new GroovyVetoableClassTarget() // assertFullyCovered()
}
}

0 comments on commit be17bad

Please sign in to comment.