Subject: | Widths incorrectly set when using addChildren |
Date: | Mon, 27 Oct 2008 04:00:52 -0700 (PDT) |
To: | bug-Tree-Simple [...] rt.cpan.org |
From: | David Cryer <david_cryer [...] yahoo.com> |
Hi there,
I've found that addChildren only appears to increment the width of the node that the children are added to rather than correctly adding them up as the code below shows. Clearly I can work round this with suitable use of fixWidth or by adding the children individually.
Found on a system running:
Tree:Simple version 1.18
Perl, v5.8.8
Linux 2.6.16.21-0.25-smp #1 SMP Tue Sep 19 07:26:15 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux
Otherwise this is proving to be a very useful module.
Thanks,
David
#!/usr/bin/perl
use Tree::Simple;
# make a tree root
my $n0 = Tree::Simple->new("0");
my $n00= Tree::Simple->new("0");
my $n01= Tree::Simple->new("0");
my $n02= Tree::Simple->new("0");
my $n03= Tree::Simple->new("0");
$n0->addChild($n00);
$n0->addChildren(($n01, $n02, $n03));
print $n0->getWidth();
$n0->fixWidth();
print $n0->getWidth();