Skip to content

Commit

Permalink
GROOVY-9464: GroovyDoc: List inherited properties (add testcase)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulk-asert committed Jan 13, 2024
1 parent 67a1f6b commit db9d644
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)<span>Inherited properties</span>" +
".*<a href='[./]*/org/codehaus/groovy/tools/groovydoc/testfiles/props/Parent.html'>Parent</a>.*<code>(\\w*)</code>" +
".*<a href='[./]*/org/codehaus/groovy/tools/groovydoc/testfiles/props/GrandParent.html'>GrandParent</a>.*<code>(\\w*)</code>").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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit db9d644

Please sign in to comment.