$point->y(10);
is( $point->y, 10, '... got the right (changed) value for y' );
-ok exception {
+dies_ok {
$point->y('Foo');
-},
+}
'... cannot assign a non-Int to y';
-ok exception {
+dies_ok {
Point->new();
-},
+}
'... must provide required attributes to new';
$point->clear();
# check the type constraints on the constructor
-ok ! exception {
+lives_ok {
Point->new( x => 0, y => 0 );
-},
+}
'... can assign a 0 to x and y';
-ok exception {
+dies_ok {
Point->new( x => 10, y => 'Foo' );
-},
+}
'... cannot assign a non-Int to y';
-ok exception {
+dies_ok {
Point->new( x => 'Foo', y => 10 );
-},
+}
'... cannot assign a non-Int to x';
# Point3D
is( $point3d->y, 0, '... got the right (cleared) value for y' );
is( $point3d->z, 0, '... got the right (cleared) value for z' );
-ok exception {
+dies_ok {
Point3D->new( x => 10, y => 'Foo', z => 3 );
-},
+}
'... cannot assign a non-Int to y';
-ok exception {
+dies_ok {
Point3D->new( x => 'Foo', y => 10, z => 3 );
-},
+}
'... cannot assign a non-Int to x';
-ok exception {
+dies_ok {
Point3D->new( x => 0, y => 10, z => 'Bar' );
-},
+}
'... cannot assign a non-Int to z';
-ok exception {
+dies_ok {
Point3D->new( x => 10, y => 3 );
-},
+}
'... z is a required attribute for Point3D';
# test some class introspection