{
storage_type
'Array'
;
has
'$.x'
=> (
default
=>
'x value'
);
has
'$.z'
=> (
default
=>
'z value'
);
}
{
storage_type
'Array'
;
has
'$.y'
;
has
'$.k'
;
}
my
$subclass
= SubDummy->new;
isa_ok(
$subclass
,
'SubDummy'
);
is(
$subclass
->x,
'x value'
,
'should have x value'
);
{
storage_type
'Array'
;
has
'$.a'
;
Custom->meta->install_constructor;
}
my
$custom
= Custom->new;
isa_ok(
$custom
,
'Custom'
);
{
storage_type
'Array'
;
has
'$.attr'
;
Initialise->meta->set_initialise_method(
'init'
);;
sub
init {
my
(
$self
) =
@_
;
$self
->set_attr(
'initialise ...'
);
}
}
my
$init
= Initialise->new;
is(
$init
->attr,
'initialise ...'
,
'should have initialise ...'
);
{
storage_type
'Array'
;
has
'$.z'
=> (
default
=> 0);
abstract
'method1'
;
my
$classA
= ClassA->new;
::isa_ok(
$classA
,
'ClassA'
);
eval
{
$classA
->method1};
::like($@,
qr{method1 is an abstract method}
,
'catch an exception method1 is an abstract method'
);
abstract_class;
eval
{ClassA->new;};
::like($@,
qr{Can't instantiate abstract class}
, 'can\
't instantiate abstract class'
);
}
{
storage_type
'Array'
,
sub
{
my
$class
=
shift
;
bless
[
@_
],
$class
} ;
has
'$.a'
;
has
'$.b'
;
}
my
$d
= ClassD->new(121,1);
isa_ok(
$d
,
'ClassD'
);
is(
$d
->a, 121,
'should hava a attribute'
);
is(
$d
->b, 1,
'should hava b attribute'
);