Skip to content

Commit

Permalink
better empty element test case
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 4, 2011
1 parent b7ea220 commit aabd046
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 28 deletions.
7 changes: 2 additions & 5 deletions lib/Mojo/Home.pm
Expand Up @@ -18,11 +18,7 @@ has app_class => 'Mojo::HelloWorld';

# "I'm normally not a praying man, but if you're up there,
# please save me Superman."
sub new {
my $self = shift->SUPER::new();
$self->parse(@_) if @_;
return $self;
}
sub new { shift->SUPER::new()->parse(@_) }

sub detect {
my ($self, $class) = @_;
Expand Down Expand Up @@ -109,6 +105,7 @@ sub mojo_lib_dir { File::Spec->catdir(dirname(__FILE__), '..') }

sub parse {
my ($self, $path) = @_;
return $self unless defined $path;
$self->{parts} = [File::Spec->splitdir($path)];
return $self;
}
Expand Down
6 changes: 1 addition & 5 deletions lib/Mojo/URL.pm
Expand Up @@ -19,11 +19,7 @@ our $PCHAR = "$UNRESERVED$SUBDELIM\%\:\@";

# "Homer, it's easy to criticize.
# Fun, too."
sub new {
my $self = shift->SUPER::new();
$self->parse(@_);
return $self;
}
sub new { shift->SUPER::new()->parse(@_) }

sub authority {
my ($self, $authority) = @_;
Expand Down
6 changes: 1 addition & 5 deletions lib/Mojolicious/Routes.pm
Expand Up @@ -36,11 +36,7 @@ sub AUTOLOAD {

sub DESTROY { }

sub new {
my $self = shift->SUPER::new();
$self->parse(@_);
return $self;
}
sub new { shift->SUPER::new()->parse(@_) }

sub add_child {
my ($self, $route) = @_;
Expand Down
6 changes: 1 addition & 5 deletions lib/Mojolicious/Routes/Pattern.pm
Expand Up @@ -14,11 +14,7 @@ has tree => sub { [] };
has wildcard_start => '*';

# "This is the worst kind of discrimination. The kind against me!"
sub new {
my $self = shift->SUPER::new();
$self->parse(@_);
return $self;
}
sub new { shift->SUPER::new()->parse(@_) }

sub match {
my ($self, $path) = @_;
Expand Down
18 changes: 10 additions & 8 deletions t/mojo/path.t
Expand Up @@ -3,7 +3,7 @@ use Mojo::Base -strict;

use utf8;

use Test::More tests => 173;
use Test::More tests => 175;

# "This is the greatest case of false advertising I’ve seen since I sued the
# movie 'The Never Ending Story.'"
Expand Down Expand Up @@ -203,15 +203,17 @@ is $path->parts->[4], '23', 'right part';
is $path->parts->[5], undef, 'no part';
ok $path->leading_slash, 'has leading slash';
ok $path->trailing_slash, 'has trailing slash';
$path = Mojo::Path->new('///foo/bar/23///');
is "$path", '///foo/bar/23///';
$path = Mojo::Path->new('///foo///bar/23///');
is "$path", '///foo///bar/23///';
is $path->parts->[0], '', 'right part';
is $path->parts->[1], '', 'right part';
is $path->parts->[2], 'foo', 'right part';
is $path->parts->[3], 'bar', 'right part';
is $path->parts->[4], '23', 'right part';
is $path->parts->[5], '', 'right part';
is $path->parts->[6], '', 'right part';
is $path->parts->[7], undef, 'no part';
is $path->parts->[3], '', 'right part';
is $path->parts->[4], '', 'right part';
is $path->parts->[5], 'bar', 'right part';
is $path->parts->[6], '23', 'right part';
is $path->parts->[7], '', 'right part';
is $path->parts->[8], '', 'right part';
is $path->parts->[9], undef, 'no part';
ok $path->leading_slash, 'has leading slash';
ok $path->trailing_slash, 'has trailing slash';

0 comments on commit aabd046

Please sign in to comment.