'... we can add the handles attribute option' );
# this one will *not* work here ....
::isnt( ::exception {
has '+blang' => (handles => ['hello']);
}, undef, '... we can not alte
Ref');
}, undef, '... can now create an attribute with an improper subtype relation' );
::isnt( ::exception {
has '+other_fail' => (trigger => sub {});
}, undef, '... cannot create
right value for foo');
isnt( exception { $foo->foo([]) }, undef, '... foo is not coercing (as expected)' );
is($foo->bar, 'Foo::bar', '... got the right default value');
isnt( exception { $foo->bar(
'... set bar successfully with a HASH ref' );
isnt( exception {
$foo->bar(100)
}, undef, '... couldnt set bar successfully with a number' );
isnt( exception {
$foo->bar(sub {})
}, undef, '.
th bar successfully set with a HASH ref' );
isnt( exception {
Foo->new(bar => 50)
}, undef, '... didnt create a new Foo with bar as a number' );
isnt( exception {
Foo->new(bar => sub {})
},
set baz successfully with a CODE ref' );
isnt( exception {
$bar->baz(\(my $var1))
}, undef, '... couldnt set baz successfully with a SCALAR ref' );
isnt( exception {
$bar->baz({})
}, undef,
{$obj->_foo(1)}, undef, "$class->_foo is writer" );
is($obj->foo(), 1, "$class->foo is reader");
isnt( exception {$obj->foo(2)}, undef, "$class->foo is not writer" ); # this should fail
ok(!defined $
foo is writer" );
is($obj->foo(), 1, "$class->foo is reader");
isnt( exception {$obj->foo(1)}, undef, "$class->foo is not writer" );
isnt($obj->_foo(undef), 1, "$class->_foo is not reader");
$class =
$obj->_foo(1)}, undef, "$class->_foo is writer" );
is($obj->_foo(), 1, "$class->foo is reader");
isnt( exception { make_class('ro', 'accessor', "Test::Class::AccessorRO"); }, undef, "Cant define attr
isnt( exception {
$foo->bar($foo);
}, undef, '... foo did not pass the type constraint okay' );
is( exception {
$foo->baz($bar);
}, undef, '... baz passed the type constraint okay' );
isnt(
hen see if Class->does(Role)
# if it does not,.. we have a conflict... so we die loudly
::isnt( ::exception {
has 'foo' => (isa => 'Foo::Class', does => 'Bar::Class');
}, undef, '.
hen see if Class->does(Role)
# if it does not,.. we have a conflict... so we die loudly
::isnt( ::exception {
has 'foo' => (isa => 'Bling', does => 'Bar::Class');
}, undef, '... ca
e');
ok(!isweak($foo->{foo}), '... it is not a weak reference');
# required writer
isnt( exception {
Foo->new;
}, undef, '... cannot create without the required attribute' )
oo_int wrote successfully' );
is($foo->foo_int(), 100, '... got the correct set value');
isnt( exception {
$foo->foo_int("Foo");
}, undef, '... foo_int died successfully' );
oo, 'foo_deref' );
is_deeply( [$foo->foo_deref_ro()], [], "... default default value" );
isnt( exception {
$foo->foo_deref_ro( [] );
}, undef, "... read only" );
$foo->{foo_d
e');
ok(!isweak($foo->{foo}), '... it is not a weak reference');
# required writer
isnt( exception {
Foo->new;
}, undef, '... cannot create without the required attribute' )
ote successfully' );
is($foo->get_foo_required(), 100, '... got the correct set value');
isnt( exception {
$foo->set_foo_required();
}, undef, '... set_foo_required died successfu
nt wrote successfully' );
is($foo->get_foo_int(), 100, '... got the correct set value');
isnt( exception {
$foo->set_foo_int("Foo");
}, undef, '... set_foo_int died successfully'
Test::For::Lazy::TypeConstraint->new;
isa_ok($test, 'Test::For::Lazy::TypeConstraint');
isnt( exception {
$test->bad_lazy_attr;
}, undef, '... this does not work' );
is( exc
'ro',
isa => 'Str',
default => sub { return }
);
}
isnt( exception {
Test::UndefDefault::Attributes->new;
}, undef, '... default must return
MyMoose;
has 'foo' => ( required => 1, builder => 'build_foo', is => 'ro');
}
isnt( exception {
Test::Builder::Attribute::Broken->new;
}, undef, '... no builder, wtf' )
yMoose;
sub parent_method_1 { "parent_1" }
::can_ok('Parent', 'parent_method_1');
::isnt( ::exception {
has child_a => (
is => "ro",
default => sub {
handles => qr/_la$/,
);
}, undef, "can declare regex collector" );
::isnt( ::exception {
has child_d => (
is => "ro",
default => sub {
gate to object even without explicit reader" );
::can_ok('Parent', 'parent_method_1');
::isnt( ::exception {
has child_h => (
isa => "ChildH",
is => "
;
can_ok($foo, 'get_foo');
is($foo->get_foo(), undef, '... got an undefined value');
isnt( exception {
$foo->get_foo(100);
}, undef, '... get_foo is a read-only' );
ok(!e
can_ok($foo, 'get_lazy_foo');
is($foo->get_lazy_foo(), 10, '... got an deferred value');
isnt( exception {
$foo->get_lazy_foo(100);
}, undef, '... get_lazy_foo is a read-only' );
ling;
use MyMoose;
::isnt( ::exception {
has('bling' => (is => 'rw', trigger => 'Fail'));
}, undef, '... a trigger must be a CODE ref' );
::isnt( ::exception {
has('b
=> 'ArrayRef[Int]',
auto_deref => 1,
);
}
{
my $autoderef = AutoDeref->new;
isnt( exception {
$autoderef->bar(1, 2, 3);
}, undef, '... its auto-de-ref-ing, not auto-e
new },
handles => ['bar']
);
package Goorch::Autoloaded;
use MyMoose;
::isnt( ::exception {
has 'foo' => (
is => 'rw',
default => sub { F
$callback->("Hello $value World");
},
);
__PACKAGE__->meta->make_immutable;
}
isnt( exception {
Fail::Bar->new(foo => 10)
}, undef, '... this fails, because initializer returns