Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Проверка входных значений

  • Loading branch information...
commit ac620dd327d4556ec2069adcc19c5aa23e708d90 1 parent 194816d
@rshadow rshadow authored
View
6 debian/changelog
@@ -1,3 +1,9 @@
+libmojolicious-plugin-human-perl (0.2-1) nowtaxi; urgency=low
+
+ * Fix warnings
+
+ -- Roman V. Nikolaev <rshadow@rambler.ru> Tue, 18 Dec 2012 21:55:18 +0400
+
libmojolicious-plugin-human-perl (0.1-1) nowtaxi; urgency=low
* Initial Release.
View
6 lib/Mojolicious/Plugin/Human.pm
@@ -10,7 +10,7 @@ use Carp;
use DateTime;
use DateTime::Format::DateParse;
-our $VERSION = '0.1';
+our $VERSION = '0.2';
=encoding utf-8
@@ -171,6 +171,7 @@ sub register {
$app->helper(human_money => sub {
my ($self, $str) = @_;
+ return $str if !defined($str) || !length($str);
my $delim = $conf->{money_delim};
my $digit = $conf->{money_digit};
$str = sprintf '%.2f', $str;
@@ -198,6 +199,9 @@ sub register {
$app->helper(human_suffix => sub {
my ($self, $str, $count, $one, $two, $many) = @_;
+ return unless defined $str;
+ return $str unless defined $count;
+
# Last digit
my $tail = abs( $count ) % 10;
View
6 t/010_human.t
@@ -6,7 +6,7 @@ use utf8;
use open qw(:std :utf8);
use lib qw(lib ../lib ../../lib);
-use Test::More tests => 21;
+use Test::More tests => 23;
use Encode qw(decode encode);
@@ -52,6 +52,10 @@ $t->app->routes->post("/test/human")->to( cb => sub {
ok $self->human_date( $dstr ) eq $dt->strftime('%F'),
'human_date';
+ ok !defined $self->human_money(),
+ 'human_money undefined';
+ ok $self->human_money('') eq '',
+ 'human_money empty';
ok $self->human_money('12345678.00') eq '12,345,678.00',
'human_money';

0 comments on commit ac620dd

Please sign in to comment.
Something went wrong with that request. Please try again.