perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From go...@apache.org
Subject cvs commit: modperl-2.0/t/response/TestApache conftree.pm
Date Tue, 10 Aug 2004 22:48:27 GMT
gozer       2004/08/10 15:48:27

  Modified:    t/response/TestApache conftree.pm
  Log:
  Improve Apache::Directive tests by including a full tree traversal and
  calling a few new methods on node components : directive, args, filename
  & line_num
  
  Revision  Changes    Path
  1.12      +49 -2     modperl-2.0/t/response/TestApache/conftree.pm
  
  Index: conftree.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestApache/conftree.pm,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- conftree.pm	8 Jul 2004 04:52:06 -0000	1.11
  +++ conftree.pm	10 Aug 2004 22:48:27 -0000	1.12
  @@ -15,7 +15,10 @@
       my $r = shift;
   
       my $cfg = Apache::Test::config();
  -    plan $r, tests => 8;
  +    
  +    my $node_count = node_count();
  +    
  +    plan $r, tests => 8 + (5*$node_count);
   
       ok $cfg;
   
  @@ -60,7 +63,51 @@
   
           ok !$vhost_failed;
       }
  -
  +    
  +    traverse_tree ( \&test_node );
  +    
       Apache::OK;
  +}
  +
  +sub test_node {
  +    my ($data, $node) = @_;
  +    ok $node->directive;
  +    #Args can be null for argless directives
  +    ok $node->args || 1;
  +    #As string can be null for containers
  +    ok $node->as_string || 1;
  +    ok $node->filename;
  +    ok $node->line_num;
  +}
  +
  +sub traverse_tree {
  +    my ($sub, $data) = @_;
  +    my $node = Apache::Directive->conftree;
  +    while ($node) {
  +        $sub->($data, $node);
  +        if (my $kid = $node->first_child) {
  +            $node = $kid;
  +        } 
  +        elsif (my $next = $node->next) {
  +            $node = $next;
  +        }
  +        else {
  +            if (my $parent = $node->parent) {
  +                $node = $parent->next;
  +            }
  +            else {
  +                $node = undef;
  +            }
  +        }
  +    }
  +    return;
  +}
  +
  +sub node_count {
  +    my $node_count = 0;
  +    
  +    traverse_tree( sub { ${$_[0]}++ }, \$node_count );
  +    
  +    return $node_count;
   }
   1;
  
  
  

Mime
View raw message