Pcuke/World.pm

filter: Statementstmt 100% 27 / 27 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 97.7% 44 / 45 CC 5 SCAR 8.2
CC
5
Cov
97%
AUTOLOAD
4.0
set
2.0
BEGIN
1.0
CRAP 2.3
« Pcuke/Executor.pm ↑ Summary Pcuke/StepDefinition.pm »
1 package Test::Pcuke::World;
2  
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 our $AUTOLOAD;
9  
10 =head1 NAME
11  
12 Test::Pcuke::World - World object for pcuke steps
13  
14 =head1 SYNOPSIS
15  
16 Quick summary of what the module does.
17  
18 use Test::Pcuke::World;
19 ...
20  
21 =head1 METHODS
22  
23 =head2 new
24  
25 =cut
26  
27 6 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
28 6 my ($class) = @_;
29 6 my $self = {
30 public => {},
31 private => {},
32 };
33
34 6 bless $self, $class;
35
36 6 $self->{private}->{ok} = 1;
37
38 6 return $self;
39 }
40  
41  
42 =head2 set $name, $value
43  
44 Sets an instance variable named $name to $value
45  
46 =cut
47  
48 2 ▶sub set {
Subroutine set: called CC=2 SCAR=6.9
Pod documented
49 2 my ($self, $name, $value) = @_;
50 croak "$name is reserved in the world"
51 2 ▶ if grep { $name eq $_ } qw{set new get ok assert};
Branch: 1 branch
BranchTrueFalseTotal
if grep {$name eq $_;} "set", "new", "get", "ok", "assert" 1 1 2
52 1 $self->{public}->{$name} = $value;
53 }
54  
55 =head2 get $name
56  
57 Returns a value of the instance variable named $name
58  
59 =cut
60  
61 2 ▶sub get { $_[0]->{public}->{$_[1]} }
Subroutine get: called CC=1 SCAR=0.0
Pod documented
62  
63 8 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=4 SCAR=13.9
64 8 ▶ return if $AUTOLOAD =~ /::DESTROY$/;
Branch: 1 branch
BranchTrueFalseTotal
if $Test::Pcuke::World::AUTOLOAD =~ /::DESTROY$/ 6 2 8
65
66 2 my $self = shift;
67
68 2 ▶ if ( $AUTOLOAD =~ /::([^:]+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Test::Pcuke::World::AUTOLOAD =~ /::([^:]+)$/) 2 0 2
69 2 ▶ if ( defined $self->{public}->{$1} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'public'}{$1}) { } 1 1 2
70 1 return $self->get($1);
71 }
72 else {
73 1 croak "$1: method is not defined in the world";
74 }
75 }
76 }
77  
78 =head2 ok
79  
80 Returns true if everything is ok
81  
82 =cut
83  
84 5 1; # End of Test::Pcuke::World
85 __END__
« Pcuke/Executor.pm ↑ Summary Pcuke/StepDefinition.pm »