2 use Test::More tests => 17;
7 use_ok( 'HTML::Parse' );
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
14 our $TestInput = "t/oldparse.html";
19 open("INFILE", "$TestInput") || die "$!" ;
24 my $own_builder = new HTML::TreeBuilder;
25 isa_ok( $own_builder, 'HTML::TreeBuilder' );
27 my $obj_h = parse_html $HTML, $own_builder;
28 isa_ok( $obj_h, "HTML::TreeBuilder", "existing TreeBuilder handled OK." );
30 my $h = parse_html $HTML;
31 isa_ok( $h, "HTML::TreeBuilder" );
33 # This ensures that the output from $h->dump goes to STDOUT
35 ok ($html = $h->as_HTML(undef, ' '), "Get html as string." );
37 # This is a very simple test just to ensure that we get something
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" );
44 my $bad_file = parse_htmlfile( "non-existent-file.html" );
45 ok( !$bad_file, "Properly returned undef on missing file." );
47 my $own_obj_parser2 = parse_htmlfile( "t/oldparse.html", $own_builder );
48 isa_ok( $own_obj_parser2, "HTML::TreeBuilder" );
51 my $h2 = parse_htmlfile( "t/oldparse.html" );
52 isa_ok( $h2, "HTML::TreeBuilder" );
54 ok ($html = $h2->as_HTML(undef, ' '), "Get html as string." );
56 # This is a very simple test just to ensure that we get something
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" );