Dancer2
view release on metacpan or search on metacpan
t/classes/Dancer2-Core-Route/match.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use Dancer2::Core::Request;
use Dancer2::Core::Route;
use Capture::Tiny 0.12 'capture_stderr';
use Ref::Util qw<is_regexpref>;
use lib 't/lib';
my @tests = (
[ [ 'get', '/', sub {11} ], '/', [ {}, 11 ] ],
[ [ 'get', '/', sub {11} ],
'/failure',
[ undef, 11 ]
],
# token tests
[ [ 'get', '/hello/:name', sub {22} ],
'/hello/sukria',
[ { name => 'sukria' }, 22 ]
],
[ [ 'get', '/hello/:name?', sub {22} ],
'/hello/',
[ { name => undef }, 22 ]
],
# prefix tests
[ [ 'get', '/', sub {33}, '/forum' ],
'/forum/',
[ {}, 33 ]
],
[ [ 'get', '/', sub {33}, '/forum' ],
'/forum/',
[ {}, 33 ]
],
[ [ 'get', '/mywebsite', sub {33}, '/forum' ],
'/forum/mywebsite',
[ {}, 33 ]
],
[ [ 'get', '', sub {'concat'}, '/' ],
'/',
[ {}, 'concat' ]
],
# token in prefix tests
[ [ 'get', 'name', sub {35}, '/hello/:' ],
'/hello/sukria',
[ { name => 'sukria' }, 35 ],
],
[ [ 'get', '/', sub {36}, '/hello/:name' ],
'/hello/sukria/',
[ { name => 'sukria' }, 36 ],
],
# splat test
[ [ 'get', '/file/*.*', sub {44} ],
'/file/dist.ini',
[ { splat => [ 'dist', 'ini' ] }, 44 ]
],
# splat in prefix
[ [ 'get', '', sub {42}, '/forum/*'],
'/forum/dancer',
[ { splat => [ 'dancer' ] }, 42 ]
],
( run in 1.216 second using v1.01-cache-2.11-cpan-39bf76dae61 )