1# Before `make install' is performed this script should be runnable with 2# `make test'. After `make install' it should work as `perl test.pl' 3 4BEGIN { 5 unshift @INC, 'examples'; 6} 7 8use XML::Directory(qw(get_dir)); 9use XML::Directory::String; 10use Cwd; 11 12BEGIN { $| = 1; print "1..5\n"; } 13END {print "There were problems!\n" unless $sum == 5;} 14END {print "Passed\n" if $sum == 5;} 15 16# 1 17$r[0] = 1; 18print "not ok 1\n" unless $r[0]; 19print "ok 1\n" if $r[0]; 20 21# 2 22my @xml = get_dir('examples',1); 23my $xml = join '', @xml; 24chdir('..'); 25$r[1] = 1 if $xml =~ /dir2xml_string.pl/; 26print "not ok 2\n" unless $r[1]; 27print "ok 2\n" if $r[1]; 28 29# 3 30my $depth0 = 25; 31my $dir = new XML::Directory::String('examples',1,$depth0); 32my $depth = $dir->get_maxdepth; 33$r[2] = 1 if $depth == $depth0 ; 34print "not ok 3\n" unless $r[2]; 35print "ok 3\n" if $r[2]; 36 37#4 38eval "require XML::SAX::Base"; 39if ($@) { 40 $r[3] = 1; 41 print "skipping 4\n"; 42 43} else { 44 require XML::Directory::SAX; 45 require MyHandler; 46 require MyErrorHandler; 47 my $h = MyHandler->new(); 48 my $e = MyErrorHandler->new(); 49 my $dir = XML::Directory::SAX->new(Handler => $h, details => 3); 50 my $rc = $dir->get_details; 51 $r[3] = 1 if $rc == 3; 52 print "not ok 4\n" unless $r[3]; 53 print "ok 4\n" if $r[3]; 54} 55 56#5 57eval "require RDF::Notation3"; 58if ($@) { 59 $r[4] = 1; 60 print "skipping 5\n"; 61 62} else { 63 require RDF::Notation3; 64 my $dir = new XML::Directory::String('examples',2); 65 $dir->enable_rdf('index.n3'); 66 $dir->parse; 67 $res = $dir->get_string; 68 $r[4] = 1 if $res =~ /dc:Title/; 69 print "not ok 5\n" unless $r[4]; 70 print "ok 5\n" if $r[4]; 71} 72 73$sum = 0; 74foreach (@r) { 75 $sum += $_; 76} 77