Add ARM files
[dh-make-perl] / dev / arm / libhtml-tree-perl / libhtml-tree-perl-3.23 / t / oldparse.t
1 #!perl -Tw
2 use Test::More tests => 17;
3
4 use strict;
5
6 BEGIN {
7     use_ok( 'HTML::Parse' );
8 }
9
10 # This is a very simple test.  It basically just ensures that the
11 # HTML::Parse module is parsed ok by perl and that it will interact
12 # nicely with the rest of our modules
13
14 our $TestInput = "t/oldparse.html";
15
16 my $HTML ;
17 {
18         local $/ = undef ;
19         open("INFILE", "$TestInput") || die "$!" ;
20         $HTML=<INFILE> ;
21         close(INFILE) ;
22 }
23
24 my $own_builder = new HTML::TreeBuilder;
25 isa_ok( $own_builder, 'HTML::TreeBuilder' );
26
27 my $obj_h = parse_html $HTML, $own_builder; 
28 isa_ok( $obj_h, "HTML::TreeBuilder", "existing TreeBuilder handled OK." );
29
30 my $h = parse_html $HTML;
31 isa_ok( $h, "HTML::TreeBuilder" );
32
33 # This ensures that the output from $h->dump goes to STDOUT
34 my $html;
35 ok ($html = $h->as_HTML(undef, '  '), "Get html as string." );
36
37 # This is a very simple test just to ensure that we get something
38 # sensible back.
39 like( $html, qr/<BODY>/i, "<BODY> found OK." );
40 like( $html, qr/www\.sn\.no/, "found www.sn.no link" );
41 unlike( $html, qr/comment/, "Didn't find comment" );
42 like( $html, qr/Gisle/, "found Gisle" );
43
44 my $bad_file = parse_htmlfile( "non-existent-file.html" );
45 ok( !$bad_file, "Properly returned undef on missing file." );
46
47 my $own_obj_parser2 = parse_htmlfile( "t/oldparse.html", $own_builder ); 
48 isa_ok( $own_obj_parser2, "HTML::TreeBuilder" );
49
50
51 my $h2 = parse_htmlfile( "t/oldparse.html" );
52 isa_ok( $h2, "HTML::TreeBuilder" );
53
54 ok ($html = $h2->as_HTML(undef, '  '), "Get html as string." );
55
56 # This is a very simple test just to ensure that we get something
57 # sensible back.
58 like( $html, qr/<BODY>/i, "parse_htmlfile: <BODY> found OK." );
59 like( $html, qr/www\.sn\.no/, "parse_htmlfile: found www.sn.no link" );
60 unlike( $html, qr/comment/, "parse_htmlfile: found comment" );
61 like( $html, qr/Gisle/, "parse_htmlfile: found Gisle" );
62