You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/06/26 14:40:32 UTC
[groovy] branch master updated: Add a test for `GroovyObjectHelper`
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 0dfa029 Add a test for `GroovyObjectHelper`
0dfa029 is described below
commit 0dfa029f089fe467a6f379d333ab64396a7c7c2f
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jun 26 22:40:10 2021 +0800
Add a test for `GroovyObjectHelper`
---
.../groovy/lang/GroovyObjectHelperTest.groovy | 43 ++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/src/test/org/apache/groovy/lang/GroovyObjectHelperTest.groovy b/src/test/org/apache/groovy/lang/GroovyObjectHelperTest.groovy
new file mode 100644
index 0000000..420073c
--- /dev/null
+++ b/src/test/org/apache/groovy/lang/GroovyObjectHelperTest.groovy
@@ -0,0 +1,43 @@
+/*
+ * 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 org.apache.groovy.lang
+
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+class GroovyObjectHelperTest {
+ @Test
+ void testLookup() {
+ assertScript '''
+ import org.apache.groovy.lang.GroovyObjectHelper
+ class Outer {
+ static class StaticInner {
+ static class StaticInnest {}
+ }
+ class Inner {}
+ }
+
+ assert Outer.class === GroovyObjectHelper.lookup(new Outer()).get().lookupClass()
+ assert Outer.Inner.class == GroovyObjectHelper.lookup(new Outer().new Inner()).get().lookupClass()
+ assert Outer.StaticInner.class == GroovyObjectHelper.lookup(new Outer.StaticInner()).get().lookupClass()
+ assert Outer.StaticInner.StaticInnest.class == GroovyObjectHelper.lookup(new Outer.StaticInner.StaticInnest()).get().lookupClass()
+ '''
+ }
+}