File: 010-return.t

package info (click to toggle)
libpath-dispatcher-perl 1.08-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 512 kB
  • sloc: perl: 1,046; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 716 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings;
use Test::More;
use Path::Dispatcher;

# we currently have no defined return strategy :/

my $dispatcher = Path::Dispatcher->new;
$dispatcher->add_rule(
    Path::Dispatcher::Rule::Regex->new(
        regex => qr/foo/,
        block => sub { "foo" },
    ),
);

is_deeply([$dispatcher->run('foo', 42)], ["foo"]);

my $dispatch = $dispatcher->dispatch('foo');
is_deeply([$dispatch->run(24)], ["foo"]);

$dispatcher->add_rule(
    Path::Dispatcher::Rule::Regex->new(
        regex => qr/foo/,
        block => sub { "jinkies" },
    ),
);

is_deeply([$dispatcher->run('foo', 42)], ["foo"]);

$dispatch = $dispatcher->dispatch('foo');
is_deeply([$dispatch->run(24)], ["foo"]);

done_testing;