-#!/usr/bin/perl
-
use strict;
use warnings;
-use Test::More tests => 27;
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
use Class::MOP;
Class::MOP::Attribute->new('y' => (
accessor => 'y',
init_arg => 'y'
- )),
+ )),
],
methods => {
'new' => sub {
my $class = shift;
- my $instance = $class->meta->construct_instance(@_);
+ my $instance = $class->meta->new_object(@_);
bless $instance => $class;
},
'clear' => sub {
my $self = shift;
$self->{'x'} = 0;
- $self->{'y'} = 0;
+ $self->{'y'} = 0;
}
}
));
my $Point3D = Class::MOP::Class->create('Point3D' => (
- version => '0.01',
+ version => '0.01',
superclasses => [ 'Point' ],
attributes => [
Class::MOP::Attribute->new('z' => (
is($point->x, 2, '... the x attribute was initialized correctly through the metaobject');
-dies_ok {
+isnt( exception {
$point->x(42);
-} '... cannot write to a read-only accessor';
+}, undef, '... cannot write to a read-only accessor' );
is($point->x, 2, '... the x attribute was not altered');
$point->clear();
{
my $point3d = Point3D->new();
isa_ok($point3d, 'Point3D');
-
+
is($point3d->x, undef, '... the x attribute was not initialized');
is($point3d->y, undef, '... the y attribute was not initialized');
- is($point3d->{'z'}, 123, '... the z attribute was initialized correctly through the metaobject');
-
-}
+ is($point3d->{'z'}, 123, '... the z attribute was initialized correctly through the metaobject');
+}
+done_testing;