From db9d64432bf5e7d6e180e0248b13c86e21364998 Mon Sep 17 00:00:00 2001 From: Paul King Date: Sat, 13 Jan 2024 23:05:25 +1000 Subject: [PATCH] GROOVY-9464: GroovyDoc: List inherited properties (add testcase) --- .../tools/groovydoc/GroovyDocToolTest.java | 20 ++++++++++++++++ .../groovydoc/testfiles/props/Child.groovy | 23 +++++++++++++++++++ .../testfiles/props/GrandParent.groovy | 23 +++++++++++++++++++ .../groovydoc/testfiles/props/Parent.groovy | 23 +++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/Child.groovy create mode 100644 subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/GrandParent.groovy create mode 100644 subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/Parent.groovy diff --git a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java index 2ba78271cd6..da70a1c422f 100644 --- a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java +++ b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java @@ -776,6 +776,26 @@ public void testGroovyExtendsImportedClassWithNameWhichExistInDefaultPackages() assertEquals("Classes from imported packages should shadow classes from default packages", "a/List", extendedClass.group(1)); } + public void testInheritedProperties() throws Exception { + htmlTool.add(Arrays.asList( + "org/codehaus/groovy/tools/groovydoc/testfiles/props/Child.groovy", + "org/codehaus/groovy/tools/groovydoc/testfiles/props/Parent.groovy", + "org/codehaus/groovy/tools/groovydoc/testfiles/props/GrandParent.groovy" + )); + + final MockOutputTool output = new MockOutputTool(); + htmlTool.renderToOutput(output, MOCK_DIR); + final String childDoc = output.getText(MOCK_DIR + "/org/codehaus/groovy/tools/groovydoc/testfiles/props/Child.html"); + + final Matcher inheritedProperties = Pattern.compile("(?s)Inherited properties" + + ".*Parent.*(\\w*)" + + ".*GrandParent.*(\\w*)").matcher(childDoc); + + assertTrue("Should find inherited properties", inheritedProperties.find()); + assertEquals("Should find Parent property", "fooP", inheritedProperties.group(1)); + assertEquals("Should find GrandParent property", "fooGP", inheritedProperties.group(2)); + } + public void testJavaExtendsImportedClassWithNameWhichExistInDefaultPackages() throws Exception { // Java interface b.Test imports a.List and extends List. // List should be recognized as a.List and not java.util.List diff --git a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/Child.groovy b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/Child.groovy new file mode 100644 index 00000000000..134c1094ce4 --- /dev/null +++ b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/Child.groovy @@ -0,0 +1,23 @@ +/* + * 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.codehaus.groovy.tools.groovydoc.testfiles.props + +class Child extends Parent { + String fooC +} diff --git a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/GrandParent.groovy b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/GrandParent.groovy new file mode 100644 index 00000000000..d0282112e1c --- /dev/null +++ b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/GrandParent.groovy @@ -0,0 +1,23 @@ +/* + * 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.codehaus.groovy.tools.groovydoc.testfiles.props + +class GrandParent { + String fooGP +} diff --git a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/Parent.groovy b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/Parent.groovy new file mode 100644 index 00000000000..f5f0388aa31 --- /dev/null +++ b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/props/Parent.groovy @@ -0,0 +1,23 @@ +/* + * 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.codehaus.groovy.tools.groovydoc.testfiles.props + +class Parent extends GrandParent { + String fooP +}