Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more Mojo::Parameters tests
  • Loading branch information
kraih committed May 30, 2012
1 parent 4bd225d commit 0864002
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Parameters.pm
Expand Up @@ -37,7 +37,7 @@ sub append {
my $value = $pairs[$i + 1] // '';

# Single value
unless (ref $value eq 'ARRAY') { push @$params, $key => $value }
if (ref $value ne 'ARRAY') { push @$params, $key => $value }

# Multiple values
else { push @$params, $key => (defined $_ ? "$_" : '') for @$value }
Expand Down
10 changes: 7 additions & 3 deletions t/mojo/parameters.t
Expand Up @@ -2,7 +2,7 @@ use Mojo::Base -strict;

use utf8;

use Test::More tests => 80;
use Test::More tests => 84;

# "Now that's a wave of destruction that's easy on the eyes."
use Mojo::Parameters;
Expand Down Expand Up @@ -151,11 +151,15 @@ is_deeply $p->to_hash,
{foo => ['bar', 'baz'], a => 'b', bar => ['bas', 'test']}, 'right structure';
$p = Mojo::Parameters->new(foo => ['ba;r', 'b;az']);
is_deeply $p->to_hash, {foo => ['ba;r', 'b;az']}, 'right structure';
$p->append(foo => ['bar'], foo => ['baz']);
is_deeply $p->to_hash, {foo => ['ba;r', 'b;az', 'bar', 'baz']},
$p->append(foo => ['bar'], foo => ['baz', 'yada']);
is_deeply $p->to_hash, {foo => ['ba;r', 'b;az', 'bar', 'baz', 'yada']},
'right structure';
is $p->param('foo'), 'ba;r', 'right value';
is_deeply [$p->param('foo')], [qw(ba;r b;az bar baz yada)], 'right values';
$p = Mojo::Parameters->new(foo => ['ba;r', 'b;az'], bar => 23);
is_deeply $p->to_hash, {foo => ['ba;r', 'b;az'], bar => 23}, 'right structure';
is $p->param('foo'), 'ba;r', 'right value';
is_deeply [$p->param('foo')], [qw(ba;r b;az)], 'right values';

# Unicode
$p = Mojo::Parameters->new;
Expand Down

0 comments on commit 0864002

Please sign in to comment.