line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mouse; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
411929
|
use Mouse::Exporter; |
|
26
|
|
|
|
|
85
|
|
|
26
|
|
|
|
|
199
|
|
4
|
26
|
|
|
26
|
|
174
|
use Mouse::Util qw(does_role find_meta); |
|
26
|
|
|
|
|
58
|
|
|
26
|
|
|
|
|
145
|
|
5
|
|
|
|
|
|
|
|
6
|
26
|
|
|
26
|
|
159
|
use Test::Builder; |
|
26
|
|
|
|
|
57
|
|
|
26
|
|
|
|
|
9325
|
|
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
|
894
|
my ($class_or_obj, $message) = @_; |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
50
|
|
|
8
|
$message ||= "The object has a meta"; |
27
|
|
|
|
|
|
|
|
28
|
2
|
100
|
|
|
|
11
|
if (find_meta($class_or_obj)) { |
29
|
1
|
|
|
|
|
7
|
return $Test->ok(1, $message) |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
1
|
|
|
|
|
7
|
return $Test->ok(0, $message); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub does_ok ($$;$) { ## no critic |
37
|
22
|
|
|
22
|
1
|
2714
|
my ($class_or_obj, $does, $message) = @_; |
38
|
|
|
|
|
|
|
|
39
|
22
|
|
66
|
|
|
152
|
$message ||= "The object does $does"; |
40
|
|
|
|
|
|
|
|
41
|
22
|
100
|
|
|
|
78
|
if (does_role($class_or_obj, $does)) { |
42
|
20
|
|
|
|
|
81
|
return $Test->ok(1, $message) |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
2
|
|
|
|
|
7
|
return $Test->ok(0, $message); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub has_attribute_ok ($$;$) { ## no critic |
50
|
10
|
|
|
10
|
1
|
4795
|
my ($class_or_obj, $attr_name, $message) = @_; |
51
|
|
|
|
|
|
|
|
52
|
10
|
|
66
|
|
|
61
|
$message ||= "The object does has an attribute named $attr_name"; |
53
|
|
|
|
|
|
|
|
54
|
10
|
|
|
|
|
39
|
my $meta = find_meta($class_or_obj); |
55
|
|
|
|
|
|
|
|
56
|
10
|
100
|
|
|
|
54
|
if ($meta->find_attribute_by_name($attr_name)) { |
57
|
9
|
|
|
|
|
36
|
return $Test->ok(1, $message) |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
1
|
|
|
|
|
4
|
return $Test->ok(0, $message); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub with_immutable (&@) { ## no critic |
65
|
20
|
|
|
20
|
1
|
3268
|
my $block = shift; |
66
|
|
|
|
|
|
|
|
67
|
20
|
|
|
|
|
97
|
my $before = $Test->current_test; |
68
|
|
|
|
|
|
|
|
69
|
20
|
|
|
|
|
276
|
$block->(); |
70
|
20
|
|
|
|
|
39209
|
$_->meta->make_immutable for @_; |
71
|
20
|
|
|
|
|
72
|
$block->(); |
72
|
20
|
100
|
|
|
|
40559
|
return if not defined wantarray; |
73
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
5
|
my $num_tests = $Test->current_test - $before; |
75
|
2
|
|
|
|
|
20
|
return !grep{ !$_ } ($Test->summary)[-$num_tests .. -1]; |
|
4
|
|
|
|
|
27
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
__END__ |