| 1 | #!/opt/perl58/bin/perl -w |
| 2 | |
| 3 | use Test::Morescip-perl cpan WWW-Mechanize-FormFiller 0.13 Test/More/ 'no_plan'; |
| 4 | |
| 5 | package Catchscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/; |
| 6 | |
| 7 | sub TIEHANDLEscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/TIEHANDLE(). { |
| 8 | my($class, $var) = @_scip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/`@_`.; |
| 9 | return blessscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/bless(). { var => $var }, $class; |
| 10 | } |
| 11 | |
| 12 | sub PRINTscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/PRINT(). { |
| 13 | my($self) = shiftscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/shift().; |
| 14 | ${'main::'.$self->{var}} .= joinscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/join(). '', @_scip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/`@_`.; |
| 15 | } |
| 16 | |
| 17 | sub OPENscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/OPEN(). {} # XXX Hackery in case the user redirects |
| 18 | sub CLOSEscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/CLOSE(). {} # XXX STDERR/STDOUT. This is not the behavior we want. |
| 19 | |
| 20 | sub READscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/READ(). {} |
| 21 | sub READLINEscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/READLINE(). {} |
| 22 | sub GETCscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/GETC(). {} |
| 23 | sub BINMODEscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/BINMODE(). {} |
| 24 | |
| 25 | my $Original_File = 'lib/WWW/Mechanize/FormFiller/Value/Random/Chars.pm'; |
| 26 | |
| 27 | package mainscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/; |
| 28 | |
| 29 | # pre-5.8.0's warns aren't caught by a tied STDERR. |
| 30 | $SIGscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`%SIG`.{__WARN__} = sub { $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_. .= joinscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/join(). '', @_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`@_`.; }; |
| 31 | tie *STDOUT, 'Catch', '_STDOUT_' or diescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/die(). $!scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$!`.; |
| 32 | tie *STDERR, 'Catch', '_STDERR_' or diescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/die(). $!scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$!`.; |
| 33 | |
| 34 | SKIP: { |
| 35 | # A header testing whether we find all prerequisites : |
| 36 | # Check for module WWW::Mechanize::FormFiller |
| 37 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). WWW::Mechanize::FormFiller }; |
| 38 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module WWW::Mechanize::FormFiller to run this test", 1 |
| 39 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 40 | |
| 41 | # Check for module WWW::Mechanize::FormFiller::Value::Random::Chars |
| 42 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). WWW::Mechanize::FormFiller::Value::Random::Chars }; |
| 43 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module WWW::Mechanize::FormFiller::Value::Random::Chars to run this test", 1 |
| 44 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 45 | |
| 46 | |
| 47 | # The original POD test |
| 48 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 49 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 50 | eval q{ |
| 51 | my $example = sub { |
| 52 | local $^W = 0; |
| 53 | |
| 54 | #line 33 lib/WWW/Mechanize/FormFiller/Value/Random/Chars.pm |
| 55 | |
| 56 | use WWW::Mechanize::FormFiller; |
| 57 | use WWW::Mechanize::FormFiller::Value::Random::Chars; |
| 58 | |
| 59 | my $f = WWW::Mechanize::FormFiller->new(); |
| 60 | |
| 61 | # Create a random value for the HTML field "login" |
| 62 | |
| 63 | my $login = WWW::Mechanize::FormFiller::Value::Random::Chars->new( |
| 64 | login => set => 'alpha', min => 3, max => 8 ); |
| 65 | $f->add_value( login => $login ); |
| 66 | |
| 67 | # Alternatively take the following shorthand, which adds the |
| 68 | # field to the list as well : |
| 69 | |
| 70 | # If there is no password, put a random one out of the list there |
| 71 | my $password = $f->add_filler( password => 'Random::Chars' ); |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | ; |
| 77 | |
| 78 | } |
| 79 | }; |
| 80 | isscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/is().($@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`., '', "example from line 33"); |
| 81 | |
| 82 | }; |
| 83 | SKIP: { |
| 84 | # A header testing whether we find all prerequisites : |
| 85 | # Check for module HTML::Form |
| 86 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). HTML::Form }; |
| 87 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module HTML::Form to run this test", 1 |
| 88 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 89 | |
| 90 | # Check for module WWW::Mechanize::FormFiller |
| 91 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). WWW::Mechanize::FormFiller }; |
| 92 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module WWW::Mechanize::FormFiller to run this test", 1 |
| 93 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 94 | |
| 95 | # Check for module WWW::Mechanize::FormFiller::Value::Random::Chars |
| 96 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). WWW::Mechanize::FormFiller::Value::Random::Chars }; |
| 97 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module WWW::Mechanize::FormFiller::Value::Random::Chars to run this test", 1 |
| 98 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 99 | |
| 100 | |
| 101 | # The original POD test |
| 102 | { |
| 103 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 104 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 105 | #line 33 lib/WWW/Mechanize/FormFiller/Value/Random/Chars.pm |
| 106 | |
| 107 | use WWW::Mechanize::FormFillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/; |
| 108 | use WWW::Mechanize::FormFiller::Value::Random::Charsscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/Value/Random/Chars/; |
| 109 | |
| 110 | my $f = WWW::Mechanize::FormFiller->newscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/new().(); |
| 111 | |
| 112 | # Create a random value for the HTML field "login" |
| 113 | |
| 114 | my $login = WWW::Mechanize::FormFiller::Value::Random::Chars->newscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/Value/Random/Chars/new().( |
| 115 | login => set => 'alpha', min => 3, max => 8 ); |
| 116 | $f->add_valuescip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/add_value().( login => $login ); |
| 117 | |
| 118 | # Alternatively take the following shorthand, which adds the |
| 119 | # field to the list as well : |
| 120 | |
| 121 | # If there is no password, put a random one out of the list there |
| 122 | my $password = $f->add_fillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/add_filler().( password => 'Random::Chars' ); |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). HTML::Form; |
| 128 | my $form = HTML::Form->parsescip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/parse().('<html><body><form method=get action=/> |
| 129 | <input type=text name=login /> |
| 130 | <input type=text name=password /> |
| 131 | </form></body></html>','http://www.example.com/'); |
| 132 | $f->fill_formscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/fill_form().($form); |
| 133 | likescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/like().( $form->valuescip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/value().('login'), qr/^([a-zA-Z]+)$/, "Login gets set"); |
| 134 | likescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/like().( $form->valuescip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/value().('password'), qr/^([a-zA-Z]+)$/, "Password gets set"); |
| 135 | |
| 136 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 137 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 138 | } |
| 139 | |
| 140 | }; |
| 141 | SKIP: { |
| 142 | # A header testing whether we find all prerequisites : |
| 143 | |
| 144 | # The original POD test |
| 145 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 146 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 147 | |
| 148 | }; |