add minimum perl
[catagits/CatalystX-Declare.git] / t / 023_runtime_dynamics.t
CommitLineData
1754e3e7 1#!/usr/bin/env perl
2use strict;
3use warnings;
4
5use FindBin;
6use lib "$FindBin::Bin/lib";
7
8use Test::More;
9use Catalyst::Test 'TestApp';
10
11is get('/df_foo/msg'), 'foo', 'dynamic final with active final';
12is get('/df_bar/msg/wrapped'), 'wrapped[bar]', 'dynamic final with non-final and attached actions';
13
14my $make_counter = sub {
15 my ($ctrl, $counter) = @_;
16 return sub { scalar get(sprintf '/df_%s/counter/%s', $ctrl, $counter) };
17};
18
19my $foo_x = $make_counter->(qw( foo x ));
20my $foo_y = $make_counter->(qw( foo y ));
21my $bar_y = $make_counter->(qw( bar y ));
22my $bar_z = $make_counter->(qw( bar z ));
23
24for (0 .. 3) {
25 is $foo_x->(), $_, "foo closure state test x $_";
26 is $foo_y->(), $_, "foo closure state test y $_";
27}
28
29for (0 .. 3) {
30 is $bar_y->(), $_, "bar closure state test y $_";
31 is $bar_z->(), $_, "bar closure state test z $_";
32}
33
34for (4 .. 6) {
35 is $foo_x->(), $_, "foo closure state test x $_";
36 is $bar_y->(), $_, "bar closure state test y $_";
37}
38
39for (4 .. 6) {
40 is $foo_y->(), $_, "foo closure state test y $_";
41 is $bar_z->(), $_, "bar closure state test z $_";
42}
43
44done_testing;
45