[
https://issues.apache.org/jira/browse/GROOVY-7486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14624694#comment-14624694
]
ASF GitHub Bot commented on GROOVY-7486:
----------------------------------------
Github user keeganwitt commented on a diff in the pull request:
https://github.com/apache/incubator-groovy/pull/59#discussion_r34466245
--- Diff: src/test/groovy/tree/NavigationTest.groovy ---
@@ -22,29 +22,37 @@ package groovy.tree
* Simple test of tree walking
*/
class NavigationTest extends GroovyTestCase {
-
+
void testDepthFirst() {
- def tree = createTree()
-
+ def tree = createTreeFromNodeBuilder()
def names = tree.depthFirst().collect { it.name() }
- def expected = ['a', 'b1', 'b2', 'c1', 'c2', 'b3', 'b4', 'c3',
'c4', 'b5']
-
- assert names == expected
+ assert names == ['a', 'b1', 'b2', 'c1', 'c2', 'b3', 'b4', 'c3',
'c4', 'b5']
}
-
+
void testBreadthFirst() {
- def tree = createTree()
-
+ def tree = createTreeFromNodeBuilder()
def names = tree.breadthFirst().collect { it.name() }
- def expected = ['a', 'b1', 'b2', 'b3', 'b4', 'b5', 'c1', 'c2',
'c3', 'c4']
-
- assert names == expected
+ assert names == ['a', 'b1', 'b2', 'b3', 'b4', 'b5', 'c1', 'c2',
'c3', 'c4']
+ }
+
+ void testPrePostOrder() {
+ def root = createTreeFromXmlParser()
+ def combos = [[false, true], ['depthFirst',
'breadthFirst']].combinations()
+ def actual = combos.collect{ preorder, type ->
+ root."$type"(preorder)*.name()
+ }*.toString().join('\n')
+ def expected = '''
+ [childa, childb, parent1, childa, grandchild, childb, childc,
parent2, root]
--- End diff --
Might improve readability to use capital letters or numbers on children.
> In groovy.util.Node.depthFirst please Provide a way to Specify In-order,
> pre-order, post-order Ordering
> -------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-7486
> URL: https://issues.apache.org/jira/browse/GROOVY-7486
> Project: Groovy
> Issue Type: Improvement
> Components: groovy-jdk
> Reporter: Suminda Dharmasena
> Priority: Minor
>
> Please provide a way to specify the ordering in depth 1st traversal.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)