You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2016/03/04 17:02:32 UTC
[2/2] groovy git commit: Tested code snippets for AST transformation
Javadoc (closes #278)
Tested code snippets for AST transformation Javadoc (closes #278)
* Added CSS class groovyTestCase for code snippets, so they are automatically tested
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/c04484a6
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/c04484a6
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/c04484a6
Branch: refs/heads/master
Commit: c04484a66e7601f02e41504c04fdf8292aa88c89
Parents: 2b6a639
Author: Hubert Klein Ikkink <h....@gmail.com>
Authored: Thu Mar 3 23:48:12 2016 +0100
Committer: pascalschumacher <pa...@gmx.net>
Committed: Fri Mar 4 17:01:07 2016 +0100
----------------------------------------------------------------------
src/main/groovy/transform/BaseScript.java | 2 +-
src/main/groovy/transform/Canonical.groovy | 2 +-
.../groovy/transform/EqualsAndHashCode.java | 2 +-
src/main/groovy/transform/Immutable.java | 2 +-
src/main/groovy/transform/IndexedProperty.java | 2 +-
.../groovy/transform/InheritConstructors.java | 4 ++--
src/main/groovy/transform/Memoized.java | 2 +-
src/main/groovy/transform/Sortable.java | 22 +++++++++++---------
src/main/groovy/transform/Synchronized.java | 2 +-
src/main/groovy/transform/TailRecursive.groovy | 2 +-
src/main/groovy/transform/ToString.java | 18 ++++++++--------
src/main/groovy/transform/TupleConstructor.java | 8 +++----
12 files changed, 35 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/BaseScript.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/BaseScript.java b/src/main/groovy/transform/BaseScript.java
index af3e594..6bea56e 100644
--- a/src/main/groovy/transform/BaseScript.java
+++ b/src/main/groovy/transform/BaseScript.java
@@ -85,7 +85,7 @@ import java.lang.annotation.Target;
* the AST is currently implemented they are not accessible in the script body code.
* </p>
* <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
* // Simple Car class to save state and distance.
* class Car {
* String state
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/Canonical.groovy
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/Canonical.groovy b/src/main/groovy/transform/Canonical.groovy
index 10ddb6d..82d2fc2 100644
--- a/src/main/groovy/transform/Canonical.groovy
+++ b/src/main/groovy/transform/Canonical.groovy
@@ -77,7 +77,7 @@ package groovy.transform
* {@code @}{@link Immutable} annotation.
*
* <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
* import groovy.transform.*
*
* @Canonical
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/EqualsAndHashCode.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/EqualsAndHashCode.java b/src/main/groovy/transform/EqualsAndHashCode.java
index 2c75279..634dbe9 100644
--- a/src/main/groovy/transform/EqualsAndHashCode.java
+++ b/src/main/groovy/transform/EqualsAndHashCode.java
@@ -193,7 +193,7 @@ import java.lang.annotation.Target;
* you have such structures.
* A future version of this transform may better handle some additional recursive scenarios.
* <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
* import groovy.transform.EqualsAndHashCode
*
* @EqualsAndHashCode(includeFields=true)
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/Immutable.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/Immutable.java b/src/main/groovy/transform/Immutable.java
index 314abbc..20a1034 100644
--- a/src/main/groovy/transform/Immutable.java
+++ b/src/main/groovy/transform/Immutable.java
@@ -124,7 +124,7 @@ import java.lang.annotation.Target;
* </ul>
* <p>More examples:</p>
--------------------------------------------------------------------------------
- * <pre>
+ * <pre class="groovyTestCase">
* import groovy.transform.*
*
* @Canonical
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/IndexedProperty.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/IndexedProperty.java b/src/main/groovy/transform/IndexedProperty.java
index 4d4daab..cf77d98 100644
--- a/src/main/groovy/transform/IndexedProperty.java
+++ b/src/main/groovy/transform/IndexedProperty.java
@@ -63,7 +63,7 @@ import java.lang.annotation.Target;
* The normal Groovy property getters and setters will also be created.
* <p>
* <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
* import groovy.transform.IndexedProperty
*
* class Group {
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/InheritConstructors.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/InheritConstructors.java b/src/main/groovy/transform/InheritConstructors.java
index 0206e06..66a1e10 100644
--- a/src/main/groovy/transform/InheritConstructors.java
+++ b/src/main/groovy/transform/InheritConstructors.java
@@ -112,7 +112,7 @@ import java.lang.annotation.Target;
* If you get it wrong you will get a compile-time error about the duplication.</li>
* </ul>
* <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* import groovy.transform.InheritConstructors
*
@@ -124,7 +124,7 @@ import java.lang.annotation.Target;
* def e1 = new MyException('message') // Other constructors are available.
* assert 'message' == e1.message
* </pre>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* import groovy.transform.InheritConstructors
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/Memoized.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/Memoized.java b/src/main/groovy/transform/Memoized.java
index a1aa76c..9e1409d 100644
--- a/src/main/groovy/transform/Memoized.java
+++ b/src/main/groovy/transform/Memoized.java
@@ -87,7 +87,7 @@ import org.codehaus.groovy.transform.GroovyASTTransformationClass;
* </pre>
*
* <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
* import groovy.transform.*
*
* // Script variable which is changed when increment()
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/Sortable.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/Sortable.java b/src/main/groovy/transform/Sortable.java
index 9d6cb0d..45fe99f 100644
--- a/src/main/groovy/transform/Sortable.java
+++ b/src/main/groovy/transform/Sortable.java
@@ -48,7 +48,7 @@ import org.codehaus.groovy.transform.GroovyASTTransformationClass;
* </ul>
* The properties within the class must themselves be {@code Comparable} or {@code @Sortable}.
* <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* import groovy.transform.Sortable
* import groovy.transform.ToString
@@ -74,20 +74,23 @@ import org.codehaus.groovy.transform.GroovyASTTransformationClass;
* final List<Course> courses = [groovy, groovy2, grails]
* assert courses.last().title == 'Grails'
*
- * // Use sort() method to sort
- * final List<Course> sorted = courses.sort(false)
+ * // Use toSorted() method to sort
+ * final List<Course> sorted = courses.toSorted()
*
* assert sorted.first().title == 'Grails'
* assert sorted.last().title == 'Groovy'
* assert sorted.maxAttendees == [20, 50, 40]
* </pre>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* // Order of fields for includes determines priority when sorting
+ * import groovy.transform.Sortable
+ * import groovy.transform.ToString
+ *
* @Sortable(includes = ['title', 'maxAttendees'])
* // Or @Sortable(excludes = ['beginDate'])
* @ToString
- * class CourseSort {
+ * class Course {
* String title
* Date beginDate
* Integer maxAttendees
@@ -103,14 +106,13 @@ import org.codehaus.groovy.transform.GroovyASTTransformationClass;
*
* final List<Course> courses = [groovy, groovy2, grails]
*
- * // Use sort() method to sort
- * final List<Course> sorted = courses.sort(false)
+ * // Use toSorted() method to sort
+ * final List<Course> sorted = courses.toSorted()
*
* assert sorted.first().title == 'Grails'
* assert sorted.last().title == 'Groovy'
* assert sorted.maxAttendees == [20, 40, 50]
- * </pre>
- * <pre>
+ *
* //--------------------------------------------------------------------------
* // Static methods to create comparators.
* final Comparator byMaxAttendees = Course.comparatorByMaxAttendees()
@@ -120,7 +122,7 @@ import org.codehaus.groovy.transform.GroovyASTTransformationClass;
* // beginDate is not used for sorting
* assert sortedByMaxAttendees[2].beginDate < sortedByMaxAttendees[1].beginDate
*
- * assert Course.declaredMethods.name.findAll { it.startsWith('comparatorBy') } == ['comparatorByTitle', 'comparatorByMaxAttendees']
+ * assert Course.declaredMethods.name.findAll { it.startsWith('comparatorBy') }.toSorted() == ['comparatorByMaxAttendees', 'comparatorByTitle']
* </pre>
*
* @author Andres Almiray
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/Synchronized.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/Synchronized.java b/src/main/groovy/transform/Synchronized.java
index 1157e3b..dc8867c 100644
--- a/src/main/groovy/transform/Synchronized.java
+++ b/src/main/groovy/transform/Synchronized.java
@@ -105,7 +105,7 @@ import java.lang.annotation.Target;
* a 0-size array is. Therefore, using {@code @Synchronized} will not prevent your
* object from being serialized.
* <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
* import groovy.transform.Synchronized
*
* class Util {
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/TailRecursive.groovy
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/TailRecursive.groovy b/src/main/groovy/transform/TailRecursive.groovy
index 2a85159..0c9b6cf 100644
--- a/src/main/groovy/transform/TailRecursive.groovy
+++ b/src/main/groovy/transform/TailRecursive.groovy
@@ -59,7 +59,7 @@ import java.lang.annotation.Target
* </ul>
*
* <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
* import groovy.transform.TailRecursive
*
* @TailRecursive
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/ToString.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/ToString.java b/src/main/groovy/transform/ToString.java
index 1d56f5f..16672a4 100644
--- a/src/main/groovy/transform/ToString.java
+++ b/src/main/groovy/transform/ToString.java
@@ -113,7 +113,7 @@ import java.lang.annotation.Target;
* my.company.NamedThing(name: Lassie)
* </pre>
* <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* // Most simple implementation of toString.
* import groovy.transform.ToString
@@ -129,12 +129,12 @@ import java.lang.annotation.Target;
*
* assert person.toString() == 'Person(mrhaki, [Groovy, Java])'
* </pre>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* // includeNames to output the names of the properties.
* import groovy.transform.ToString
*
- * @@ToString(includeNames=true)
+ * @ToString(includeNames=true)
* class Person {
* String name
* List likes
@@ -145,7 +145,7 @@ import java.lang.annotation.Target;
*
* assert person.toString() == 'Person(name:mrhaki, likes:[Groovy, Java])'
* </pre>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* // includeFields to not only output properties, but also field values.
* import groovy.transform.ToString
@@ -182,7 +182,7 @@ import java.lang.annotation.Target;
*
* assert student.toString() == 'Student(courses:[IT, Business], super:Person(name:mrhaki, likes:[Groovy, Java]))'
* </pre>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* // excludes active field and likes property from output
* import groovy.transform.ToString
@@ -198,7 +198,7 @@ import java.lang.annotation.Target;
*
* assert person.toString() == 'Person(name:mrhaki)'
* </pre>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* // Don't include the package name in the output
* package com.mrhaki.blog.groovy
@@ -215,7 +215,7 @@ import java.lang.annotation.Target;
*
* assert course.toString() == 'Course(Groovy 101, 200)'
* </pre>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* // Don't use properties with null value.
* package com.mrhaki.blog.groovy
@@ -232,14 +232,14 @@ import java.lang.annotation.Target;
*
* assert course.toString() == 'com.mrhaki.blog.groovy.Course(Groovy 101)'
* </pre>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* // Cache toString() result.
* package com.mrhaki.blog.groovy
*
* import groovy.transform.*
*
- * @@ToString(cache=true)
+ * @ToString(cache=true)
* class Course {
* String title
* Integer maxAttendees
http://git-wip-us.apache.org/repos/asf/groovy/blob/c04484a6/src/main/groovy/transform/TupleConstructor.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/TupleConstructor.java b/src/main/groovy/transform/TupleConstructor.java
index e472667..916028d 100644
--- a/src/main/groovy/transform/TupleConstructor.java
+++ b/src/main/groovy/transform/TupleConstructor.java
@@ -56,7 +56,7 @@ import java.lang.annotation.Target;
* by the fields of the class (if {@code includeFields} is set). Within each grouping the order
* is as attributes appear within the respective class.
* <p>More examples:</p>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* import groovy.transform.TupleConstructor
*
@@ -77,7 +77,7 @@ import java.lang.annotation.Target;
* assert person.name == 'mrhaki'
* assert !person.likes
* </pre>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* // includeFields in the constructor creation.
* import groovy.transform.TupleConstructor
@@ -97,7 +97,7 @@ import java.lang.annotation.Target;
* assert person.likes == ['Groovy', 'Java']
* assert person.activated
* </pre>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* // use force attribute to force creation of constructor
* // even if we define our own constructors.
@@ -126,7 +126,7 @@ import java.lang.annotation.Target;
*
* assert person.activated
* </pre>
- * <pre>
+ * <pre class="groovyTestCase">
* //--------------------------------------------------------------------------
* // include properties and fields from super class.
* import groovy.transform.TupleConstructor