groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pascalschumac...@apache.org
Subject groovy git commit: test more javadoc code examples
Date Sat, 05 Mar 2016 12:32:37 GMT
Repository: groovy
Updated Branches:
  refs/heads/master e610cc93d -> 625d5dce2


test more javadoc code examples


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/625d5dce
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/625d5dce
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/625d5dce

Branch: refs/heads/master
Commit: 625d5dce27b816523fe076eae9a7c538e6ede14e
Parents: e610cc9
Author: pascalschumacher <pascalschumacher@gmx.net>
Authored: Sat Mar 5 13:32:20 2016 +0100
Committer: pascalschumacher <pascalschumacher@gmx.net>
Committed: Sat Mar 5 13:32:20 2016 +0100

----------------------------------------------------------------------
 src/main/groovy/lang/Category.java              |  4 +--
 src/main/groovy/lang/Closure.java               | 34 +++++++-------------
 src/main/groovy/lang/Delegate.java              |  2 +-
 src/main/groovy/time/TimeCategory.java          |  4 +--
 src/main/groovy/transform/ASTTest.java          |  2 +-
 .../groovy/transform/InheritConstructors.java   |  8 ++---
 src/main/groovy/transform/ToString.java         | 28 ++++++----------
 src/main/groovy/transform/TupleConstructor.java |  4 +--
 8 files changed, 32 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/625d5dce/src/main/groovy/lang/Category.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/Category.java b/src/main/groovy/lang/Category.java
index 4463a4d..f880828 100644
--- a/src/main/groovy/lang/Category.java
+++ b/src/main/groovy/lang/Category.java
@@ -61,7 +61,7 @@ import java.lang.annotation.Target;
  * <p>
  * An example showing a {@code use} statement (allowing fine-grained application of
  * the category methods):
