| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Mouse; |
|
2
|
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
321831
|
use Mouse::Exporter; |
|
|
26
|
|
|
|
|
41
|
|
|
|
26
|
|
|
|
|
134
|
|
|
4
|
26
|
|
|
26
|
|
128
|
use Mouse::Util qw(does_role find_meta); |
|
|
26
|
|
|
|
|
28
|
|
|
|
26
|
|
|
|
|
97
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
26
|
|
|
26
|
|
103
|
use Test::Builder; |
|
|
26
|
|
|
|
|
30
|
|
|
|
26
|
|
|
|
|
7418
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Mouse::Exporter->setup_import_methods( |
|
9
|
|
|
|
|
|
|
as_is => [qw( |
|
10
|
|
|
|
|
|
|
meta_ok |
|
11
|
|
|
|
|
|
|
does_ok |
|
12
|
|
|
|
|
|
|
has_attribute_ok |
|
13
|
|
|
|
|
|
|
with_immutable |
|
14
|
|
|
|
|
|
|
)], |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
## the test builder instance ... |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $Test = Test::Builder->new; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
## exported functions |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub meta_ok ($;$) { ## no critic |
|
24
|
2
|
|
|
2
|
1
|
484
|
my ($class_or_obj, $message) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
2
|
|
50
|
|
|
6
|
$message ||= "The object has a meta"; |
|
27
|
|
|
|
|
|
|
|
|
28
|
2
|
100
|
|
|
|
5
|
if (find_meta($class_or_obj)) { |
|
29
|
1
|
|
|
|
|
3
|
return $Test->ok(1, $message) |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
else { |
|
32
|
1
|
|
|
|
|
3
|
return $Test->ok(0, $message); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub does_ok ($$;$) { ## no critic |
|
37
|
22
|
|
|
22
|
1
|
2423
|
my ($class_or_obj, $does, $message) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
22
|
|
66
|
|
|
105
|
$message ||= "The object does $does"; |
|
40
|
|
|
|
|
|
|
|
|
41
|
22
|
100
|
|
|
|
52
|
if (does_role($class_or_obj, $does)) { |
|
42
|
20
|
|
|
|
|
52
|
return $Test->ok(1, $message) |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
else { |
|
45
|
2
|
|
|
|
|
6
|
return $Test->ok(0, $message); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub has_attribute_ok ($$;$) { ## no critic |
|
50
|
10
|
|
|
10
|
1
|
3694
|
my ($class_or_obj, $attr_name, $message) = @_; |
|
51
|
|
|
|
|
|
|
|
|
52
|
10
|
|
66
|
|
|
45
|
$message ||= "The object does has an attribute named $attr_name"; |
|
53
|
|
|
|
|
|
|
|
|
54
|
10
|
|
|
|
|
24
|
my $meta = find_meta($class_or_obj); |
|
55
|
|
|
|
|
|
|
|
|
56
|
10
|
100
|
|
|
|
28
|
if ($meta->find_attribute_by_name($attr_name)) { |
|
57
|
9
|
|
|
|
|
20
|
return $Test->ok(1, $message) |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
else { |
|
60
|
1
|
|
|
|
|
10
|
return $Test->ok(0, $message); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub with_immutable (&@) { ## no critic |
|
65
|
20
|
|
|
20
|
1
|
3361
|
my $block = shift; |
|
66
|
|
|
|
|
|
|
|
|
67
|
20
|
|
|
|
|
96
|
my $before = $Test->current_test; |
|
68
|
|
|
|
|
|
|
|
|
69
|
20
|
|
|
|
|
191
|
$block->(); |
|
70
|
20
|
|
|
|
|
28693
|
$_->meta->make_immutable for @_; |
|
71
|
20
|
|
|
|
|
47
|
$block->(); |
|
72
|
20
|
100
|
|
|
|
27156
|
return if not defined wantarray; |
|
73
|
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
4
|
my $num_tests = $Test->current_test - $before; |
|
75
|
2
|
|
|
|
|
14
|
return !grep{ !$_ } ($Test->summary)[-$num_tests .. -1]; |
|
|
4
|
|
|
|
|
18
|
|
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
|
79
|
|
|
|
|
|
|
__END__ |