use Scalar::Util 'isweak';
-use Test::More tests => 24;
+use Test::More tests => 27;
use Test::Exception;
BEGIN {
{
package Foo;
- use strict;
- use warnings;
use Moose;
has 'bar' => (is => 'rw',
package Bar;
- use strict;
- use warnings;
use Moose;
has 'foo' => (is => 'rw', isa => 'Foo', weak_ref => 1);
package Baz;
- use strict;
- use warnings;
use Moose;
has 'foo' => (is => 'rw', isa => 'Foo', weak_ref => 1);
ok(isweak($baz->{foo}), '... baz.foo is a weak reference');
}
+# some errors
+
+{
+ package Bling;
+ use Moose;
+
+ ::dies_ok {
+ has('bling' => (is => 'ro', trigger => sub { 0 }));
+ } '... cannot create trigger on a read-only attr';
+}
+
+{
+ package Bling::Bling;
+ use Moose;
+
+ ::dies_ok {
+ has('bling' => (is => 'rw', trigger => 'Fail'));
+ } '... a trigger must be a CODE ref';
+
+ ::dies_ok {
+ has('bling' => (is => 'rw', trigger => []));
+ } '... a trigger must be a CODE ref';
+}
+
+