- * <pre>
+ * <pre class="groovyTestCase">
  * {@code @Category}(Integer)
  * class IntegerOps {
  *     def triple() {
@@ -74,7 +74,7 @@ import java.lang.annotation.Target;
  * }
  * </pre>
  * Or, "mixing in" your methods at runtime:
- * <pre>
+ * <pre class="groovyTestCase">
  * {@code @Category}(List)
  * class Shuffler {
  *     def shuffle() {

http://git-wip-us.apache.org/repos/asf/groovy/blob/625d5dce/src/main/groovy/lang/Closure.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/Closure.java b/src/main/groovy/lang/Closure.java
index 19fc960..503a01b 100644
--- a/src/main/groovy/lang/Closure.java
+++ b/src/main/groovy/lang/Closure.java
@@ -66,7 +66,7 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      * With this resolveStrategy set the closure will attempt to resolve property references
and methods to the
      * owner first, then the delegate (<b>this is the default strategy</b>).
      *
-     * For example the following code :
+     * For example the following code:
      * <pre>
      * class Test {
      *     def x = 30
@@ -77,21 +77,15 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      *         def cl = { y = x + y }
      *         cl.delegate = data
      *         cl()
-     *         println x
-     *         println y
-     *         println data
+     *         assert x == 30
+     *         assert y == 70
+     *         assert data == [x:10, y:20]
      *     }
      * }
      *
      * new Test().run()
      * </pre>
-     * will output :
-     * <pre>
-     * 30
-     * 70
-     * [x:10, y:20]
-     * </pre>
-     * because the x and y fields declared in the Test class shadow the variables in the
delegate.<p>
+     * Will succeed, because the x and y fields declared in the Test class shadow the variables
in the delegate.<p>
      * <i>Note that local variables are always looked up first, independently of the
resolution strategy.</i>
      */
     public static final int OWNER_FIRST = 0;
@@ -100,8 +94,8 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      * With this resolveStrategy set the closure will attempt to resolve property references
and methods to the
      * delegate first then the owner.
      *
-     * For example the following code :
-     * <pre>
+     * For example the following code:
+     * <pre class="groovyTestCase">
      * class Test {
      *     def x = 30
      *     def y = 40
@@ -112,21 +106,15 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      *         cl.delegate = data
      *         cl.resolveStrategy = Closure.DELEGATE_FIRST
      *         cl()
-     *         println x
-     *         println y
-     *         println data
+     *         assert x == 30
+     *         assert y == 40
+     *         assert data == [x:10, y:30]
      *     }
      * }
      *
      * new Test().run()
      * </pre>
-     * will output :
-     * <pre>
-     * 30
-     * 40
-     * [x:10, y:30]
-     * </pre>
-     * because the x and y variables declared in the delegate shadow the fields in the owner
class.<p>
+     * This will succeed, because the x and y variables declared in the delegate shadow the
fields in the owner class.<p>
      * <i>Note that local variables are always looked up first, independently of the
resolution strategy.</i>
      */
     public static final int DELEGATE_FIRST = 1;

http://git-wip-us.apache.org/repos/asf/groovy/blob/625d5dce/src/main/groovy/lang/Delegate.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/Delegate.java b/src/main/groovy/lang/Delegate.java
index 6513129..7fb3016 100644
--- a/src/main/groovy/lang/Delegate.java
+++ b/src/main/groovy/lang/Delegate.java
@@ -34,7 +34,7 @@ import java.lang.annotation.Target;
  * methods is code which calls through to the delegate as per the normal delegate pattern.
  * <p>
  * As an example, consider this code:
- * <pre>
+ * <pre class="groovyTestCase">
  * class Event {
  *     {@code @Delegate} Date when
  *     String title, url

http://git-wip-us.apache.org/repos/asf/groovy/blob/625d5dce/src/main/groovy/time/TimeCategory.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/time/TimeCategory.java b/src/main/groovy/time/TimeCategory.java
index 29993ed..dbc08cd 100644
--- a/src/main/groovy/time/TimeCategory.java
+++ b/src/main/groovy/time/TimeCategory.java
@@ -24,8 +24,8 @@ import java.util.TimeZone;
 
 /**
  * Apply a number of methods to allow convenient Date/Time manipulation,such as:
- * <pre>
- * use ( TimeCategory ) {
+ * <pre class="groovyTestCase">
+ * use (groovy.time.TimeCategory) {
  *     // application on numbers:
  *     println 1.minute.from.now
  *     println 10.hours.ago

http://git-wip-us.apache.org/repos/asf/groovy/blob/625d5dce/src/main/groovy/transform/ASTTest.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/ASTTest.java b/src/main/groovy/transform/ASTTest.java
index e1805c4..1cdb480 100644
--- a/src/main/groovy/transform/ASTTest.java
+++ b/src/main/groovy/transform/ASTTest.java
@@ -33,7 +33,7 @@ import java.lang.annotation.Target;
  * or parameters), then use a script which is run against this AST node at a specific phase.
For example,
  * you could test the {@link Field} AST transformation this way:
  *
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.*
  *
  * {@code @ASTTest}(value = {

http://git-wip-us.apache.org/repos/asf/groovy/blob/625d5dce/src/main/groovy/transform/InheritConstructors.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/InheritConstructors.java b/src/main/groovy/transform/InheritConstructors.java
index 66a1e10..f4c77f5 100644
--- a/src/main/groovy/transform/InheritConstructors.java
+++ b/src/main/groovy/transform/InheritConstructors.java
@@ -33,7 +33,7 @@ import java.lang.annotation.Target;
  * {@code @InheritConstructors} saves you typing some boilerplate code.
  * <p>
  * <em>Example usage:</em>
- * <pre>
+ * <pre class="groovyTestCase">
  * class Person {
  *     String first, last
  *     Person(String first, String last) {
@@ -42,15 +42,15 @@ import java.lang.annotation.Target;
  *     }
  * }
  *
- * {@code @InheritConstructors}
+ * {@code @groovy.transform.InheritConstructors}
  * class PersonAge extends Person {
  *     int age
  * }
  *
  * def js = new PersonAge('John', 'Smith')
  * js.age = 25
- * println "$js.last, $js.first is $js.age years old"
- * // => SMITH, John is 25 years old
+ * 
+ * assert "$js.last, $js.first is $js.age years old" == 'SMITH, John is 25 years old'
  * </pre>
  * for this case, the <code>PersonAge</code> class will be
  * equivalent to the following code:

http://git-wip-us.apache.org/repos/asf/groovy/blob/625d5dce/src/main/groovy/transform/ToString.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/ToString.java b/src/main/groovy/transform/ToString.java
index 16672a4..2f3e73d 100644
--- a/src/main/groovy/transform/ToString.java
+++ b/src/main/groovy/transform/ToString.java
@@ -31,8 +31,8 @@ import java.lang.annotation.Target;
  * AST transformation which adds the necessary toString() method.
  * <p>
  * It allows you to write classes in this shortened form:
- * <pre>
- * {@code @ToString}
+ * <pre class="groovyTestCase">
+ * {@code @groovy.transform.ToString}
  * class Customer {
  *     String first, last
  *     int age
@@ -40,11 +40,8 @@ import java.lang.annotation.Target;
  *     Collection favItems
  *     private answer = 42
  * }
- * println new Customer(first:'Tom', last:'Jones', age:21, favItems:['Books', 'Games'])
- * </pre>
- * Which will have this output:
- * <pre>
- * Customer(Tom, Jones, 21, Wed Jul 14 23:57:14 EST 2010, [Books, Games])
+ * String customerAsString = new Customer(first:'Tom', last:'Jones', age:21, favItems:['Books',
'Games']).toString()
+ * assert customerAsString == 'Customer(Tom, Jones, 21, Wed Jul 14 23:57:14 EST 2010, [Books,
Games])'
  * </pre>
  * There are numerous options to customize the format of the generated output.
  * E.g. if you change the first annotation to:
@@ -64,7 +61,7 @@ import java.lang.annotation.Target;
  * Customer(first:Tom, last:Jones, age:21, answer:42)
  * </pre>
  * If you have this example:
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.ToString
  * {@code @ToString} class NamedThing {
  *     String name
@@ -73,25 +70,18 @@ import java.lang.annotation.Target;
  * class AgedThing extends NamedThing {
  *     int age
  * }
- * println new AgedThing(name:'Lassie', age:5)
- * </pre>
- * Then the output will be:
- * <pre>
- * AgedThing(age:5, super:NamedThing(Lassie))
+ * String agedThingAsString = new AgedThing(name:'Lassie', age:5).toString()
+ * assert agedThingAsString == 'AgedThing(age:5, super:NamedThing(Lassie))'
  * </pre>
  * {@code @ToString} can also be used in conjunction with {@code @Canonical} and {@code @Immutable}.
  * <p>
  * If you want to omit fields or properties referring to <tt>null</tt>, you can
use the <tt>ignoreNulls</tt> flag:
- * <pre>
+ * <pre class="groovyTestCase">
  * import groovy.transform.ToString
  * {@code @ToString(ignoreNulls = true)} class NamedThing {
  *     String name
  * }
- * println new NamedThing(name: null)
- * </pre>
- * Which results in:
- * <pre>
- * NamedThing()
+ * assert new NamedThing(name: null).toString() == 'NamedThing()'
  * </pre>
  * <p>
  * By default the fully-qualified class name is used as part of the generated toString.

http://git-wip-us.apache.org/repos/asf/groovy/blob/625d5dce/src/main/groovy/transform/TupleConstructor.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/transform/TupleConstructor.java b/src/main/groovy/transform/TupleConstructor.java
index 916028d..075fe2c 100644
--- a/src/main/groovy/transform/TupleConstructor.java
+++ b/src/main/groovy/transform/TupleConstructor.java
@@ -31,8 +31,8 @@ import java.lang.annotation.Target;
  * Limitations" for more details.
  * <p>
  * It allows you to write classes in this shortened form:
- * <pre>
- * {@code @TupleConstructor} class Customer {
+ * <pre class="groovyTestCase">
+ * {@code @groovy.transform.TupleConstructor} class Customer {
  *     String first, last
  *     int age
  *     Date since


Mime
View raw message