diff _test/Test/DOM/Builder.pm @ 36:1828103371d0

DOM in works
author Sergey
date Fri, 20 Nov 2009 16:48:08 +0300
parents f25d021780b3
children c2e7f7c96bcd
line wrap: on
line diff
--- a/_test/Test/DOM/Builder.pm	Tue Nov 17 17:46:24 2009 +0300
+++ b/_test/Test/DOM/Builder.pm	Fri Nov 20 16:48:08 2009 +0300
@@ -10,6 +10,7 @@
 
 require IMPL::DOM::Schema;
 require IMPL::DOM::Navigator::Builder;
+require IMPL::DOM::Navigator::SimpleBuilder;
 require IMPL::DOM::Document;
 
 BEGIN {
@@ -84,5 +85,46 @@
     return 1;
 };
 
+test BuildSimpleDocument => sub {
+    my ($this) = @_;
+    
+    my $builder = IMPL::DOM::Navigator::SimpleBuilder->new();
+    
+    use Time::HiRes qw(gettimeofday tv_interval);
+    
+    my $t = [gettimeofday];
+    
+    $builder->NavigateCreate('personInfo', version => '1');
+        $builder->NavigateCreate('firstName')->nodeValue('Nemo');
+        $builder->Back();
+        $builder->NavigateCreate('lastName')->nodeValue('Nobel');
+        $builder->Back();
+        $builder->NavigateCreate('lastName')->nodeValue('Gardum');
+        $builder->Back();
+        for(1..100) {
+            $builder->NavigateCreate('address', local => 1);
+                $builder->NavigateCreate('street')->nodeValue('Hellroad');
+                $builder->Back();
+                $builder->NavigateCreate('line')->nodeValue($_);
+                $builder->Back();
+            $builder->Back();
+        }
+    $builder->Back();
+    
+    print "Build: ",tv_interval($t,[gettimeofday]),"\n";
+    $t = [gettimeofday];
+    print $_->Message,"\n" foreach $this->schemaDoc->Validate($builder->Document);
+    print "Validate: ",tv_interval($t,[gettimeofday]),"\n";
+    
+    $t = [gettimeofday];
+    for (1...100) {
+        my $node = new IMPL::DOM::Node(nodeName => 'dummy', foo => 'bar');
+        $node->nodeValue('dummy content');
+    }
+    print "Create a set of nodes: ",tv_interval($t,[gettimeofday]),"\n";
+    
+    return 1;
+};
+
 
 1;