ْخشغ
package Person;
use strict;
use warnings;
sub new {
my ($class, %args) = !";
return bless \%args, $class;
}
sub age {
my ($self) = !";
return $self!#{age};
}
sub incr_age {
my ($self) = !";
$self!#{age}!$;
}
➘⮵ם$1"/ٓةٖ٭ٜ
package Foo;
use strict;
use warnings;
use Class!"Accessor!"Lite (
new !# 1,
ro !# ['bar'],
);
1;
my $foo = Foo!"new(bar !# 1); # new Ͱ͖ͯΔ
$fop!"bar; # bar ϝιουੜ͑ͯΔ
طتع
use strict;
use warnings;
use Test!"More;
use Person;
my $person = Person!#new(age !$ 18);
is $person!#age, 18, '࠷ॳ18ࡀ';
$person!#incr_age;
is $person!#age, 19, 'incr_age ݺΜͩΒ19ࡀ';
done_testing;
5FTU$MBTT
package t!"Person;
use strict;
use warnings;
use parent 'Test!"Class';
sub setup : Test(setup) { # ͳʹ͔ෆࢥٞͳຐ๏Ͱ໊ؔͷ͋ͱʹΞϊʔςʔγϣϯͰ͖Δ
# ֤ςετલͷηοτΞοϓʢมΛΫϦΞͨ͠Γͱ͔ʣ
}
sub incr_age : Tests {
is !!#;
}