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 2018/10/06 01:54:01 UTC
[1/2] groovy git commit: GROOVY-8827: Close a small gap in the EMC
DSL for constructors
Repository: groovy
Updated Branches:
refs/heads/master c27bad23e -> 075ed9b26
GROOVY-8827: Close a small gap in the EMC DSL for constructors
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/075ed9b2
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/075ed9b2
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/075ed9b2
Branch: refs/heads/master
Commit: 075ed9b2601bece01bd4e4e03852556c09c3357a
Parents: d65fd61
Author: Paul King <pa...@asert.com.au>
Authored: Sat Oct 6 11:51:16 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Sat Oct 6 11:53:46 2018 +1000
----------------------------------------------------------------------
.../groovy/groovy/lang/ExpandoMetaClass.java | 6 +++
.../lang/ExpandoMetaClassConstructorTest.groovy | 45 ++++++++++++++++++++
2 files changed, 51 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/075ed9b2/src/main/groovy/groovy/lang/ExpandoMetaClass.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/lang/ExpandoMetaClass.java b/src/main/groovy/groovy/lang/ExpandoMetaClass.java
index 8183e08..e965e2f 100644
--- a/src/main/groovy/groovy/lang/ExpandoMetaClass.java
+++ b/src/main/groovy/groovy/lang/ExpandoMetaClass.java
@@ -599,6 +599,9 @@ public class ExpandoMetaClass extends MetaClassImpl implements GroovyObject {
private void registerIfClosure(Object arg, boolean replace) {
if (arg instanceof Closure) {
+ if (propertyName.equals(CONSTRUCTOR)) {
+ propertyName = GROOVY_CONSTRUCTOR;
+ }
Closure callable = (Closure) arg;
final List<MetaMethod> list = ClosureMetaMethod.createMethodList(propertyName, theClass, callable);
if (list.isEmpty() && this.isStatic) {
@@ -906,6 +909,9 @@ public class ExpandoMetaClass extends MetaClassImpl implements GroovyObject {
}
public void registerInstanceMethod(String name, Closure closure) {
+ if (name.equals(CONSTRUCTOR)) {
+ name = GROOVY_CONSTRUCTOR;
+ }
final List<MetaMethod> list = ClosureMetaMethod.createMethodList(name, theClass, closure);
for (MetaMethod method : list) {
registerInstanceMethod(method);
http://git-wip-us.apache.org/repos/asf/groovy/blob/075ed9b2/src/test/groovy/lang/ExpandoMetaClassConstructorTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/lang/ExpandoMetaClassConstructorTest.groovy b/src/test/groovy/lang/ExpandoMetaClassConstructorTest.groovy
new file mode 100644
index 0000000..f01e63f
--- /dev/null
+++ b/src/test/groovy/lang/ExpandoMetaClassConstructorTest.groovy
@@ -0,0 +1,45 @@
+/*
+ * 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.lang
+
+class ExpandoMetaClassConstructorTest extends GroovyTestCase {
+ void testVariousConstructorForms() {
+ try {
+ assertScript """
+ Short.metaClass {
+ constructor { List l -> l.size() as short }
+ }
+ Integer.metaClass {
+ constructor = { List l -> l.size() }
+ }
+ Long.metaClass {
+ constructor << { List l -> l.size() as long }
+ }
+
+ def result = [[] as Short, ['foo'] as Integer, ['bar', 'baz'] as Long]
+ assert result.toString() == '[0, 1, 2]'
+ assert result*.class == [Short, Integer, Long]
+ """
+ } finally {
+ Integer.metaClass = null
+ Short.metaClass = null
+ Long.metaClass = null
+ }
+ }
+}
[2/2] groovy git commit: comment tweaks
Posted by pa...@apache.org.
comment tweaks
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/d65fd611
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d65fd611
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d65fd611
Branch: refs/heads/master
Commit: d65fd6118202709cc3b648bde60fc9bef2502879
Parents: c27bad2
Author: Paul King <pa...@asert.com.au>
Authored: Sat Oct 6 11:09:59 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Sat Oct 6 11:53:46 2018 +1000
----------------------------------------------------------------------
gradle/pomconfigurer.gradle | 3 +++
src/test/gls/syntax/Gep3Test.groovy | 6 +-----
2 files changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/d65fd611/gradle/pomconfigurer.gradle
----------------------------------------------------------------------
diff --git a/gradle/pomconfigurer.gradle b/gradle/pomconfigurer.gradle
index 12f2f5a..da7a445 100644
--- a/gradle/pomconfigurer.gradle
+++ b/gradle/pomconfigurer.gradle
@@ -645,6 +645,9 @@ project.ext.pomConfigureClosureWithoutTweaks = {
contributor {
name 'Dejan Bosanac'
}
+ contributor {
+ name 'Lidia Donajczyk-Lipinska'
+ }
}
mailingLists {
mailingList {
http://git-wip-us.apache.org/repos/asf/groovy/blob/d65fd611/src/test/gls/syntax/Gep3Test.groovy
----------------------------------------------------------------------
diff --git a/src/test/gls/syntax/Gep3Test.groovy b/src/test/gls/syntax/Gep3Test.groovy
index 35bd16c..1cfbfc0 100644
--- a/src/test/gls/syntax/Gep3Test.groovy
+++ b/src/test/gls/syntax/Gep3Test.groovy
@@ -61,11 +61,7 @@ import static Temperature.*
* method calls (ie. send "hello" to "Guillaume" is two methods chained
* one after the other as send("hello").to("Guillaume"))
* - extend command expressions to be allowed on the RHS of assignments.
- * def txt = foo a1() not allowed rigth now
- *
- * @author Lidia Donajczyk-Lipinska
- * @author Jochen "blackdrag" Theodorou
- * @author Guillaume Laforge
+ * def txt = foo a1() not allowed right now
*/
class Gep3Test extends GroovyTestCase {