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