X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F011_create_class.t;h=839a8d9b4497153e5dea4e01dec0d1eeef3f4a9d;hb=b4bd10ecd2eabe1a2c1bc3addad22b207f6592ee;hp=15252b6519b1b6f01550a92785f66f60713fa5ab;hpb=b9dfbf78527011f5752e3ec901141e52ee1bb6b1;p=gitmo%2FClass-MOP.git diff --git a/t/011_create_class.t b/t/011_create_class.t index 15252b6..839a8d9 100644 --- a/t/011_create_class.t +++ b/t/011_create_class.t @@ -1,22 +1,19 @@ -#!/usr/bin/perl - use strict; use warnings; -use Test::More tests => 28; +use Test::More tests => 27; use Test::Exception; -BEGIN { - use_ok('Class::MOP'); -} +use Class::MOP; -my $Point = Class::MOP::Class->create('Point' => '0.01' => ( +my $Point = Class::MOP::Class->create('Point' => ( + version => '0.01', attributes => [ - Class::MOP::Attribute->new('$.x' => ( + Class::MOP::Attribute->new('x' => ( reader => 'x', init_arg => 'x' )), - Class::MOP::Attribute->new('$.y' => ( + Class::MOP::Attribute->new('y' => ( accessor => 'y', init_arg => 'y' )), @@ -29,23 +26,24 @@ my $Point = Class::MOP::Class->create('Point' => '0.01' => ( }, 'clear' => sub { my $self = shift; - $self->{'$.x'} = 0; - $self->{'$.y'} = 0; + $self->{'x'} = 0; + $self->{'y'} = 0; } } )); -my $Point3D = Class::MOP::Class->create('Point3D' => '0.01' => ( +my $Point3D = Class::MOP::Class->create('Point3D' => ( + version => '0.01', superclasses => [ 'Point' ], attributes => [ - Class::MOP::Attribute->new('$:z' => ( + Class::MOP::Attribute->new('z' => ( default => 123 )), ], methods => { 'clear' => sub { my $self = shift; - $self->{'$:z'} = 0; + $self->{'z'} = 0; $self->SUPER::clear(); } } @@ -68,24 +66,24 @@ can_ok($point, 'clear'); is($meta, Point->meta(), '... got the meta from the instance too'); } -is($point->y, 3, '... the $.y attribute was initialized correctly through the metaobject'); +is($point->y, 3, '... the y attribute was initialized correctly through the metaobject'); $point->y(42); -is($point->y, 42, '... the $.y attribute was set properly with the accessor'); +is($point->y, 42, '... the y attribute was set properly with the accessor'); -is($point->x, 2, '... the $.x attribute was initialized correctly through the metaobject'); +is($point->x, 2, '... the x attribute was initialized correctly through the metaobject'); dies_ok { $point->x(42); } '... cannot write to a read-only accessor'; -is($point->x, 2, '... the $.x attribute was not altered'); +is($point->x, 2, '... the x attribute was not altered'); $point->clear(); -is($point->y, 0, '... the $.y attribute was cleared correctly'); -is($point->x, 0, '... the $.x attribute was cleared correctly'); +is($point->y, 0, '... the y attribute was cleared correctly'); +is($point->x, 0, '... the x attribute was cleared correctly'); -my $point3d = Point3D->new('x' => 1, 'y' => 2, '$:z' => 3); +my $point3d = Point3D->new('x' => 1, 'y' => 2, 'z' => 3); isa_ok($point3d, 'Point3D'); isa_ok($point3d, 'Point'); @@ -98,17 +96,17 @@ can_ok($point3d, 'x'); can_ok($point3d, 'y'); can_ok($point3d, 'clear'); -is($point3d->x, 1, '... the $.x attribute was initialized correctly through the metaobject'); -is($point3d->y, 2, '... the $.y attribute was initialized correctly through the metaobject'); -is($point3d->{'$:z'}, 3, '... the $:z attribute was initialized correctly through the metaobject'); +is($point3d->x, 1, '... the x attribute was initialized correctly through the metaobject'); +is($point3d->y, 2, '... the y attribute was initialized correctly through the metaobject'); +is($point3d->{'z'}, 3, '... the z attribute was initialized correctly through the metaobject'); { 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->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'); }