Commit | Line | Data |
cc57831f |
1 | use strictures 1; |
2 | use Test::More; |
3 | |
4 | { |
5 | package t::Web::Simple::MatchHome; |
6 | |
7 | use Web::Simple; |
8 | |
9 | sub as_text { |
10 | [200, ['Content-Type' => 'text/plain'], |
11 | [$_[0]->{REQUEST_METHOD}, $_[0]->{REQUEST_URI}] ] |
12 | } |
13 | |
14 | sub dispatch_request { |
15 | sub (/foo...) { |
16 | sub (~) { as_text(pop) }, |
17 | sub (/bar) { as_text(pop) }, |
18 | sub (/baz) { as_text(pop) }, |
19 | sub (/*) { as_text(pop) }, |
20 | sub (/bork...) { |
21 | sub (~) { as_text(pop) }, |
22 | sub (/bar) { as_text(pop) }, |
23 | } |
24 | }, |
25 | sub (/...) { |
26 | sub (/baz) { as_text(pop) }, |
27 | sub (/fob...) { |
28 | sub (~) { as_text(pop) }, |
29 | sub (/bar) { as_text(pop) }, |
30 | } |
31 | } |
32 | } |
33 | } |
34 | |
35 | ok my $app = t::Web::Simple::MatchHome->new, |
36 | 'made app'; |
37 | |
38 | for(ok my $res = $app->run_test_request(GET => '/foo')) { |
39 | is $res->content, 'GET/foo'; |
40 | } |
41 | |
42 | for(ok my $res = $app->run_test_request(GET => '/foo/bar')) { |
43 | is $res->content, 'GET/foo/bar'; |
44 | } |
45 | |
46 | for(ok my $res = $app->run_test_request(GET => '/foo/baz')) { |
47 | is $res->content, 'GET/foo/baz'; |
48 | } |
49 | |
50 | for(ok my $res = $app->run_test_request(GET => '/foo/id')) { |
51 | is $res->content, 'GET/foo/id'; |
52 | } |
53 | |
54 | |
55 | for(ok my $res = $app->run_test_request(GET => '/foo/bork')) { |
56 | is $res->content, 'GET/foo/bork'; |
57 | } |
58 | |
59 | for(ok my $res = $app->run_test_request(GET => '/foo/bork/bar')) { |
60 | is $res->content, 'GET/foo/bork/bar'; |
61 | } |
62 | |
63 | for(ok my $res = $app->run_test_request(GET => '/fob')) { |
64 | is $res->content, 'GET/fob'; |
65 | } |
66 | |
67 | for(ok my $res = $app->run_test_request(GET => '/baz')) { |
68 | is $res->content, 'GET/baz'; |
69 | } |
70 | |
71 | for(ok my $res = $app->run_test_request(GET => '/fob/bar')) { |
72 | is $res->content, 'GET/fob/bar'; |
73 | } |
74 | |
75 | done_testing; |