From: gfx Date: Fri, 26 Feb 2010 06:24:47 +0000 (+0900) Subject: Add an example for Mouse error checking X-Git-Tag: 0.50_04~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=950f02e50997068e6ea0a7abd373a0846fff0343 Add an example for Mouse error checking --- diff --git a/example/warns.pl b/example/warns.pl new file mode 100644 index 0000000..7ba7fbb --- /dev/null +++ b/example/warns.pl @@ -0,0 +1,22 @@ +#!perl +package Point; +use Mouse; + +# extra 'unknown_attr' is supplied (WARN) +has 'x' => (isa => 'Int', is => 'rw', required => 1, unknown_attr => 1); + +# mandatory 'is' is not supplied (WARN) +has 'y' => (isa => 'Int', required => 1); + +sub clear { + my $self = shift; + $self->x(0); + $self->y(0); +} + +__PACKAGE__->meta->make_immutable(strict_constructor => 1); + +package main; + +# extra 'z' is supplied (FATAL) +my $point1 = Point->new(x => 5, y => 7, z => 9);