| 1 | package Object::HashBase::Test; | ||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 2 | ▶ | use vars qw/$NO_RUN $TODO/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | BEGIN { | ||||||||||||
| 8 | 2 | ▶ | if ($NO_RUN) { | ||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||
| 9 | 1 | ▶ | *ok = sub { }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 1 | ▶ | *is = sub { }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 1 | ▶ | *is_deeply = sub { }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 1 | ▶ | *like = sub { }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||
| 13 | 1 | ▶ | *done_testing = sub { }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||
| 14 | } | ||||||||||||
| 15 | else { | ||||||||||||
| 16 | 1 | require Test::More; | |||||||||||
| 17 | 1 | Test::More->import; | |||||||||||
| 18 | } | ||||||||||||
| 19 | } | ||||||||||||
| 20 | |||||||||||||
| 21 | 2 | ▶ | return 1 if $NO_RUN; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 22 | |||||||||||||
| 23 | 1 | our $VERSION = '0.017'; | |||||||||||
| 24 | # <-- START --> | ||||||||||||
| 25 | |||||||||||||
| 26 | sub warnings(&) { | ||||||||||||
| 27 | 1 | ▶ | my $code = shift; | ||||||||||
|
Subroutine
warnings: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 28 | 1 | my @warnings; | |||||||||||
| 29 | 1 | ▶ | local $SIG{__WARN__} = sub { push @warnings => @_ }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 30 | 1 | $code->(); | |||||||||||
| 31 | 1 | return \@warnings; | |||||||||||
| 32 | } | ||||||||||||
| 33 | |||||||||||||
| 34 | sub exception(&) { | ||||||||||||
| 35 | 2 | ▶ | my $code = shift; | ||||||||||
|
Subroutine
exception: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||
| 36 | 2 | local ($@, $!, $SIG{__DIE__}); | |||||||||||
| 37 | 2 | my $ok = eval { $code->(); 1 }; | |||||||||||
| 38 | 2 | ▶ | my $error = $@ || 'SQUASHED ERROR'; | ||||||||||
|
Condition50%1/2
$@ || 'SQUASHED ERROR'
MC/DC0%0/1
$@ || 'SQUASHED ERROR'
$@
Truth table50%1/2
A
A= $@
| |||||||||||||
| 39 | 2 | ▶ | return $ok ? undef : $error; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | BEGIN { | ||||||||||||
| 43 | 2 | ▶ | $INC{'Object/HashBase/Test/HBase.pm'} = __FILE__; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 44 | |||||||||||||
| 45 | package | ||||||||||||
| 46 | Object::HashBase::Test::HBase; | ||||||||||||
| 47 | 2 | ▶ | use Object::HashBase qw/foo bar baz/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 48 | |||||||||||||
| 49 | 2 | Object::HashBase::Test::is(FOO, 'foo', "FOO CONSTANT"); | |||||||||||
| 50 | 2 | Object::HashBase::Test::is(BAR, 'bar', "BAR CONSTANT"); | |||||||||||
| 51 | 2 | Object::HashBase::Test::is(BAZ, 'baz', "BAZ CONSTANT"); | |||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | { | ||||||||||||
| 55 | 1 | BEGIN { | |||||||||||
| 56 | 2 | ▶ | $INC{'Object/HashBase/Test/HBaseINIT.pm'} = __FILE__; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 57 | 2 | $INC{'Object/HashBase/Test/HBaseINIT2.pm'} = __FILE__; | |||||||||||
| 58 | } | ||||||||||||
| 59 | |||||||||||||
| 60 | package | ||||||||||||
| 61 | Object::HashBase::Test::HBaseINIT; | ||||||||||||
| 62 | 2 | ▶ | use Object::HashBase qw/foo bar baz/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 63 | |||||||||||||
| 64 | 1 | $main::counter = 0; | |||||||||||
| 65 | 2 | ▶ | add_pre_init { shift->{pre_init_1} = $main::counter++ }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 66 | 2 | ▶ | add_pre_init { shift->{pre_init_2} = $main::counter++ }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 67 | 2 | ▶ | sub init { shift->{init} = $main::counter++ }; | ||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 68 | 2 | ▶ | add_post_init { shift->{post_init_1} = $main::counter++ }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 69 | 2 | ▶ | add_post_init { shift->{post_init_2} = $main::counter++ }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 70 | |||||||||||||
| 71 | package | ||||||||||||
| 72 | Object::HashBase::Test::HBaseINIT2; | ||||||||||||
| 73 | 2 | ▶ | use parent 'Object::HashBase::Test::HBaseINIT'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 74 | 2 | ▶ | use Object::HashBase qw/boop/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 75 | |||||||||||||
| 76 | 1 | ▶ | add_pre_init { shift->{pre_init_3} = $main::counter++ }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 77 | 1 | ▶ | sub init { $_[0]->SUPER::init(); $_[0]->{init2} = $main::counter++ }; | ||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 78 | 1 | ▶ | add_post_init { shift->{post_init_3} = $main::counter++ }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 79 | |||||||||||||
| 80 | } | ||||||||||||
| 81 | |||||||||||||
| 82 | BEGIN { | ||||||||||||
| 83 | package | ||||||||||||
| 84 | Object::HashBase::Test::HBaseSub; | ||||||||||||
| 85 | 2 | ▶ | use base 'Object::HashBase::Test::HBase'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 86 | 2 | ▶ | use Object::HashBase qw/apple pear/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 87 | |||||||||||||
| 88 | 2 | ▶ | Object::HashBase::Test::is(FOO, 'foo', "FOO CONSTANT"); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 89 | 2 | Object::HashBase::Test::is(BAR, 'bar', "BAR CONSTANT"); | |||||||||||
| 90 | 2 | Object::HashBase::Test::is(BAZ, 'baz', "BAZ CONSTANT"); | |||||||||||
| 91 | 2 | Object::HashBase::Test::is(APPLE, 'apple', "APPLE CONSTANT"); | |||||||||||
| 92 | 2 | Object::HashBase::Test::is(PEAR, 'pear', "PEAR CONSTANT"); | |||||||||||
| 93 | } | ||||||||||||
| 94 | |||||||||||||
| 95 | 1 | my $one = Object::HashBase::Test::HBase->new(foo => 'a', bar => 'b', baz => 'c'); | |||||||||||
| 96 | 1 | is($one->foo, 'a', "Accessor"); | |||||||||||
| 97 | 1 | is($one->bar, 'b', "Accessor"); | |||||||||||
| 98 | 1 | is($one->baz, 'c', "Accessor"); | |||||||||||
| 99 | 1 | $one->set_foo('x'); | |||||||||||
| 100 | 1 | is($one->foo, 'x', "Accessor set"); | |||||||||||
| 101 | 1 | $one->set_foo(undef); | |||||||||||
| 102 | |||||||||||||
| 103 | 1 | is_deeply( | |||||||||||
| 104 | $one, | ||||||||||||
| 105 | { | ||||||||||||
| 106 | foo => undef, | ||||||||||||
| 107 | bar => 'b', | ||||||||||||
| 108 | baz => 'c', | ||||||||||||
| 109 | }, | ||||||||||||
| 110 | 'hash' | ||||||||||||
| 111 | ); | ||||||||||||
| 112 | |||||||||||||
| 113 | { | ||||||||||||
| 114 | 1 | my @warns; | |||||||||||
| 115 | 0 | ▶ | local $SIG{__WARN__} = sub { push @warns => @_ }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||
| 116 | 2 | ▶ | Object::HashBase::Test::HBaseINIT->add_post_init(sub { shift->{late_post} = 'yes' }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 117 | 1 | ▶ | ok(!@warns, "No Warnings adding a post-init") or diag(@_); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 118 | } | ||||||||||||
| 119 | |||||||||||||
| 120 | 1 | $main::counter = 0; | |||||||||||
| 121 | 1 | my $two = Object::HashBase::Test::HBaseINIT->new(); | |||||||||||
| 122 | 1 | is_deeply( | |||||||||||
| 123 | $two, | ||||||||||||
| 124 | { | ||||||||||||
| 125 | pre_init_1 => 0, | ||||||||||||
| 126 | pre_init_2 => 1, | ||||||||||||
| 127 | init => 2, | ||||||||||||
| 128 | post_init_2 => 3, | ||||||||||||
| 129 | post_init_1 => 4, | ||||||||||||
| 130 | late_post => 'yes', | ||||||||||||
| 131 | }, | ||||||||||||
| 132 | "inits ran in the correct order" | ||||||||||||
| 133 | ); | ||||||||||||
| 134 | |||||||||||||
| 135 | 1 | $main::counter = 0; | |||||||||||
| 136 | 1 | my $three = Object::HashBase::Test::HBaseINIT2->new(); | |||||||||||
| 137 | 1 | is_deeply( | |||||||||||
| 138 | $three, | ||||||||||||
| 139 | { | ||||||||||||
| 140 | pre_init_1 => 0, | ||||||||||||
| 141 | pre_init_2 => 1, | ||||||||||||
| 142 | pre_init_3 => 2, | ||||||||||||
| 143 | init => 3, | ||||||||||||
| 144 | init2 => 4, | ||||||||||||
| 145 | post_init_3 => 5, | ||||||||||||
| 146 | post_init_2 => 6, | ||||||||||||
| 147 | post_init_1 => 7, | ||||||||||||
| 148 | late_post => 'yes', | ||||||||||||
| 149 | }, | ||||||||||||
| 150 | "inits ran in the correct order" | ||||||||||||
| 151 | ); | ||||||||||||
| 152 | |||||||||||||
| 153 | |||||||||||||
| 154 | BEGIN { | ||||||||||||
| 155 | package | ||||||||||||
| 156 | Object::HashBase::Test::Const::Test; | ||||||||||||
| 157 | 2 | ▶ | use Object::HashBase qw/foo/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: not called CC=1 SCAR=0.0
| |||||||||||||
| 158 | |||||||||||||
| 159 | sub do_it { | ||||||||||||
| 160 | 2 | ▶ | if (FOO()) { | ||||||||||
|
Subroutine
do_it: called CC=1 SCAR=0.4
| |||||||||||||
| 161 | 2 | return 'const'; | |||||||||||
| 162 | } | ||||||||||||
| 163 | 0 | return 'not const' | |||||||||||
| 164 | } | ||||||||||||
| 165 | } | ||||||||||||
| 166 | |||||||||||||
| 167 | 1 | my $pkg = 'Object::HashBase::Test::Const::Test'; | |||||||||||
| 168 | 1 | is($pkg->do_it, 'const', "worked as expected"); | |||||||||||
| 169 | { | ||||||||||||
| 170 | 1 | ▶ | local $SIG{__WARN__} = sub { }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 171 | 1 | ▶ | *Object::HashBase::Test::Const::Test::FOO = sub { 0 }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 172 | } | ||||||||||||
| 173 | 1 | ok(!$pkg->FOO, "overrode const sub"); | |||||||||||
| 174 | { | ||||||||||||
| 175 | 1 | ▶ | local $TODO = "known to fail on $]" if $] le "5.006002"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 176 | 1 | is($pkg->do_it, 'const', "worked as expected, const was constant"); | |||||||||||
| 177 | } | ||||||||||||
| 178 | |||||||||||||
| 179 | BEGIN { | ||||||||||||
| 180 | 2 | ▶ | $INC{'Object/HashBase/Test/HBase/Wrapped.pm'} = __FILE__; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 181 | |||||||||||||
| 182 | package | ||||||||||||
| 183 | Object::HashBase::Test::HBase::Wrapped; | ||||||||||||
| 184 | 2 | ▶ | use Object::HashBase qw/foo bar dup/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 185 | |||||||||||||
| 186 | 2 | my $foo = __PACKAGE__->can('foo'); | |||||||||||
| 187 | 2 | ▶ | no warnings 'redefine'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 188 | *foo = sub { | ||||||||||||
| 189 | 4 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 190 | 4 | $self->set_bar(1); | |||||||||||
| 191 | 4 | $self->$foo(@_); | |||||||||||
| 192 | 2 | }; | |||||||||||
| 193 | } | ||||||||||||
| 194 | |||||||||||||
| 195 | BEGIN { | ||||||||||||
| 196 | 2 | ▶ | $INC{'Object/HashBase/Test/HBase/Wrapped/Inherit.pm'} = __FILE__; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 197 | |||||||||||||
| 198 | package | ||||||||||||
| 199 | Object::HashBase::Test::HBase::Wrapped::Inherit; | ||||||||||||
| 200 | 2 | ▶ | use base 'Object::HashBase::Test::HBase::Wrapped'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 201 | 2 | ▶ | use Object::HashBase qw/baz dup/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 202 | } | ||||||||||||
| 203 | |||||||||||||
| 204 | 1 | my $o = Object::HashBase::Test::HBase::Wrapped::Inherit->new(foo => 1); | |||||||||||
| 205 | 1 | my $foo = $o->foo; | |||||||||||
| 206 | 1 | is($o->bar, 1, 'parent attribute sub not overridden'); | |||||||||||
| 207 | |||||||||||||
| 208 | { | ||||||||||||
| 209 | package | ||||||||||||
| 210 | Foo; | ||||||||||||
| 211 | |||||||||||||
| 212 | sub new; | ||||||||||||
| 213 | |||||||||||||
| 214 | 2 | ▶ | use Object::HashBase qw/foo bar baz/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 215 | |||||||||||||
| 216 | 1 | ▶ | sub new { 'foo' }; | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||
| 217 | } | ||||||||||||
| 218 | |||||||||||||
| 219 | 1 | is(Foo->new, 'foo', "Did not override existing 'new' method"); | |||||||||||
| 220 | |||||||||||||
| 221 | BEGIN { | ||||||||||||
| 222 | 2 | ▶ | $INC{'Object/HashBase/Test/HBase2.pm'} = __FILE__; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 223 | |||||||||||||
| 224 | package | ||||||||||||
| 225 | Object::HashBase::Test::HBase2; | ||||||||||||
| 226 | 2 | ▶ | use Object::HashBase qw/foo -bar ^baz <bat >ban +boo/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 227 | |||||||||||||
| 228 | 2 | Object::HashBase::Test::is(FOO, 'foo', "FOO CONSTANT"); | |||||||||||
| 229 | 2 | Object::HashBase::Test::is(BAR, 'bar', "BAR CONSTANT"); | |||||||||||
| 230 | 2 | Object::HashBase::Test::is(BAZ, 'baz', "BAZ CONSTANT"); | |||||||||||
| 231 | 2 | Object::HashBase::Test::is(BAT, 'bat', "BAT CONSTANT"); | |||||||||||
| 232 | 2 | Object::HashBase::Test::is(BAN, 'ban', "BAN CONSTANT"); | |||||||||||
| 233 | 2 | Object::HashBase::Test::is(BOO, 'boo', "BOO CONSTANT"); | |||||||||||
| 234 | } | ||||||||||||
| 235 | |||||||||||||
| 236 | 1 | my $ro = Object::HashBase::Test::HBase2->new(foo => 'foo', bar => 'bar', baz => 'baz', bat => 'bat', ban => 'ban'); | |||||||||||
| 237 | 1 | is($ro->foo, 'foo', "got foo"); | |||||||||||
| 238 | 1 | is($ro->bar, 'bar', "got bar"); | |||||||||||
| 239 | 1 | is($ro->baz, 'baz', "got baz"); | |||||||||||
| 240 | 1 | is($ro->bat, 'bat', "got bat"); | |||||||||||
| 241 | 1 | ok(!$ro->can('set_bat'), "No setter for bat"); | |||||||||||
| 242 | 1 | ok(!$ro->can('ban'), "No reader for ban"); | |||||||||||
| 243 | 1 | ok(!$ro->can('boo'), "No reader for boo"); | |||||||||||
| 244 | 1 | ok(!$ro->can('set_boo'), "No setter for boo"); | |||||||||||
| 245 | 1 | is($ro->{ban}, 'ban', "ban attribute is set"); | |||||||||||
| 246 | 1 | $ro->set_ban('xxx'); | |||||||||||
| 247 | 1 | is($ro->{ban}, 'xxx', "ban attribute can be set"); | |||||||||||
| 248 | |||||||||||||
| 249 | 1 | is($ro->set_foo('xxx'), 'xxx', "Can set foo"); | |||||||||||
| 250 | 1 | is($ro->foo, 'xxx', "got foo"); | |||||||||||
| 251 | |||||||||||||
| 252 | 1 | ▶ | like(exception { $ro->set_bar('xxx') }, qr/'bar' is read-only/, "Cannot set bar"); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 253 | |||||||||||||
| 254 | 1 | ▶ | my $warnings = warnings { is($ro->set_baz('xxx'), 'xxx', 'set baz') }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 255 | 1 | like($warnings->[0], qr/set_baz\(\) is deprecated/, "Deprecation warning"); | |||||||||||
| 256 | |||||||||||||
| 257 | |||||||||||||
| 258 | |||||||||||||
| 259 | 1 | is_deeply( | |||||||||||
| 260 | [Object::HashBase::attr_list('Object::HashBase::Test::HBase::Wrapped::Inherit')], | ||||||||||||
| 261 | [qw/foo bar dup baz/], | ||||||||||||
| 262 | "Got a list of attributes in order starting from base class, duplicates removed", | ||||||||||||
| 263 | ); | ||||||||||||
| 264 | |||||||||||||
| 265 | 1 | my $x = Object::HashBase::Test::HBase::Wrapped::Inherit->new(foo => 1, baz => 2); | |||||||||||
| 266 | 1 | is($x->foo, 1, "set foo via pairs"); | |||||||||||
| 267 | 1 | is($x->baz, 2, "set baz via pairs"); | |||||||||||
| 268 | |||||||||||||
| 269 | # Now with hashref | ||||||||||||
| 270 | 1 | my $y = Object::HashBase::Test::HBase::Wrapped::Inherit->new({foo => 1, baz => 2}); | |||||||||||
| 271 | 1 | is($y->foo, 1, "set foo via hashref"); | |||||||||||
| 272 | 1 | is($y->baz, 2, "set baz via hashref"); | |||||||||||
| 273 | |||||||||||||
| 274 | # Now with hashref | ||||||||||||
| 275 | 1 | my $z = Object::HashBase::Test::HBase::Wrapped::Inherit->new([ | |||||||||||
| 276 | 1, # foo | ||||||||||||
| 277 | 2, # bar | ||||||||||||
| 278 | 3, # dup | ||||||||||||
| 279 | 4, # baz | ||||||||||||
| 280 | ]); | ||||||||||||
| 281 | 1 | is($z->foo, 1, "set foo via arrayref"); | |||||||||||
| 282 | 1 | is($z->baz, 4, "set baz via arrayref"); | |||||||||||
| 283 | |||||||||||||
| 284 | like( | ||||||||||||
| 285 | 1 | ▶ | exception { Object::HashBase::Test::HBase::Wrapped::Inherit->new([1 .. 10]) }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 286 | 1 | qr/Too many arguments for Object::HashBase::Test::HBase::Wrapped::Inherit constructor/, | |||||||||||
| 287 | "Too many args in array form" | ||||||||||||
| 288 | ); | ||||||||||||
| 289 | |||||||||||||
| 290 | |||||||||||||
| 291 | 1 | my $CAN_COUNT = 0; | |||||||||||
| 292 | 1 | my $CAN_COUNT2 = 0; | |||||||||||
| 293 | 1 | my $INIT_COUNT = 0; | |||||||||||
| 294 | BEGIN { | ||||||||||||
| 295 | 2 | ▶ | $INC{'Object/HashBase/Test/HBase3.pm'} = __FILE__; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 296 | package | ||||||||||||
| 297 | Object::HashBase::Test::HBase3; | ||||||||||||
| 298 | 2 | ▶ | use Object::HashBase qw/foo/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 299 | |||||||||||||
| 300 | sub can { | ||||||||||||
| 301 | 1 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
can: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 302 | 1 | $CAN_COUNT++; | |||||||||||
| 303 | 1 | $self->SUPER::can(@_); | |||||||||||
| 304 | } | ||||||||||||
| 305 | |||||||||||||
| 306 | 2 | $INC{'Object/HashBase/Test/HBase4.pm'} = __FILE__; | |||||||||||
| 307 | package | ||||||||||||
| 308 | Object::HashBase::Test::HBase4; | ||||||||||||
| 309 | 2 | ▶ | use Object::HashBase qw/foo/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 310 | |||||||||||||
| 311 | sub can { | ||||||||||||
| 312 | 1 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
can: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 313 | 1 | $CAN_COUNT2++; | |||||||||||
| 314 | 1 | $self->SUPER::can(@_); | |||||||||||
| 315 | } | ||||||||||||
| 316 | |||||||||||||
| 317 | 2 | ▶ | sub init { $INIT_COUNT++ } | ||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 318 | } | ||||||||||||
| 319 | |||||||||||||
| 320 | 1 | is($CAN_COUNT, 0, "->can has not been called yet"); | |||||||||||
| 321 | 1 | my $it = Object::HashBase::Test::HBase3->new; | |||||||||||
| 322 | 1 | is($CAN_COUNT, 1, "->can has been called once to check for init"); | |||||||||||
| 323 | 1 | $it = Object::HashBase::Test::HBase3->new; | |||||||||||
| 324 | 1 | is($CAN_COUNT, 1, "->can was not called again, we cached it"); | |||||||||||
| 325 | |||||||||||||
| 326 | 1 | is($CAN_COUNT2, 0, "->can has not been called yet"); | |||||||||||
| 327 | 1 | is($INIT_COUNT, 0, "->init has not been called yet"); | |||||||||||
| 328 | 1 | $it = Object::HashBase::Test::HBase4->new; | |||||||||||
| 329 | 1 | is($CAN_COUNT2, 1, "->can has been called once to check for init"); | |||||||||||
| 330 | 1 | is($INIT_COUNT, 1, "->init has been called once"); | |||||||||||
| 331 | 1 | $it = Object::HashBase::Test::HBase4->new; | |||||||||||
| 332 | 1 | is($CAN_COUNT2, 1, "->can was not called again, we cached it"); | |||||||||||
| 333 | 1 | is($INIT_COUNT, 2, "->init has been called again"); | |||||||||||
| 334 | |||||||||||||
| 335 | 1 | done_testing; | |||||||||||
| 336 | |||||||||||||
| 337 | 1 | 1; | |||||||||||