line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
592
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
48
|
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Data::Conveyor::Test; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
1
|
|
|
1
|
|
25
|
$Data::Conveyor::Test::VERSION = '1.103130'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: Stage-based conveyor-belt-like ticket handling system |
10
|
1
|
|
|
1
|
|
6
|
use Test::More; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
11
|
1
|
|
|
1
|
|
382
|
use Error::Hierarchy::Util 'load_class'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
12
|
1
|
|
|
1
|
|
5
|
use parent 'Class::Scaffold::Test'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# e.g., stage_basics_ok($self->delegate, ST_POLICY => 1); |
15
|
|
|
|
|
|
|
sub stage_basics_ok { |
16
|
1
|
|
|
1
|
1
|
4
|
my ($self, $stage_type_const, $will_shift_ticket, %stage_args) = @_; |
17
|
1
|
|
|
|
|
7
|
my $stage_type = $self->delegate->$stage_type_const; |
18
|
1
|
|
|
|
|
19
|
my $stage = $self->delegate->make_stage_object($stage_type, %stage_args); |
19
|
1
|
|
|
|
|
1312
|
is($stage->expected_stage, $stage_type, |
20
|
|
|
|
|
|
|
"expected stage type [$stage_type]"); |
21
|
1
|
|
|
|
|
675
|
is($stage->will_shift_ticket, $will_shift_ticket, |
22
|
|
|
|
|
|
|
"$stage_type ticket shift setting"); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub transition_ok { |
26
|
0
|
|
|
0
|
1
|
0
|
my ($self, $test_storage, $stage, $rc, $next_stage) = @_; |
27
|
0
|
|
|
|
|
0
|
$test_storage->transition_ok_bare( |
28
|
|
|
|
|
|
|
$test_storage, |
29
|
|
|
|
|
|
|
$test_storage->delegate->make_obj('value_ticket_stage') |
30
|
|
|
|
|
|
|
->new_end($stage), |
31
|
|
|
|
|
|
|
$rc, |
32
|
|
|
|
|
|
|
$test_storage->delegate->make_obj('value_ticket_stage') |
33
|
|
|
|
|
|
|
->new_start($next_stage), |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub transition_ok_bare { |
38
|
0
|
|
|
0
|
1
|
0
|
my ($self, $test_storage, $stage, $rc, $next_stage) = @_; |
39
|
0
|
|
|
|
|
0
|
is($test_storage->get_next_stage($stage, $rc), |
40
|
|
|
|
|
|
|
$next_stage, sprintf('%s + %s = %s', $stage, $rc, $next_stage)); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub factory_gen_template_handler_ok { |
44
|
0
|
|
|
0
|
1
|
0
|
my ($self, $factory, $gen_method, $hash_name) = @_; |
45
|
0
|
|
|
|
|
0
|
my %hash_spec = $factory->every_hash($hash_name); |
46
|
0
|
|
|
|
|
0
|
while (my ($ticket_type, $class) = each %hash_spec) { |
47
|
0
|
0
|
|
|
|
0
|
next if $ticket_type eq '_AUTO'; |
48
|
0
|
|
|
|
|
0
|
isa_ok( |
49
|
|
|
|
|
|
|
$factory->$gen_method( |
50
|
|
|
|
|
|
|
ticket => |
51
|
|
|
|
|
|
|
$factory->delegate->make_obj('ticket', type => $ticket_type), |
52
|
|
|
|
|
|
|
), |
53
|
|
|
|
|
|
|
$class |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub factory_gen_txsel_handler_iterate { |
59
|
0
|
|
|
0
|
1
|
0
|
my ($self, $factory, $gen_method, $spec, $value) = @_; |
60
|
0
|
0
|
|
|
|
0
|
if (ref $value eq 'HASH') { |
61
|
0
|
|
|
|
|
0
|
while (my ($deeper_spec, $deeper_value) = each %$value) { |
62
|
0
|
0
|
|
|
|
0
|
next if $deeper_spec eq '_AUTO'; |
63
|
0
|
|
|
|
|
0
|
$self->factory_gen_txsel_handler_iterate($factory, $gen_method, |
64
|
|
|
|
|
|
|
[ @$spec, $deeper_spec ], |
65
|
|
|
|
|
|
|
$deeper_value); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} else { |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# expect it to be a scalar, i.e. a leaf, so call the generator method |
70
|
0
|
|
|
|
|
0
|
isa_ok($factory->$gen_method(@$spec), $value); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub factory_gen_txsel_handler_ok { |
75
|
0
|
|
|
0
|
1
|
0
|
my ($self, $factory, $gen_method, $hash_name) = @_; |
76
|
0
|
|
|
|
|
0
|
my %hash_spec = $factory->every_hash($hash_name); |
77
|
0
|
|
|
|
|
0
|
$self->factory_gen_txsel_handler_iterate($factory, $gen_method, [], |
78
|
|
|
|
|
|
|
\%hash_spec); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub factory_gen_transaction_handler_ok { |
82
|
0
|
|
|
0
|
1
|
0
|
my ($self, $factory, $gen_method, $hash_name) = @_; |
83
|
0
|
|
|
|
|
0
|
my %hash_spec = $factory->every_hash($hash_name); |
84
|
0
|
|
|
|
|
0
|
while (my ($object_type, $ot_spec) = each %hash_spec) { |
85
|
0
|
0
|
|
|
|
0
|
next if $object_type eq '_AUTO'; |
86
|
0
|
|
|
|
|
0
|
while (my ($command, $class) = each %$ot_spec) { |
87
|
0
|
0
|
|
|
|
0
|
next if $command eq '_AUTO'; |
88
|
0
|
|
|
|
|
0
|
my $tx = $factory->delegate->make_obj( |
89
|
|
|
|
|
|
|
'transaction', |
90
|
|
|
|
|
|
|
object_type => $object_type, |
91
|
|
|
|
|
|
|
command => $command, |
92
|
|
|
|
|
|
|
); |
93
|
0
|
|
|
|
|
0
|
my $payload_tx = $factory->delegate->make_obj('payload_transaction', |
94
|
|
|
|
|
|
|
transaction => $tx); |
95
|
0
|
|
|
|
|
0
|
isa_ok($factory->$gen_method(tx => $payload_tx), $class); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub apply_rc_ok { |
101
|
16
|
|
|
16
|
1
|
39
|
my ($self, $from, $via, $to, $should_ask_delegate) = @_; |
102
|
16
|
50
|
|
|
|
93
|
if ($should_ask_delegate) { |
103
|
16
|
|
|
|
|
64
|
$_ = $self->delegate->$_ for $from, $via, $to; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
$_ = $self->delegate->make_obj('value_ticket_rc', value => $_) |
106
|
16
|
|
|
|
|
488
|
for $from, $via, $to; |
107
|
16
|
|
|
|
|
10607
|
is($from + $via, $to, sprintf("apply_rc: %s x %s = %s", $from, $via, $to)); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub apply_status_ok { |
111
|
14
|
|
|
14
|
1
|
37
|
my ($self, $from, $via, $to, $should_ask_delegate) = @_; |
112
|
14
|
50
|
|
|
|
33
|
if ($should_ask_delegate) { |
113
|
14
|
|
|
|
|
60
|
$_ = $self->delegate->$_ for $from, $via, $to; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
$_ = $self->delegate->make_obj('value_ticket_status', value => $_) |
116
|
14
|
|
|
|
|
395
|
for $from, $via, $to; |
117
|
14
|
|
|
|
|
4692
|
is($from + $via, |
118
|
|
|
|
|
|
|
$to, sprintf("apply_status: %s x %s = %s", $from, $via, $to)); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub object_limit_ok { |
122
|
0
|
|
|
0
|
1
|
|
my ($self, $ticket_type_const, $object_type_const, $expected) = @_; |
123
|
0
|
|
|
|
|
|
my $ticket_type = $self->delegate->$ticket_type_const; |
124
|
0
|
|
|
|
|
|
my $object_type = $self->delegate->$object_type_const; |
125
|
0
|
|
|
|
|
|
is( $self->delegate->get_object_limit($ticket_type, $object_type), |
126
|
|
|
|
|
|
|
$expected, sprintf '%s, %s -> %s', |
127
|
|
|
|
|
|
|
$ticket_type, $object_type, $expected |
128
|
|
|
|
|
|
|
); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub rc_for_exception_class_ok { |
132
|
0
|
|
|
0
|
1
|
|
my ($self, $handler, $exception_class, $payload_item_type, $command_name, |
133
|
|
|
|
|
|
|
$rc_name) |
134
|
|
|
|
|
|
|
= @_; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# The exception class needs to be loaded so class_map() can determine its |
137
|
|
|
|
|
|
|
# superclasses. |
138
|
0
|
|
|
|
|
|
load_class $exception_class, 0; |
139
|
0
|
|
|
|
|
|
my $payload_item = $self->delegate->make_obj($payload_item_type, |
140
|
|
|
|
|
|
|
command => $self->delegate->$command_name); |
141
|
0
|
|
|
|
|
|
my $rc = $handler->rc_for_exception_class($exception_class, $payload_item); |
142
|
0
|
|
|
|
|
|
is( $rc, |
143
|
|
|
|
|
|
|
$self->delegate->$rc_name, |
144
|
|
|
|
|
|
|
sprintf 'type [%s], command [%s]: exception [%s] => rc [%s]', |
145
|
|
|
|
|
|
|
$payload_item_type, |
146
|
|
|
|
|
|
|
$command_name, |
147
|
|
|
|
|
|
|
$exception_class, |
148
|
|
|
|
|
|
|
$rc_name |
149
|
|
|
|
|
|
|
); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
1; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
__END__ |