comparison _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
comparison
equal deleted inserted replaced
35:f25d021780b3 36:1828103371d0
8 use IMPL::Class::Property; 8 use IMPL::Class::Property;
9 use IMPL::Test qw(test failed shared); 9 use IMPL::Test qw(test failed shared);
10 10
11 require IMPL::DOM::Schema; 11 require IMPL::DOM::Schema;
12 require IMPL::DOM::Navigator::Builder; 12 require IMPL::DOM::Navigator::Builder;
13 require IMPL::DOM::Navigator::SimpleBuilder;
13 require IMPL::DOM::Document; 14 require IMPL::DOM::Document;
14 15
15 BEGIN { 16 BEGIN {
16 public property schemaDoc => prop_all; 17 public property schemaDoc => prop_all;
17 } 18 }
82 print "Validate: ",tv_interval($t,[gettimeofday]),"\n"; 83 print "Validate: ",tv_interval($t,[gettimeofday]),"\n";
83 84
84 return 1; 85 return 1;
85 }; 86 };
86 87
88 test BuildSimpleDocument => sub {
89 my ($this) = @_;
90
91 my $builder = IMPL::DOM::Navigator::SimpleBuilder->new();
92
93 use Time::HiRes qw(gettimeofday tv_interval);
94
95 my $t = [gettimeofday];
96
97 $builder->NavigateCreate('personInfo', version => '1');
98 $builder->NavigateCreate('firstName')->nodeValue('Nemo');
99 $builder->Back();
100 $builder->NavigateCreate('lastName')->nodeValue('Nobel');
101 $builder->Back();
102 $builder->NavigateCreate('lastName')->nodeValue('Gardum');
103 $builder->Back();
104 for(1..100) {
105 $builder->NavigateCreate('address', local => 1);
106 $builder->NavigateCreate('street')->nodeValue('Hellroad');
107 $builder->Back();
108 $builder->NavigateCreate('line')->nodeValue($_);
109 $builder->Back();
110 $builder->Back();
111 }
112 $builder->Back();
113
114 print "Build: ",tv_interval($t,[gettimeofday]),"\n";
115 $t = [gettimeofday];
116 print $_->Message,"\n" foreach $this->schemaDoc->Validate($builder->Document);
117 print "Validate: ",tv_interval($t,[gettimeofday]),"\n";
118
119 $t = [gettimeofday];
120 for (1...100) {
121 my $node = new IMPL::DOM::Node(nodeName => 'dummy', foo => 'bar');
122 $node->nodeValue('dummy content');
123 }
124 print "Create a set of nodes: ",tv_interval($t,[gettimeofday]),"\n";
125
126 return 1;
127 };
128
87 129
88 1; 130 1;