Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libwww-mechanize-perl / libwww-mechanize-perl-1.34 / t / mech-dump / mech-dump.t
1 #!perl -Tw
2
3 use warnings;
4 use strict;
5
6 use Test::More;
7 use File::Spec;
8 use LWP;
9
10 BEGIN {
11     delete @ENV{ qw( IFS CDPATH ENV BASH_ENV PATH ) };
12 }
13
14 plan skip_all => 'Not installing mech-dump' if -e File::Spec->catfile( qw( t SKIP-MECH-DUMP ) );
15 plan tests => 4;
16
17 my $exe = File::Spec->catfile( qw( blib script mech-dump ) );
18 if ( $^O eq 'VMS' ) {
19     $exe = qq[mcr $^X "-mblib" $exe];
20 }
21
22 # Simply use a file: uri instead of the filename to make this test
23 # more independent of what URI::* thinks.
24 my $source = 'file:t/google.html';
25
26 my $perl;
27 $perl = $1 if $^X =~ /^(.+)$/;
28 my $command = "$perl -Mblib $exe --forms $source";
29
30 my $actual = `$command`;
31
32 my $expected;
33 if ( $LWP::VERSION < 5.800 ) {
34     $expected = <<'EOF';
35 GET file:/target-page [bob-the-form]
36   hl=en                           (hidden)
37   ie=ISO-8859-1                   (hidden)
38   q=
39   btnG=Google Search              (submit)
40   btnI=I'm Feeling Lucky          (submit)
41 EOF
42 } else {
43     $expected = <<'EOF';
44 GET file:/target-page [bob-the-form]
45   hl=en                          (hidden readonly)
46   ie=ISO-8859-1                  (hidden readonly)
47   q=                             (text)
48   btnG=Google Search             (submit)
49   btnI=I'm Feeling Lucky         (submit)
50 EOF
51 }
52
53 my @actual = split /\s*\n/, $actual;
54 my @expected = split /\s*\n/, $expected;
55
56 # First line is platform-dependent, so handle it accordingly.
57 shift @expected;
58 my $first = shift @actual;
59 like( $first, qr/^GET file:.*\/target-page \[bob-the-form\]/, 'First line matches' );
60
61 cmp_ok( @expected, '>', 0, 'Still some expected' );
62 cmp_ok( @actual, '>', 0, 'Still some actual' );
63
64 is_deeply( \@actual, \@expected, 'Rest of the lines match' );
65