Debian Codegraph @

t/disp_named_capture.t

raw
1 use warnings;
2 use strict;
3
4 use Plack::Test;
5 use HTTP::Request;
6 use Test::More tests => 2;
7
8 {
9 package app;
10 use Dancer2;
11 get '/1' => sub {
12 return '1';
13 };
14 get '/2' => sub {
15 return '2';
16 };
17 }
18
19 my $test = Plack::Test->create( app->to_app );
20 my $request = HTTP::Request->new( GET => 'http://localhost/1' );
21 my $response = $test->request( $request );
22 is( $response->content, 1 );
23
24 # "Dummy" regex to populate global $+
25 "12345" =~ m#(?<capture>23)#;
26 my $c = $+{capture};
27
28 $request = HTTP::Request->new( GET => 'http://localhost/2' );
29 $response = $test->request( $request );
30 is( $response->content, 2 );
31