Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.5, 1.5.1
-
None
-
Patch
Description
Currently the each() method for subclasses of java.lang.Enum is the default each() method that returns the enum class itself in a single-element list. I believe it would be useful for the each() method to iterate through the values of the enum.
The provided patch implements this functionality by providing enum-specific behavior in DefaultTypeTransformation.asCollection(). This makes each(), eachWithIndex(), for (... in ...), and perhaps other constructs use the enum values as the collection instead of the single element list containing the enum class itself.
The provided test case tests only each() and the for/in behavior. It also introduces a new groovy.vm5.GroovyMethodsTest class for DGM tests that should only be run under Java 5 and later.