Skip to content

Commit

Permalink
Added a new test file that running the example given in Tree::Simple:…
Browse files Browse the repository at this point in the history
…:Visitor object POD
  • Loading branch information
Takadonet committed Dec 20, 2010
1 parent ff3c84e commit 6caa82d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions t/test_visitor.t
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"

0 comments on commit 6caa82d

Please sign in to comment.