-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new test file that running the example given in Tree::Simple:…
…:Visitor object POD
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use v6; | ||
use Test; | ||
plan 1; | ||
BEGIN | ||
{ | ||
@*INC.push('lib'); | ||
@*INC.push('blib'); | ||
} | ||
use Tree::Simple; | ||
use Tree::Simple::Visitor; | ||
|
||
# create a visitor instance | ||
my $visitor = Tree::Simple::Visitor.new(); | ||
|
||
# create a tree to visit | ||
my $tree = Tree::Simple.new($Tree::Simple::ROOT).addChildren( | ||
Tree::Simple.new("1.0"), | ||
Tree::Simple.new("2.0").addChild( | ||
Tree::Simple.new("2.1.0")), | ||
Tree::Simple.new("3.0")); | ||
|
||
# by default this will collect all the | ||
# node values in depth-first order into | ||
# our results | ||
$tree.accept($visitor); | ||
|
||
# get our results and print them | ||
my @results= <1.0 2.0 2.1.0 3.0>; | ||
|
||
is($visitor.getResults().join(', '), @results.join(', '),'Find correct children'); # prints "1.0, 2.0, 2.1.0, 3.0" | ||
|