Repository: groovy Updated Branches: refs/heads/GROOVY_2_5_X 578b3c7e7 -> 70006c7dd
GROOVY-8205: Regression test for STC Enum values DGM methods (closes #592) Issue fixed by commit 8c218dec34 (GROOVY-7283) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/70006c7d Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/70006c7d Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/70006c7d Branch: refs/heads/GROOVY_2_5_X Commit: 70006c7dd313483312abaa098fb727f5990e65ae Parents: 578b3c7 Author: John Wagenleitner <[email protected]> Authored: Sat Aug 26 11:55:25 2017 -0700 Committer: John Wagenleitner <[email protected]> Committed: Sat Aug 26 12:33:57 2017 -0700 ---------------------------------------------------------------------- .../stc/DefaultGroovyMethodsSTCTest.groovy | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/70006c7d/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy ---------------------------------------------------------------------- diff --git a/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy b/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy index db43b5b..81eb450 100644 --- a/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy +++ b/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy @@ -179,5 +179,26 @@ class DefaultGroovyMethodsSTCTest extends StaticTypeCheckingTestCase { assert sorted3*.value == [10, 5, 20, 15] ''' } -} + // GROOVY-8205 + void testEachOnEnumValues() { + assertScript ''' + enum Functions { + A, B, C + } + def m() { + def results = [] + Functions.values().each { results << it.name() } + results + } + def m2() { + def results = [:] + Functions.values().eachWithIndex { val, idx -> results[idx] = val.name() } + results + } + assert m() == ['A', 'B', 'C'] + assert m2() == [0: 'A', 1: 'B', 2: 'C'] + ''' + } + +}
