groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7486) In groovy.util.Node.depthFirst please Provide a way to Specify In-order, pre-order, post-order Ordering
Date Mon, 13 Jul 2015 14:24:04 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-7486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14624704#comment-14624704
] 

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_r34467403
  
    --- 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 --
    
    Minor point, but might improve test readability by changing from a multiline string to
a concatenated string with trailing comments labeling the combination.


> 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)

Mime
View raw message