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 2017/01/30 12:58:38 UTC
groovy git commit: GROOVY-8026: Matcher indexed via IntRange with
startIdx..-1 does not return "intermediate" range matches (closes #483)
Repository: groovy
Updated Branches:
refs/heads/GROOVY_2_4_X bf8ab581b -> cf2a041ab
GROOVY-8026: Matcher indexed via IntRange with startIdx..-1 does not return "intermediate" range matches (closes #483)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/cf2a041a
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/cf2a041a
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/cf2a041a
Branch: refs/heads/GROOVY_2_4_X
Commit: cf2a041abaea3295664383f2d3519cadbe5e0365
Parents: bf8ab58
Author: paulk <pa...@asert.com.au>
Authored: Fri Jan 27 16:58:50 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Mon Jan 30 22:58:17 2017 +1000
----------------------------------------------------------------------
.../groovy/runtime/StringGroovyMethods.java | 5 +++
src/test/groovy/bugs/Groovy8026Bug.groovy | 35 ++++++++++++++++++++
2 files changed, 40 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/cf2a041a/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
index 5448b1b..976e391 100644
--- a/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
+++ b/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
@@ -1314,6 +1314,11 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport {
*/
public static List getAt(Matcher self, Collection indices) {
List result = new ArrayList();
+ if (indices instanceof IntRange) {
+ int size = (int) size(self);
+ RangeInfo info = subListBorders(size, (Range) indices);
+ indices = new IntRange(((IntRange)indices).getInclusive(), info.from, info.to - 1);
+ }
for (Object value : indices) {
if (value instanceof Range) {
result.addAll(getAt(self, (Range) value));
http://git-wip-us.apache.org/repos/asf/groovy/blob/cf2a041a/src/test/groovy/bugs/Groovy8026Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy8026Bug.groovy b/src/test/groovy/bugs/Groovy8026Bug.groovy
new file mode 100644
index 0000000..8483ee0
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8026Bug.groovy
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package groovy.bugs
+
+class Groovy8026Bug extends GroovyTestCase {
+ void testJavaBeanPropertiesAvailableInInnerClasses() {
+ assertScript '''
+ def mm = '1 2 3 4 5 6 7 8 9' =~ /\\d/
+ assert mm.collect { it }.toString() == '[1, 2, 3, 4, 5, 6, 7, 8, 9]'
+ assert mm[ 0..8 ].toString() == '[1, 2, 3, 4, 5, 6, 7, 8, 9]'
+ assert mm[ 0..mm.size()-1 ].toString() == '[1, 2, 3, 4, 5, 6, 7, 8, 9]'
+ assert mm[ 0..<mm.size() ].toString() == '[1, 2, 3, 4, 5, 6, 7, 8, 9]'
+ assert mm[-1] == '9'
+ assert mm[ 0..-1 ].toString() == '[1, 2, 3, 4, 5, 6, 7, 8, 9]'
+ assert mm[ (0..-1).toList() ].toString() == '[1, 9]'
+ assert mm[ (0..-1).iterator().toList() ].toString() == '[1, 9]'
+ '''
+ }
+}