| 1 | use Dancerscip-perl cpan Dancer 1.3522 Dancer/ ':tests'; |
| 2 | use Test::Morescip-perl cpan Dancer 1.3522 Test/More/; |
| 3 | |
| 4 | use Dancer::Testscip-perl cpan Dancer 1.3522 Dancer/Test/; |
| 5 | |
| 6 | planscip-perl cpan Dancer 1.3522 main/plan(). tests => 6; |
| 7 | |
| 8 | getscip-perl cpan Dancer 1.3522 main/get(). '/foo/**' => sub { show_splatscip-perl cpan Dancer 1.3522 main/show_splat().() }; |
| 9 | response_content_is [ GET => '/foo/a/b/c' ] => '(a,b,c)'; |
| 10 | |
| 11 | getscip-perl cpan Dancer 1.3522 main/get(). '/bar/*/**' => sub { show_splatscip-perl cpan Dancer 1.3522 main/show_splat().() }; |
| 12 | response_content_is [ GET => '/bar/a/b/c' ] => 'a:(b,c)'; |
| 13 | |
| 14 | getscip-perl cpan Dancer 1.3522 main/get(). '/alpha/**/gamma' => sub { show_splatscip-perl cpan Dancer 1.3522 main/show_splat().() }; |
| 15 | response_content_is [ GET => '/alpha/beta/delta/gamma' ] => '(beta,delta)'; |
| 16 | response_content_is [ GET => '/alpha/beta/gamma' ] => '(beta)'; |
| 17 | |
| 18 | # mixed tokens and splat |
| 19 | my $route_code = sub { |
| 20 | my $id = paramscip-perl cpan Dancer 1.3522 main/param(). 'id'; |
| 21 | $id = 'undef' unless definedscip-perl cpan Dancer 1.3522 main/defined(). $id; |
| 22 | my $splt = show_splatscip-perl cpan Dancer 1.3522 main/show_splat().(); |
| 23 | return "$id:$splt" |
| 24 | }; |
| 25 | getscip-perl cpan Dancer 1.3522 main/get(). '/some/:id/**/*' => $route_code; |
| 26 | response_content_is [ GET => '/some/where/to/run/and/hide' ] => 'where:(to,run,and):hide'; |
| 27 | |
| 28 | getscip-perl cpan Dancer 1.3522 main/get(). '/some/*/**/:id?' => $route_code; |
| 29 | response_content_is [ GET => '/some/one/to/say/boo/' ] => 'undef:one:(to,say,boo)'; |
| 30 | |
| 31 | sub show_splatscip-perl cpan Dancer 1.3522 main/show_splat(). { |
| 32 | return joinscip-perl cpan Dancer 1.3522 main/join(). ':', mapscip-perl cpan Dancer 1.3522 main/map(). { refscip-perl cpan Dancer 1.3522 main/ref(). $_scip-perl cpan Dancer 1.3522 main/$_. ? "(" . joinscip-perl cpan Dancer 1.3522 main/join().( ',', @$_scip-perl cpan Dancer 1.3522 main/$_. ) . ")": $_scip-perl cpan Dancer 1.3522 main/$_. } splat; |
| 33 | } |