Skip to content

Commit

Permalink
Remove leading spaces where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ambs authored and xsawyerx committed Oct 7, 2012
1 parent fc251ea commit a8bf300
Show file tree
Hide file tree
Showing 3 changed files with 287 additions and 2 deletions.
287 changes: 287 additions & 0 deletions t/moo/types.t
@@ -0,0 +1,287 @@
use strict;
use warnings;
use Test::More tests => 46;
use Test::Fatal;
use Dancer::Moo::Types;

is(
exception { Dancer::Moo::Types::Str(undef) },
undef,
'Str accepts undef value',
);

is(
exception { Dancer::Moo::Types::Str('something') },
undef,
'Str',
);

like(
exception { Dancer::Moo::Types::Str({foo => 'something'}) },
qr{does not pass the type constraint check for type `Str'},
'Str',
);

is(
exception { Dancer::Moo::Types::Num(34) },
undef,
'Num',
);

is(
exception { Dancer::Moo::Types::Num(undef) },
undef,
'Num accepts undef value',
);

like(
exception { Dancer::Moo::Types::Num('not a number') },
qr{does not pass the type constraint check for type `Num'},
'Num fail',
);

is(
exception { Dancer::Moo::Types::Bool(1) },
undef,
'Bool true value',
);

is(
exception { Dancer::Moo::Types::Bool(0) },
undef,
'Bool false value',
);

is(
exception { Dancer::Moo::Types::Bool(undef) },
undef,
'Bool accepts undef value',
);

like(
exception { Dancer::Moo::Types::Bool('2') },
qr{does not pass the type constraint check for type `Bool'},
'Bool fail',
);

is(
exception { Dancer::Moo::Types::Regexp(qr{.*}) },
undef,
'Regexp',
);

like(
exception { Dancer::Moo::Types::Regexp('/.*/') },
qr{does not pass the type constraint check for type `Regexp'},
'Regexp fail',
);

is(
exception { Dancer::Moo::Types::Regexp(undef) },
undef,
'Regexp accepts undef value',
);

is(
exception { Dancer::Moo::Types::HashRef({goo => 'le'}) },
undef,
'HashRef',
);

like(
exception { Dancer::Moo::Types::HashRef('/.*/') },
qr{does not pass the type constraint check for type `HashRef'},
'HashRef fail',
);

is(
exception { Dancer::Moo::Types::HashRef(undef) },
undef,
'HashRef accepts undef value',
);

is(
exception { Dancer::Moo::Types::ArrayRef([1, 2, 3, 4 ]) },
undef,
'ArrayRef',
);

like(
exception { Dancer::Moo::Types::ArrayRef('/.*/') },
qr{does not pass the type constraint check for type `ArrayRef'},
'ArrayRef fail',
);

is(
exception { Dancer::Moo::Types::ArrayRef(undef) },
undef,
'ArrayRef accepts undef value',
);

is(
exception { Dancer::Moo::Types::CodeRef( sub { 44 } ) },
undef,
'CodeRef',
);

like(
exception { Dancer::Moo::Types::CodeRef('/.*/') },
qr{does not pass the type constraint check for type `CodeRef'},
'CodeRef fail',
);

is(
exception { Dancer::Moo::Types::CodeRef(undef) },
undef,
'CodeRef accepts undef value',
);

{ package Foo; }
{ package Bar; }
my $f = bless {}, 'Foo';
my $b = bless {}, 'Bar';

is(
exception { Dancer::Moo::Types::ObjectOf( Foo => $f) },
undef,
'ObjectOf',
);

like(
exception { Dancer::Moo::Types::ObjectOf( Foo => $b) },
qr{does not pass the type constraint check for type `ObjectOf\(Foo\)'},
'ObjectOf fail',
);

is(
exception { Dancer::Moo::Types::ObjectOf(Foo => undef) },
undef,
'ObjectOf accepts undef value',
);

is(
exception { Dancer::Moo::Types::DancerPrefix('/foo') },
undef,
'DancerPrefix',
);

like(
exception { Dancer::Moo::Types::DancerPrefix('bar/something') },
qr{does not pass the type constraint check for type `DancerPrefix'},
'DancerPrefix fail',
);

is(
exception { Dancer::Moo::Types::DancerPrefix(undef) },
undef,
'DancerPrefix accepts undef value',
);

is(
exception { Dancer::Moo::Types::DancerAppName('Foo') },
undef,
'DancerAppName',
);

is(
exception { Dancer::Moo::Types::DancerAppName('Foo::Bar') },
undef,
'DancerAppName',
);

is(
exception { Dancer::Moo::Types::DancerAppName('Foo::Bar::Baz') },
undef,
'DancerAppName',
);

like(
exception { Dancer::Moo::Types::DancerAppName('Foo:Bar') },
qr{does not pass the type constraint check for type `DancerAppName'},
'DancerAppName fails with single colons',
);

like(
exception { Dancer::Moo::Types::DancerAppName('Foo:::Bar') },
qr{does not pass the type constraint check for type `DancerAppName'},
'DancerAppName fails with tripe colons',
);

like(
exception { Dancer::Moo::Types::DancerAppName('7Foo') },
qr{does not pass the type constraint check for type `DancerAppName'},
'DancerAppName fails with beginning number',
);

like(
exception { Dancer::Moo::Types::DancerAppName('Foo::45Bar') },
qr{does not pass the type constraint check for type `DancerAppName'},
'DancerAppName fails with beginning number',
);

like(
exception { Dancer::Moo::Types::DancerAppName('-F') },
qr{does not pass the type constraint check for type `DancerAppName'},
'DancerAppName fails with special character',
);

like(
exception { Dancer::Moo::Types::DancerAppName('Foo::-') },
qr{does not pass the type constraint check for type `DancerAppName'},
'DancerAppName fails with special character',
);

like(
exception { Dancer::Moo::Types::DancerAppName('Foo^') },
qr{does not pass the type constraint check for type `DancerAppName'},
'DancerAppName fails with special character',
);

is(
exception { Dancer::Moo::Types::DancerAppName(undef) },
undef,
'DancerAppName accepts undef value',
);

like(
exception { Dancer::Moo::Types::DancerAppName('') },
qr{does not pass the type constraint check for type `DancerAppName'},
'DancerAppName fails an empty string value',
);

is(
exception { Dancer::Moo::Types::DancerMethod('post') },
undef,
'DancerMethod',
);

like(
exception { Dancer::Moo::Types::DancerMethod('POST') },
qr{does not pass the type constraint check for type `DancerMethod'},
'DancerMethod fail',
);

is(
exception { Dancer::Moo::Types::DancerMethod(undef) },
undef,
'DancerMethod accepts undef value',
);

is(
exception { Dancer::Moo::Types::DancerHTTPMethod('POST') },
undef,
'DancerMethod',
);

like(
exception { Dancer::Moo::Types::DancerHTTPMethod('post') },
qr{does not pass the type constraint check for type `DancerMethod'},
'DancerMethod fail',
);

is(
exception { Dancer::Moo::Types::DancerHTTPMethod(undef) },
undef,
'DancerMethod accepts undef value',
);

1 change: 0 additions & 1 deletion t/plugin_syntax.t
Expand Up @@ -51,7 +51,6 @@ subtest caller_dsl => sub {

my $r = dancer_response GET => '/sitemap';
is $r->content, '^\/$, ^\/app$, ^\/foo$, ^\/foo\/plugin$, ^\/sitemap$'

};

subtest 'hooks in plugins' => sub {
Expand Down
1 change: 0 additions & 1 deletion t/request_upld.t
Expand Up @@ -136,6 +136,5 @@ do {
qr{Can't open.* using mode '<'},
);


unlink($file) if ($^O eq 'MSWin32');
};

0 comments on commit a8bf300

Please sign in to comment.