|
Groovy example source code file (NavigationTest.groovy)
The Groovy NavigationTest.groovy source codepackage groovy.tree /** * Simple test of tree walking */ class NavigationTest extends GroovyTestCase { void testDepthFirst() { def tree = createTree() def names = tree.depthFirst().collect { it.name() } def expected = ['a', 'b1', 'b2', 'c1', 'c2', 'b3', 'b4', 'c3', 'c4', 'b5'] assert names == expected } void testBreadthFirst() { def tree = createTree() def names = tree.breadthFirst().collect { it.name() } def expected = ['a', 'b1', 'b2', 'b3', 'b4', 'b5', 'c1', 'c2', 'c3', 'c4'] assert names == expected } protected def createTree() { def b = NodeBuilder.newInstance() def root = b.a(a:5, b:7) { b1() b2 { c1() c2() } b3() b4 { c3() c4() } b5() } assert root != null println(root) return root } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy NavigationTest.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.