blib/lib/Class/MOP/Class/Immutable/Trait.pm

filter: Statementstmt 88.7% 63 / 71 Branchbran 75.0% 3 / 4 Conditioncond 62.5% 10 / 16 MC/DCmcdc 33.3% 3 / 9 Subroutinesub 91.3% 21 / 23 Podpod n/a totaltotal 81.3% 100 / 123 CC 10 SCAR 6.9
CC
10
Cov
84%
:around
6.0
:around
6.0
:around
2.0
CRAP 2.0
« blib/lib/Moose/Meta/Method/Accessor/Native/Counter/Writer.pm ↑ Summary blib/lib/Moose/Util/TypeConstraints/Builtins.pm »
1 package Class::MOP::Class::Immutable::Trait;
2 459 our $VERSION = '2.4001';
3  
4 459 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 459 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 459 ▶use MRO::Compat;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 459 ▶use Module::Runtime 'use_module';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # the original class of the metaclass instance
11 11280 ▶sub _get_mutable_metaclass_name { $_[0]{__immutable}{original_class} }
Subroutine _get_mutable_metaclass_name: called CC=1 SCAR=0.0
12  
13 19 ▶sub is_mutable { 0 }
Subroutine :around: called CC=1 SCAR=0.0
14 11335 ▶sub is_immutable { 1 }
Subroutine :around: called CC=1 SCAR=0.0
15  
16 1 ▶sub _immutable_metaclass { ref $_[1] }
Subroutine :around: called CC=1 SCAR=0.0
17  
18 6 ▶sub _immutable_read_only {
Subroutine _immutable_read_only: called CC=1 SCAR=0.0
19 6 my $name = shift;
20 6 __throw_exception( CallingReadOnlyMethodOnAnImmutableInstance => method_name => $name );
21 }
22  
23 33 ▶sub _immutable_cannot_call {
Subroutine _immutable_cannot_call: called CC=1 SCAR=0.0
24 33 my $name = shift;
25 33 __throw_exception( CallingMethodOnAnImmutableInstance => method_name => $name );
26 }
27  
28 459 for my $name (qw/superclasses/) {
29 459 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
30 459 ▶ *{__PACKAGE__."::$name"} = sub {
Subroutine :around: called CC=2 SCAR=6.9
Subroutine __ANON__: called CC=2 SCAR=6.9
31 823 my $orig = shift;
32 823 my $self = shift;
33 823 ▶ _immutable_read_only($name) if @_;
Branch: 2 branches
BranchTrueFalseTotal
if @_ 6 817 823
if @_ 0 308 308
34 817 $self->$orig;
35 459 };
36 }
37  
38 459 for my $name (qw/add_method alias_method remove_method add_attribute remove_attribute remove_package_symbol add_package_symbol/) {
39 459 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
40 31 ▶ *{__PACKAGE__."::$name"} = sub { _immutable_cannot_call($name) };
Subroutine :around: called CC=1 SCAR=0.0
41 }
42  
43 2580 ▶sub class_precedence_list {
Subroutine :around: called CC=2 SCAR=6.9
44 2580 my $orig = shift;
45 2580 my $self = shift;
46 2580 @{ $self->{__immutable}{class_precedence_list}
47 2580 ▶ ||= [ $self->$orig ] };
Condition100%2/2
$self->{"__immutable"}{"class_precedence_list"} ||= [$self->$orig]
l!l
14611119
MC/DC100%1/1
$self->{"__immutable"}{"class_precedence_list"} ||= [$self->$orig]
$self->{"__immutable"}{"class_precedence_list"}
Truth table100%2/2
A
A= $self->{"__immutable"}{"class_precedence_list"}
Aresult
11
00
48 }
49  
50 28537 ▶sub linearized_isa {
Subroutine :around: called CC=2 SCAR=6.9
51 28537 my $orig = shift;
52 28537 my $self = shift;
53 28537 ▶ @{ $self->{__immutable}{linearized_isa} ||= [ $self->$orig ] };
Condition100%2/2
$self->{"__immutable"}{"linearized_isa"} ||= [$self->$orig]
l!l
222026335
MC/DC100%1/1
$self->{"__immutable"}{"linearized_isa"} ||= [$self->$orig]
$self->{"__immutable"}{"linearized_isa"}
Truth table100%2/2
A
A= $self->{"__immutable"}{"linearized_isa"}
Aresult
11
00
54 }
55  
56 0 ▶sub get_all_methods {
Subroutine :around: not called CC=2 SCAR=17.9
57 0 my $orig = shift;
58 0 my $self = shift;
59 0 ▶ @{ $self->{__immutable}{get_all_methods} ||= [ $self->$orig ] };
Condition0%0/2
$self->{"__immutable"}{"get_all_methods"} ||= [$self->$orig]
l!l
00
MC/DC0%0/1
$self->{"__immutable"}{"get_all_methods"} ||= [$self->$orig]
$self->{"__immutable"}{"get_all_methods"}
Truth table0%0/2
A
A= $self->{"__immutable"}{"get_all_methods"}
Aresult
11
00
60 }
61  
62 0 ▶sub get_all_method_names {
Subroutine :around: not called CC=2 SCAR=17.9
63 0 my $orig = shift;
64 0 my $self = shift;
65 0 ▶ @{ $self->{__immutable}{get_all_method_names} ||= [ $self->$orig ] };
Condition0%0/2
$self->{"__immutable"}{"get_all_method_names"} ||= [$self->$orig]
l!l
00
MC/DC0%0/1
$self->{"__immutable"}{"get_all_method_names"} ||= [$self->$orig]
$self->{"__immutable"}{"get_all_method_names"}
Truth table0%0/2
A
A= $self->{"__immutable"}{"get_all_method_names"}
Aresult
11
00
66 }
67  
68 19416 ▶sub get_all_attributes {
Subroutine :around: called CC=2 SCAR=6.9
69 19416 my $orig = shift;
70 19416 my $self = shift;
71 19416 ▶ @{ $self->{__immutable}{get_all_attributes} ||= [ $self->$orig ] };
Condition100%2/2
$self->{"__immutable"}{"get_all_attributes"} ||= [$self->$orig]
l!l
133706046
MC/DC100%1/1
$self->{"__immutable"}{"get_all_attributes"} ||= [$self->$orig]
$self->{"__immutable"}{"get_all_attributes"}
Truth table100%2/2
A
A= $self->{"__immutable"}{"get_all_attributes"}
Aresult
11
00
72 }
73  
74 120730 ▶sub get_meta_instance {
Subroutine :around: called CC=2 SCAR=7.0
75 120730 my $orig = shift;
76 120730 my $self = shift;
77 120730 ▶ $self->{__immutable}{get_meta_instance} ||= $self->$orig;
Condition66%2/3
$self->{"__immutable"}{"get_meta_instance"} ||= $self->$orig
l!l&&r!l&&!r
11209386370
MC/DC0%0/2
$self->{"__immutable"}{"get_meta_instance"} ||= $self->$orig
$self->{"__immutable"}{"get_meta_instance"} $self->$orig
Truth table66%2/3
A ||= B
A= $self->{"__immutable"}{"get_meta_instance"}B= $self->$orig
ABresult
1X1
011
000
78 }
79  
80 78792 ▶sub _method_map {
Subroutine :around: called CC=2 SCAR=7.0
81 78792 my $orig = shift;
82 78792 my $self = shift;
83 78792 ▶ $self->{__immutable}{_method_map} ||= $self->$orig;
Condition66%2/3
$self->{"__immutable"}{"_method_map"} ||= $self->$orig
l!l&&r!l&&!r
7116876240
MC/DC0%0/2
$self->{"__immutable"}{"_method_map"} ||= $self->$orig
$self->{"__immutable"}{"_method_map"} $self->$orig
Truth table66%2/3
A ||= B
A= $self->{"__immutable"}{"_method_map"}B= $self->$orig
ABresult
1X1
011
000
84 }
85  
86 # private method, for this file only -
87 # if we declare a method here, it will behave differently depending on what
88 # class this trait is applied to, so we won't have a reliable parameter list.
89 39 ▶sub __throw_exception {
Subroutine __throw_exception: called CC=1 SCAR=0.0
90 39 my ($exception_type, @args_to_exception) = @_;
91 39 die use_module( "Moose::Exception::$exception_type" )->new( @args_to_exception );
92 }
93  
94 459 1;
95  
96 # ABSTRACT: Implements immutability for metaclass objects
97  
98 __END__
« blib/lib/Moose/Meta/Method/Accessor/Native/Counter/Writer.pm ↑ Summary blib/lib/Moose/Util/TypeConstraints/Builtins.pm »