Benchmark-DKbench

 view release on metacpan or  search on metacpan

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

use strict;
use warnings;

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


{
    {
        package Test::Attribute::Inline::Documentation;
        use Moose;

        has 'foo' => (
            documentation => q{
                The 'foo' attribute is my favorite
                attribute in the whole wide world.
            },
            is => 'bare',
        );
    }

    my $foo_attr = Test::Attribute::Inline::Documentation->meta->get_attribute('foo');

    ok($foo_attr->has_documentation, '... the foo has docs');
    is($foo_attr->documentation,
            q{
                The 'foo' attribute is my favorite
                attribute in the whole wide world.
            },
    '... got the foo docs');
}

{
    {
        package Test::For::Lazy::TypeConstraint;
        use Moose;
        use Moose::Util::TypeConstraints;

        has 'bad_lazy_attr' => (
            is => 'rw',
            isa => 'ArrayRef',
            lazy => 1,
            default => sub { "test" },
        );

        has 'good_lazy_attr' => (
            is => 'rw',
            isa => 'ArrayRef',
            lazy => 1,
            default => sub { [] },
        );

    }

    my $test = Test::For::Lazy::TypeConstraint->new;
    isa_ok($test, 'Test::For::Lazy::TypeConstraint');

    isnt( exception {
        $test->bad_lazy_attr;
    }, undef, '... this does not work' );

    is( exception {
        $test->good_lazy_attr;
    }, undef, '... this does not work' );
}



( run in 2.447 seconds using v1.01-cache-2.11-cpan-54e63673c56 )