+package Moose::Cookbook::Basics::Recipe1;
-=pod
+# ABSTRACT: The (always classic) B<Point> example.
+
+__END__
-=head1 NAME
-Moose::Cookbook::Basics::Recipe1 - The (always classic) B<Point> example.
+=pod
=head1 SYNOPSIS
From here on, we can use C<$point> and C<$point3d> just as you would
any other Perl 5 object. For a more detailed example of what can be
done, you can refer to the
-F<t/000_recipes/moose_cookbook_basics_recipe1.t> test file.
+F<t/recipes/moose_cookbook_basics_recipe1.t> test file.
=head2 Moose Objects are Just Hashrefs
=back
-=head1 AUTHORS
-
-Stevan Little E<lt>stevan@iinteractive.comE<gt>
-
-Dave Rolsky E<lt>autarch@urth.orgE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006-2010 by Infinity Interactive, Inc.
-
-L<http://www.iinteractive.com>
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
=begin testing
my $point = Point->new( x => 1, y => 2 );
$point->y(10);
is( $point->y, 10, '... got the right (changed) value for y' );
-dies_ok {
- $point->y('Foo');
-}
-'... cannot assign a non-Int to y';
+isnt(
+ exception {
+ $point->y('Foo');
+ },
+ undef,
+ '... cannot assign a non-Int to y'
+);
-dies_ok {
- Point->new();
-}
-'... must provide required attributes to new';
+isnt(
+ exception {
+ Point->new();
+ },
+ undef,
+ '... must provide required attributes to new'
+);
$point->clear();
# check the type constraints on the constructor
-lives_ok {
- Point->new( x => 0, y => 0 );
-}
-'... can assign a 0 to x and y';
+is(
+ exception {
+ Point->new( x => 0, y => 0 );
+ },
+ undef,
+ '... can assign a 0 to x and y'
+);
-dies_ok {
- Point->new( x => 10, y => 'Foo' );
-}
-'... cannot assign a non-Int to y';
+isnt(
+ exception {
+ Point->new( x => 10, y => 'Foo' );
+ },
+ undef,
+ '... cannot assign a non-Int to y'
+);
-dies_ok {
- Point->new( x => 'Foo', y => 10 );
-}
-'... cannot assign a non-Int to x';
+isnt(
+ exception {
+ Point->new( x => 'Foo', y => 10 );
+ },
+ undef,
+ '... 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' );
-dies_ok {
- Point3D->new( x => 10, y => 'Foo', z => 3 );
-}
-'... cannot assign a non-Int to y';
+isnt(
+ exception {
+ Point3D->new( x => 10, y => 'Foo', z => 3 );
+ },
+ undef,
+ '... cannot assign a non-Int to y'
+);
-dies_ok {
- Point3D->new( x => 'Foo', y => 10, z => 3 );
-}
-'... cannot assign a non-Int to x';
+isnt(
+ exception {
+ Point3D->new( x => 'Foo', y => 10, z => 3 );
+ },
+ undef,
+ '... cannot assign a non-Int to x'
+);
-dies_ok {
- Point3D->new( x => 0, y => 10, z => 'Bar' );
-}
-'... cannot assign a non-Int to z';
+isnt(
+ exception {
+ Point3D->new( x => 0, y => 10, z => 'Bar' );
+ },
+ undef,
+ '... cannot assign a non-Int to z'
+);
-dies_ok {
- Point3D->new( x => 10, y => 3 );
-}
-'... z is a required attribute for Point3D';
+isnt(
+ exception {
+ Point3D->new( x => 10, y => 3 );
+ },
+ undef,
+ '... z is a required attribute for Point3D'
+);
# test some class introspection
can_ok( 'Point3D', 'meta' );
isa_ok( Point3D->meta, 'Moose::Meta::Class' );
-isnt( Point->meta, Point3D->meta,
- '... they are different metaclasses as well' );
+isnt(
+ Point->meta, Point3D->meta,
+ '... they are different metaclasses as well'
+);
# poke at Point