blib/lib/Test/Moose.pm

filter: Statementstmt 100% 48 / 48 Branchbran 100% 6 / 6 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 11 / 11 Podpod 100% 4 / 4 totaltotal 94.8% 74 / 78 CC 8 SCAR 7.5
CC
8
Cov
97%
meta_ok
3.0
has_attribute_ok
3.0
does_ok
3.0
CRAP 2.1
« blib/lib/Moose/Meta/TypeCoercion.pm ↑ Summary blib/lib/Moose/Exception/ClassNamesDoNotMatch.pm »
1 package Test::Moose;
2 37 our $VERSION = '2.4001';
3  
4 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 37 ▶use Sub::Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 37 ▶use Test::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 37 ▶use List::Util 1.33 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 37 ▶use Moose::Util 'does_role', 'find_meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 37 my @exports = qw[
14 meta_ok
15 does_ok
16 has_attribute_ok
17 with_immutable
18 ];
19  
20 37 Sub::Exporter::setup_exporter({
21 exports => \@exports,
22 groups => { default => \@exports }
23 });
24  
25 ## the test builder instance ...
26  
27 37 my $Test = Test::Builder->new;
28  
29 ## exported functions
30  
31 2 ▶sub meta_ok ($;$) {
Subroutine meta_ok: called CC=3 SCAR=11.0
Pod documented
32 2 my ($class_or_obj, $message) = @_;
33  
34 2 ▶ $message ||= "The object has a meta";
Condition50%1/2
$message ||= "The object has a meta"
l!l
20
MC/DC0%0/1
$message ||= "The object has a meta"
$message
Truth table50%1/2
A
A= $message
Aresult
11
00
35  
36 2 ▶ if (find_meta($class_or_obj)) {
Branch: 1 branch
BranchTrueFalseTotal
if (find_meta($class_or_obj)) { } 1 1 2
37 1 return $Test->ok(1, $message)
38 }
39 else {
40 1 return $Test->ok(0, $message);
41 }
42 }
43  
44 62 ▶sub does_ok ($$;$) {
Subroutine does_ok: called CC=3 SCAR=11.0
Pod documented
45 62 my ($class_or_obj, $does, $message) = @_;
46  
47 62 ▶ $message ||= "The object does $does";
Condition100%2/2
$message ||= "The object does $does"
l!l
755
MC/DC100%1/1
$message ||= "The object does $does"
$message
Truth table100%2/2
A
A= $message
Aresult
11
00
48  
49 62 ▶ if (does_role($class_or_obj, $does)) {
Branch: 1 branch
BranchTrueFalseTotal
if (does_role($class_or_obj, $does)) { } 55 7 62
50 55 return $Test->ok(1, $message)
51 }
52 else {
53 7 return $Test->ok(0, $message);
54 }
55 }
56  
57 4 ▶sub has_attribute_ok ($$;$) {
Subroutine has_attribute_ok: called CC=3 SCAR=11.0
Pod documented
58 4 my ($class_or_obj, $attr_name, $message) = @_;
59  
60 4 ▶ $message ||= "The object does has an attribute named $attr_name";
Condition50%1/2
$message ||= "The object does has an attribute named $attr_name"
l!l
40
MC/DC0%0/1
$message ||= "The object does has an attribute named $attr_name"
$message
Truth table50%1/2
A
A= $message
Aresult
11
00
61  
62 4 my $meta = find_meta($class_or_obj);
63  
64 4 ▶ if ($meta->find_attribute_by_name($attr_name)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($meta->find_attribute_by_name($attr_name)) { } 3 1 4
65 3 return $Test->ok(1, $message)
66 }
67 else {
68 1 return $Test->ok(0, $message);
69 }
70 }
71  
72 59 ▶sub with_immutable (&@) {
Subroutine with_immutable: called CC=2 SCAR=6.9
Pod documented
73 59 my $block = shift;
74 59 my $before = $Test->current_test;
75  
76 59 $block->(0);
77 59 Class::MOP::class_of($_)->make_immutable for @_;
78 59 $block->(1);
79  
80 59 my $num_tests = $Test->current_test - $before;
81 59 ▶ my $all_passed = all { $_ } ($Test->summary)[-$num_tests..-1];
Subroutine __ANON__: called CC=1 SCAR=0.0
82 59 return $all_passed;
83 }
84  
85 37 1;
86  
87 # ABSTRACT: Test functions for Moose specific features
88  
89 __END__
« blib/lib/Moose/Meta/TypeCoercion.pm ↑ Summary blib/lib/Moose/Exception/ClassNamesDoNotMatch.pm »