This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[PATCH] Minor problem in cookie.t
[perl5.git] / cpan / CGI / t / param_fetch.t
1 #!perl
2
3 # Tests for the param_fetch() method.
4
5 use Test::More 'no_plan';
6 use CGI;
7
8 {
9     my $q = CGI->new('b=baz;a=foo;a=bar');
10
11     is $q->param_fetch('a')->[0] => 'foo', 'first "a" is "foo"';
12     is $q->param_fetch( -name => 'a' )->[0] => 'foo',
13       'first "a" is "foo", with -name';
14     is $q->param_fetch('a')->[1] => 'bar', 'second "a" is "bar"';
15     is_deeply $q->param_fetch('a') => [qw/ foo bar /], 'a is array ref';
16     is_deeply $q->param_fetch( -name => 'a' ) => [qw/ foo bar /],
17       'a is array ref, w/ name';
18
19     is $q->param_fetch('b')->[0] => 'baz', '"b" is "baz"';
20     is_deeply $q->param_fetch('b') => [qw/ baz /], 'b is array ref too';
21
22     is_deeply $q->param_fetch, [], "param_fetch without parameters";
23
24     is_deeply $q->param_fetch( 'a', 'b' ), [qw/ foo bar /],
25       "param_fetch only take first argument";
26 }