Benchmark-DKbench

 view release on metacpan or  search on metacpan

data/t/attributes/attribute_inherited_slot_specs.t  view on Meta::CPAN

use strict;
use warnings;

use Test::More;
use Test::Fatal;


{
    package Thing::Meta::Attribute;
    use Moose;

    extends 'Moose::Meta::Attribute';
    around illegal_options_for_inheritance => sub {
        return (shift->(@_), qw/trigger/);
    };

    package Thing;
    use Moose;

    sub hello   { 'Hello World (from Thing)' }
    sub goodbye { 'Goodbye World (from Thing)' }

    package Foo;
    use Moose;
    use Moose::Util::TypeConstraints;

    subtype 'FooStr'
        => as 'Str'
        => where { /Foo/ };

    coerce 'FooStr'
        => from ArrayRef
            => via { 'FooArrayRef' };

    has 'bar' => (is => 'ro', isa => 'Str', default => 'Foo::bar');
    has 'baz' => (is => 'rw', isa => 'Ref');
    has 'foo' => (is => 'rw', isa => 'FooStr');

    has 'gorch' => (is => 'ro');
    has 'gloum' => (is => 'ro', default => sub {[]});
    has 'fleem' => (is => 'ro');

    has 'bling' => (is => 'ro', isa => 'Thing');
    has 'blang' => (is => 'ro', isa => 'Thing', handles => ['goodbye']);

    has 'bunch_of_stuff' => (is => 'rw', isa => 'ArrayRef');

    has 'one_last_one' => (is => 'rw', isa => 'Ref');

    # this one will work here ....
    has 'fail' => (isa => 'CodeRef', is => 'bare');
    has 'other_fail' => (metaclass => 'Thing::Meta::Attribute', is => 'bare', trigger => sub { });

    package Bar;
    use Moose;
    use Moose::Util::TypeConstraints;

    extends 'Foo';

    ::is( ::exception {
        has '+bar' => (default => 'Bar::bar');
    }, undef, '... we can change the default attribute option' );

    ::is( ::exception {
        has '+baz' => (isa => 'ArrayRef');



( run in 0.782 second using v1.01-cache-2.11-cpan-54e63673c56 )