blib/lib/Langertha/Holmgang/Simulators.pm

filter: Statementstmt 54.3% 107 / 197 Branchbran 39.8% 43 / 108 Conditioncond 29.8% 40 / 134 MC/DCmcdc 16.6% 12 / 72 Subroutinesub 59.0% 26 / 44 Podpod 91.6% 22 / 24 totaltotal 43.1% 250 / 579 CC 111 SCAR 25.8
CC
111
Cov
43%
simulator
34.7
simulator
34.7
register
21.5
CRAP 13.2
« blib/lib/Langertha/Holmgang/Sim/Sehen.pm ↑ Summary blib/lib/Langertha/Holmgang/Loader.pm »
1 package Langertha::Holmgang::Simulators;
2 # ABSTRACT: Registry of simulators by device type, and dispatch of calls to them
3  
4 96 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 96 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 96 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 96 ▶use Module::Runtime qw( module_notional_filename use_module );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 96 ▶use Moose::Util qw( find_meta );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 96 our $VERSION = '0.002';
11  
12  
13 96 my %BUILTIN = (
14 linux => 'Langertha::Holmgang::Sim::Linux',
15 routeros => 'Langertha::Holmgang::Sim::RouterOS',
16 ios => 'Langertha::Holmgang::Sim::IOS',
17 kueche => 'Langertha::Holmgang::Sim::Kueche',
18 sehen => 'Langertha::Holmgang::Sim::Sehen',
19 schichtfehler => 'Langertha::Holmgang::Sim::Schichtfehler',
20 uebersetzung => 'Langertha::Holmgang::Sim::Uebersetzung',
21 denken => 'Langertha::Holmgang::Sim::Denken',
22 roost => 'Langertha::Holmgang::Sim::Roost',
23 );
24  
25 has _classes => (
26 is => 'ro',
27 init_arg => undef,
28 428 ▶ default => sub { +{ %BUILTIN } },
Subroutine __ANON__: called CC=1 SCAR=0.0
29 96 );
30  
31 has _instances => (
32 is => 'ro',
33 init_arg => undef,
34 428 ▶ default => sub { {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
35 96 );
36  
37 has register_classes => (
38 is => 'ro',
39 426 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
40 96 );
41  
42  
43 96 has sandbox => ( is => 'rw', predicate => 'has_sandbox', clearer => 'clear_sandbox' );
44  
45  
46 2457 ▶sub _ctx {
Subroutine _ctx: called CC=3 SCAR=15.4
47 0 ▶ my ( $self, $host, $state ) = @_;
Subroutine _ctx: not called CC=3 SCAR=15.4
48 0 ▶ return { host => $host, state => $state, ( $self->has_sandbox && $self->sandbox ? ( sandbox => $self->sandbox ) : () ) };
Branch: 2 branches
BranchTrueFalseTotal
$self->has_sandbox && $self->sandbox ? : 22 2435 2457
$self->has_sandbox && $self->sandbox ? : 0 0 0
Condition33%2/6
$self->has_sandbox and $self->sandbox
!ll&&!rl&&r
2435022
$self->has_sandbox and $self->sandbox
!ll&&!rl&&r
000
MC/DC50%1/2
$self->has_sandbox and $self->sandbox
$self->has_sandbox $self->sandbox
MC/DC0%0/2
$self->has_sandbox and $self->sandbox
$self->has_sandbox $self->sandbox
Truth table66%2/3
A and B
A= $self->has_sandboxB= $self->sandbox
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $self->has_sandboxB= $self->sandbox
ABresult
0X0
100
111
49 }
50  
51 428 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=9.2
Pod undocumented
52 0 ▶ my ( $self ) = @_;
Subroutine BUILD: not called CC=2 SCAR=9.2
Pod undocumented
53 0 $self->register($_) for @{ $self->register_classes };
54 }
55  
56 8 ▶sub register {
Subroutine register: called CC=7 SCAR=30.7
Pod documented
57 0 ▶ my ( $self, $class ) = @_;
Subroutine register: not called CC=7 SCAR=30.7
Pod documented
58 0 ▶ croak __PACKAGE__.'->register needs a class name' unless defined $class && length $class && !ref $class;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $class and length $class and not ref $class 0 8 8
unless defined $class and length $class and not ref $class 0 0 0
Condition16%2/12
defined $class and length $class and not ref $class
!ll&&!rl&&r
008
defined $class and length $class
!ll&&!rl&&r
008
defined $class and length $class and not ref $class
!ll&&!rl&&r
000
defined $class and length $class
!ll&&!rl&&r
000
MC/DC0%0/3
defined $class and length $class and not ref $class
defined $class length $class not ref $class
MC/DC0%0/3
defined $class and length $class and not ref $class
defined $class length $class not ref $class
Truth table25%1/4
A and B and not(C)
A= defined $classB= length $classC= not ref $class
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B and not(C)
A= defined $classB= length $classC= not ref $class
ABCresult
0XX0
10X0
1100
1111
59 0 $self->_load($class);
60 0 ▶ croak __PACKAGE__.'->register: '.$class.' composes neither Langertha::Holmgang::Role::Simulator nor Langertha::Holmgang::Role::AnswerWorld'
Branch: 2 branches
BranchTrueFalseTotal
unless $self->_is_simulator($class) 1 6 7
unless $self->_is_simulator($class) 0 0 0
61 unless $self->_is_simulator($class);
62 0 my $type = $class->device_type;
63 0 ▶ croak __PACKAGE__.'->register: '.$class.' has no device_type' unless defined $type && length $type;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $type and length $type 0 6 6
unless defined $type and length $type 0 0 0
Condition16%1/6
defined $type and length $type
!ll&&!rl&&r
006
defined $type and length $type
!ll&&!rl&&r
000
MC/DC0%0/2
defined $type and length $type
defined $type length $type
MC/DC0%0/2
defined $type and length $type
defined $type length $type
Truth table33%1/3
A and B
A= defined $typeB= length $type
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $typeB= length $type
ABresult
0X0
100
111
64 0 $self->_classes->{$type} = $class;
65 0 delete $self->_instances->{$type};
66 0 return $self;
67 }
68  
69  
70 # a class defined in a file already loaded (or inline, in a test) needs no require
71 783 ▶sub _load {
Subroutine _load: called CC=2 SCAR=9.2
72 0 ▶ my ( $self, $class ) = @_;
Subroutine _load: not called CC=2 SCAR=9.2
73 0 ▶ return if find_meta($class);
Branch: 2 branches
BranchTrueFalseTotal
if find_meta($class) 433 350 783
if find_meta($class) 0 0 0
74 0 use_module($class);
75 0 return;
76 }
77  
78 782 ▶sub _is_simulator {
Subroutine _is_simulator: called CC=3 SCAR=15.3
79 0 ▶ my ( $self, $class ) = @_;
Subroutine _is_simulator: not called CC=3 SCAR=15.3
80 0 ▶ return $class->can('does')
Condition41%5/12
$class->can('does') && ($class->does('Langertha::Holmgang::Role::Simulator') || $class->does('Langertha::Holmgang::Role::AnswerWorld'))
!ll&&!rl&&r
01781
$class->does("Langertha::Holmgang::Role::Simulator") or $class->does("Langertha::Holmgang::Role::AnswerWorld")
l!l&&r!l&&!r
3274541
$class->can('does') && ($class->does('Langertha::Holmgang::Role::Simulator') || $class->does('Langertha::Holmgang::Role::AnswerWorld'))
!ll&&!rl&&r
000
$class->does("Langertha::Holmgang::Role::Simulator") or $class->does("Langertha::Holmgang::Role::AnswerWorld")
l!l&&r!l&&!r
000
MC/DC66%2/3
$class->can('does') && ($class->does('Langertha::Holmgang::Role::Simulator') || $class->does('Langertha::Holmgang::Role::AnswerWorld'))
$class->can('does') $class->does("Langertha::Holmgang::Role::Simulator") $class->does("Langertha::Holmgang::Role::AnswerWorld")
MC/DC0%0/3
$class->can('does') && ($class->does('Langertha::Holmgang::Role::Simulator') || $class->does('Langertha::Holmgang::Role::AnswerWorld'))
$class->can('does') $class->does("Langertha::Holmgang::Role::Simulator") $class->does("Langertha::Holmgang::Role::AnswerWorld")
Truth table75%3/4
A && B or C
A= $class->can('does')B= $class->does("Langertha::Holmgang::Role::Simulator")C= $class->does("Langertha::Holmgang::Role::AnswerWorld")
ABCresult
0XX0
1000
11X1
1011
Truth table0%0/4
A && B or C
A= $class->can('does')B= $class->does("Langertha::Holmgang::Role::Simulator")C= $class->does("Langertha::Holmgang::Role::AnswerWorld")
ABCresult
0XX0
1000
11X1
1011
81 && ( $class->does('Langertha::Holmgang::Role::Simulator') || $class->does('Langertha::Holmgang::Role::AnswerWorld') );
82 }
83  
84 395 ▶sub types {
Subroutine types: called CC=1 SCAR=1.2
Pod documented
85 0 ▶ my ( $self ) = @_;
Subroutine types: not called CC=1 SCAR=1.2
Pod documented
86 0 return sort grep { $self->simulator($_) } keys %{ $self->_classes };
87 }
88  
89  
90 6921 ▶sub simulator {
Subroutine simulator: called CC=9 SCAR=35.5
Pod documented
91 0 ▶ my ( $self, $type ) = @_;
Subroutine simulator: not called CC=9 SCAR=35.5
Pod documented
92 0 ▶ return unless defined $type && !ref $type;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $type and not ref $type 0 6921 6921
unless defined $type and not ref $type 0 0 0
Condition16%1/6
defined $type and not ref $type
!ll&&!rl&&r
006921
defined $type and not ref $type
!ll&&!rl&&r
000
MC/DC0%0/2
defined $type and not ref $type
defined $type not ref $type
MC/DC0%0/2
defined $type and not ref $type
defined $type not ref $type
Truth table33%1/3
A and not(B)
A= defined $typeB= not ref $type
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= defined $typeB= not ref $type
ABresult
0X0
100
111
93 0 my $inst = $self->_instances;
94 0 ▶ return $inst->{$type} if exists $inst->{$type};
Branch: 2 branches
BranchTrueFalseTotal
if exists $inst->{$type} 6141 780 6921
if exists $inst->{$type} 0 0 0
95 0 ▶ my $class = $self->_classes->{$type} or return;
Branch: 2 branches
BranchTrueFalseTotal
my $class = $self->_classes->{$type} or return 775 5 780
my $class = $self->_classes->{$type} or return 0 0 0
96 0 my $ok = eval { $self->_load($class); 1 };
97 0 ▶ unless ( $ok ) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($ok) 0 775 775
unless ($ok) 0 0 0
98 0 my $err = $@;
99 0 my $file = module_notional_filename($class);
100 0 ▶ return $inst->{$type} = undef if $err =~ /\ACan't locate \Q$file\E in \@INC/;
Branch: 2 branches
BranchTrueFalseTotal
if $err =~ /\ACan't locate \Q$file\E in \@INC/ 0 0 0
if $err =~ /\ACan't locate \Q$file\E in \@INC/ 0 0 0
101 0 croak __PACKAGE__.': simulator '.$class.' for type '.$type.' does not load: '.$err;
102 }
103 0 ▶ croak __PACKAGE__.': '.$class.' (type '.$type.') composes no simulator role' unless $self->_is_simulator($class);
Branch: 2 branches
BranchTrueFalseTotal
unless $self->_is_simulator($class) 0 775 775
unless $self->_is_simulator($class) 0 0 0
104 0 ▶ croak __PACKAGE__.': '.$class.' says device_type '.$class->device_type.', registered as '.$type
Branch: 2 branches
BranchTrueFalseTotal
unless $class->device_type eq $type 0 775 775
unless $class->device_type eq $type 0 0 0
105 unless $class->device_type eq $type;
106 0 return $inst->{$type} = $class->new;
107 }
108  
109  
110 378 ▶sub is_answer_world {
Subroutine is_answer_world: called CC=3 SCAR=14.2
Pod documented
111 0 ▶ my ( $self, $type ) = @_;
Subroutine is_answer_world: not called CC=3 SCAR=14.2
Pod documented
112 0 ▶ my $sim = $self->simulator($type) or return 0;
Branch: 2 branches
BranchTrueFalseTotal
my $sim = $self->simulator($type) or return 0 377 1 378
my $sim = $self->simulator($type) or return 0 0 0 0
113 0 ▶ return $sim->does('Langertha::Holmgang::Role::AnswerWorld') ? 1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
$sim->does('Langertha::Holmgang::Role::AnswerWorld') ? : 372 5 377
$sim->does('Langertha::Holmgang::Role::AnswerWorld') ? : 0 0 0
114 }
115  
116  
117 2467 ▶sub _device {
Subroutine _device: called CC=5 SCAR=25.5
118 0 ▶ my ( $self, $state, $host ) = @_;
Subroutine _device: not called CC=5 SCAR=25.5
119 0 ▶ return unless defined $host && !ref $host && ref $state eq 'HASH' && ref $state->{$host} eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH" 5 2462 2467
unless defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH" 0 0 0
Condition22%4/18
defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH"
!ll&&!rl&&r
052462
defined $host and not ref $host and ref $state eq "HASH"
!ll&&!rl&&r
002467
defined $host and not ref $host
!ll&&!rl&&r
002467
defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH"
!ll&&!rl&&r
000
defined $host and not ref $host and ref $state eq "HASH"
!ll&&!rl&&r
000
defined $host and not ref $host
!ll&&!rl&&r
000
MC/DC25%1/4
defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH"
defined $host not ref $host ref $state eq "HASH" ref $state->{$host} eq "HASH"
MC/DC0%0/4
defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH"
defined $host not ref $host ref $state eq "HASH" ref $state->{$host} eq "HASH"
Truth table40%2/5
A and not(B) and C and D
A= defined $hostB= not ref $hostC= ref $state eq "HASH"D= ref $state->{$host} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
Truth table0%0/5
A and not(B) and C and D
A= defined $hostB= not ref $hostC= ref $state eq "HASH"D= ref $state->{$host} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
120 0 return $state->{$host};
121 }
122  
123 5 ▶sub _unresolved {
Subroutine _unresolved: called CC=2 SCAR=10.9
124 0 ▶ my ( $self, $host ) = @_;
Subroutine _unresolved: not called CC=2 SCAR=10.9
125 0 ▶ return ( 'ssh: Could not resolve hostname '.( $host // '' ).': Name or service not known', 0 );
Condition25%1/4
$host // ""
l!l
50
$host // ""
l!l
00
MC/DC0%0/1
$host // ""
$host
MC/DC0%0/1
$host // ""
$host
Truth table50%1/2
A
A= $host
Aresult
11
00
Truth table0%0/2
A
A= $host
Aresult
11
00
126 }
127  
128 413 ▶sub prepare {
Subroutine prepare: called CC=7 SCAR=26.5
Pod documented
129 0 ▶ my ( $self, $state ) = @_;
Subroutine prepare: not called CC=7 SCAR=26.5
Pod documented
130 0 ▶ for my $k ( sort keys %{ $state || {} } ) {
Condition25%1/4
$state || {}
l!l
4130
$state || {}
l!l
00
MC/DC0%0/1
$state || {}
$state
MC/DC0%0/1
$state || {}
$state
Truth table50%1/2
A
A= $state
Aresult
11
00
Truth table0%0/2
A
A= $state
Aresult
11
00
131 0 my $dev = $state->{$k};
132 0 ▶ next unless ref $dev eq 'HASH' && defined $dev->{type};
Branch: 2 branches
BranchTrueFalseTotal
unless ref $dev eq "HASH" and defined $dev->{"type"} 358 106 464
unless ref $dev eq "HASH" and defined $dev->{"type"} 0 0 0
Condition50%3/6
ref $dev eq "HASH" and defined $dev->{"type"}
!ll&&!rl&&r
111247106
ref $dev eq "HASH" and defined $dev->{"type"}
!ll&&!rl&&r
000
MC/DC100%2/2
ref $dev eq "HASH" and defined $dev->{"type"}
ref $dev eq "HASH" defined $dev->{"type"}
MC/DC0%0/2
ref $dev eq "HASH" and defined $dev->{"type"}
ref $dev eq "HASH" defined $dev->{"type"}
Truth table100%3/3
A and B
A= ref $dev eq "HASH"B= defined $dev->{"type"}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $dev eq "HASH"B= defined $dev->{"type"}
ABresult
0X0
100
111
133 0 ▶ my $sim = $self->simulator( $dev->{type} ) or next;
Branch: 2 branches
BranchTrueFalseTotal
my $sim = $self->simulator($dev->{"type"}) or next 105 1 106
my $sim = $self->simulator($dev->{"type"}) or next 0 0 0
134 0 ▶ $sim->prepare( $dev, { host => $k, state => $state } ) if $sim->can('prepare');
Branch: 2 branches
BranchTrueFalseTotal
if $sim->can("prepare") 73 32 105
if $sim->can("prepare") 0 0 0
135 }
136 0 return;
137 }
138  
139  
140 2313 ▶sub run_command {
Subroutine run_command: called CC=5 SCAR=21.8
Pod documented
141 0 ▶ my ( $self, $state, $host, $command ) = @_;
Subroutine run_command: not called CC=5 SCAR=21.8
Pod documented
142 0 ▶ my $dev = $self->_device( $state, $host ) or return $self->_unresolved($host);
Branch: 2 branches
BranchTrueFalseTotal
my $dev = $self->_device($state, $host) or return $self->_unresolved($host) 2308 5 2313
my $dev = $self->_device($state, $host) or return $self->_unresolved($host) 0 0 0
143 0 my $sim = $self->simulator( $dev->{type} );
144 0 ▶ return ( 'ssh: connect to host '.$host.' port 22: Connection refused', 0 )
Branch: 2 branches
BranchTrueFalseTotal
unless $sim and $sim->can("run_command") 2 2306 2308
unless $sim and $sim->can("run_command") 0 0 0
Condition50%3/6
$sim and $sim->can("run_command")
!ll&&!rl&&r
112306
$sim and $sim->can("run_command")
!ll&&!rl&&r
000
MC/DC100%2/2
$sim and $sim->can("run_command")
$sim $sim->can("run_command")
MC/DC0%0/2
$sim and $sim->can("run_command")
$sim $sim->can("run_command")
Truth table100%3/3
A and B
A= $simB= $sim->can("run_command")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $simB= $sim->can("run_command")
ABresult
0X0
100
111
145 unless $sim && $sim->can('run_command');
146 0 ▶ return $sim->run_command( $dev, $command // '', $self->_ctx( $host, $state ) );
Condition25%1/4
$command // ""
l!l
23060
$command // ""
l!l
00
MC/DC0%0/1
$command // ""
$command
MC/DC0%0/1
$command // ""
$command
Truth table50%1/2
A
A= $command
Aresult
11
00
Truth table0%0/2
A
A= $command
Aresult
11
00
147 }
148  
149  
150 154 ▶sub write_file {
Subroutine write_file: called CC=6 SCAR=26.9
Pod documented
151 0 ▶ my ( $self, $state, $host, $path, $content ) = @_;
Subroutine write_file: not called CC=6 SCAR=26.9
Pod documented
152 0 ▶ my $dev = $self->_device( $state, $host ) or return $self->_unresolved($host);
Branch: 2 branches
BranchTrueFalseTotal
my $dev = $self->_device($state, $host) or return $self->_unresolved($host) 154 0 154
my $dev = $self->_device($state, $host) or return $self->_unresolved($host) 0 0 0
153 0 my $sim = $self->simulator( $dev->{type} );
154 0 ▶ return ( 'scp: '.$host.': Datei schreiben auf diesem Gerät nicht möglich (nur Konsole über run_command)', 0 )
Branch: 2 branches
BranchTrueFalseTotal
unless $sim and $sim->can("write_file") 3 151 154
unless $sim and $sim->can("write_file") 0 0 0
Condition33%2/6
$sim and $sim->can("write_file")
!ll&&!rl&&r
03151
$sim and $sim->can("write_file")
!ll&&!rl&&r
000
MC/DC50%1/2
$sim and $sim->can("write_file")
$sim $sim->can("write_file")
MC/DC0%0/2
$sim and $sim->can("write_file")
$sim $sim->can("write_file")
Truth table66%2/3
A and B
A= $simB= $sim->can("write_file")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $simB= $sim->can("write_file")
ABresult
0X0
100
111
155 unless $sim && $sim->can('write_file');
156 0 ▶ return $sim->write_file( $dev, $path // '', $content // '', $self->_ctx( $host, $state ) );
Condition25%2/8
$path // ""
l!l
1510
$content // ""
l!l
1510
$path // ""
l!l
00
$content // ""
l!l
00
MC/DC0%0/1
$path // ""
$path
MC/DC0%0/1
$content // ""
$content
MC/DC0%0/1
$path // ""
$path
MC/DC0%0/1
$content // ""
$content
Truth table50%1/2
A
A= $path
Aresult
11
00
Truth table50%1/2
A
A= $content
Aresult
11
00
Truth table0%0/2
A
A= $path
Aresult
11
00
Truth table0%0/2
A
A= $content
Aresult
11
00
157 }
158  
159  
160 58 ▶sub world_tools {
Subroutine world_tools: called CC=2 SCAR=9.2
Pod documented
161 0 ▶ my ( $self, $type ) = @_;
Subroutine world_tools: not called CC=2 SCAR=9.2
Pod documented
162 0 ▶ return unless $self->is_answer_world($type);
Branch: 2 branches
BranchTrueFalseTotal
unless $self->is_answer_world($type) 6 52 58
unless $self->is_answer_world($type) 0 0 0
163 0 return $self->simulator($type)->tools;
164 }
165  
166  
167 316 ▶sub tool_call {
Subroutine tool_call: called CC=7 SCAR=29.4
Pod documented
168 0 ▶ my ( $self, $state, $type, $name, $args ) = @_;
Subroutine tool_call: not called CC=7 SCAR=29.4
Pod documented
169 0 ▶ my ($key) = grep { ref $state->{$_} eq 'HASH' && ( $state->{$_}{type} // '' ) eq $type } sort keys %{ $state || {} };
Condition28%4/14
ref $state->{$_} eq 'HASH' && ($state->{$_}{'type'} // '') eq $type
!ll&&!rl&&r
08314
$state->{$_}{"type"} // ""
l!l
3220
$state || {}
l!l
3160
ref $state->{$_} eq 'HASH' && ($state->{$_}{'type'} // '') eq $type
!ll&&!rl&&r
000
$state->{$_}{"type"} // ""
l!l
00
$state || {}
l!l
00
MC/DC0%0/2
ref $state->{$_} eq 'HASH' && ($state->{$_}{'type'} // '') eq $type
ref $state->{$_} eq 'HASH' $state->{$_}{"type"}
MC/DC0%0/1
$state || {}
$state
MC/DC0%0/2
ref $state->{$_} eq 'HASH' && ($state->{$_}{'type'} // '') eq $type
ref $state->{$_} eq 'HASH' $state->{$_}{"type"}
MC/DC0%0/1
$state || {}
$state
Truth table33%1/3
A && B
A= ref $state->{$_} eq 'HASH'B= $state->{$_}{"type"}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $state
Aresult
11
00
Truth table0%0/3
A && B
A= ref $state->{$_} eq 'HASH'B= $state->{$_}{"type"}
ABresult
0X0
100
111
Truth table0%0/2
A
A= $state
Aresult
11
00
170 0 ▶ return ( 'Fehler: diese Umgebung hat keine '.$type.'.', 0 ) unless defined $key;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $key 2 314 316
unless defined $key 0 0 0
171 0 ▶ return ( 'Fehler: unbekannte Welt '.$type.'.', 0 ) unless $self->is_answer_world($type);
Branch: 2 branches
BranchTrueFalseTotal
unless $self->is_answer_world($type) 0 314 314
unless $self->is_answer_world($type) 0 0 0
172 0 ▶ return $self->simulator($type)->tool( $state->{$key}, $name, $args || {}, { host => $key, state => $state } );
Condition25%1/4
$args || {}
l!l
3140
$args || {}
l!l
00
MC/DC0%0/1
$args || {}
$args
MC/DC0%0/1
$args || {}
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
Truth table0%0/2
A
A= $args
Aresult
11
00
173 }
174  
175  
176 34 ▶sub _for_rule {
Subroutine _for_rule: called CC=5 SCAR=21.7
177 0 ▶ my ( $self, $dev, $method, $kind ) = @_;
Subroutine _for_rule: not called CC=5 SCAR=21.7
178 0 ▶ croak __PACKAGE__.': a '.$kind.' rule needs a device' unless ref $dev eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $dev eq "HASH" 0 34 34
unless ref $dev eq "HASH" 0 0 0
179 0 ▶ my $type = $dev->{type} // '';
Condition50%2/4
$dev->{"type"} // ""
l!l
331
$dev->{"type"} // ""
l!l
00
MC/DC100%1/1
$dev->{"type"} // ""
$dev->{"type"}
MC/DC0%0/1
$dev->{"type"} // ""
$dev->{"type"}
Truth table100%2/2
A
A= $dev->{"type"}
Aresult
11
00
Truth table0%0/2
A
A= $dev->{"type"}
Aresult
11
00
180 0 my $sim = $self->simulator($type);
181 0 ▶ croak __PACKAGE__.': device type '.$type.' cannot answer a '.$kind.' rule (no '.$method.')'
Branch: 2 branches
BranchTrueFalseTotal
unless $sim and $sim->can($method) 3 31 34
unless $sim and $sim->can($method) 0 0 0
Condition50%3/6
$sim and $sim->can($method)
!ll&&!rl&&r
1231
$sim and $sim->can($method)
!ll&&!rl&&r
000
MC/DC100%2/2
$sim and $sim->can($method)
$sim $sim->can($method)
MC/DC0%0/2
$sim and $sim->can($method)
$sim $sim->can($method)
Truth table100%3/3
A and B
A= $simB= $sim->can($method)
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $simB= $sim->can($method)
ABresult
0X0
100
111
182 unless $sim && $sim->can($method);
183 0 return $sim;
184 }
185  
186 25 ▶sub packet_verdict {
Subroutine packet_verdict: called CC=2 SCAR=10.9
Pod documented
187 0 ▶ my ( $self, $dev, $packet, $boot ) = @_;
Subroutine packet_verdict: not called CC=2 SCAR=10.9
Pod documented
188 0 ▶ return $self->_for_rule( $dev, 'packet_verdict', 'packet' )->packet_verdict( $dev, $packet || {}, $boot );
Condition25%1/4
$packet || {}
l!l
240
$packet || {}
l!l
00
MC/DC0%0/1
$packet || {}
$packet
MC/DC0%0/1
$packet || {}
$packet
Truth table50%1/2
A
A= $packet
Aresult
11
00
Truth table0%0/2
A
A= $packet
Aresult
11
00
189 }
190  
191  
192 9 ▶sub login_check {
Subroutine login_check: called CC=2 SCAR=10.9
Pod documented
193 0 ▶ my ( $self, $dev, $attempt, $host ) = @_;
Subroutine login_check: not called CC=2 SCAR=10.9
Pod documented
194 0 ▶ return $self->_for_rule( $dev, 'login_check', 'login' )->login_check( $dev, $attempt || {}, $host );
Condition25%1/4
$attempt || {}
l!l
70
$attempt || {}
l!l
00
MC/DC0%0/1
$attempt || {}
$attempt
MC/DC0%0/1
$attempt || {}
$attempt
Truth table50%1/2
A
A= $attempt
Aresult
11
00
Truth table0%0/2
A
A= $attempt
Aresult
11
00
195 }
196  
197  
198 96 __PACKAGE__->meta->make_immutable;
199  
200 __END__
« blib/lib/Langertha/Holmgang/Sim/Sehen.pm ↑ Summary blib/lib/Langertha/Holmgang/Loader.pm »