Benchmark-DKbench

 view release on metacpan or  search on metacpan

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

use strict;
use warnings;

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

use Scalar::Util 'isweak';


{
    package Foo;
    use Moose;

    eval {
        has 'foo' => (
            accessor => 'foo',
        );
    };
    ::ok(!$@, '... created the accessor method okay');

    eval {
        has 'lazy_foo' => (
            accessor => 'lazy_foo',
            lazy     => 1,
            default  => sub { 10 }
        );
    };
    ::ok(!$@, '... created the lazy accessor method okay');


    eval {
        has 'foo_required' => (
            accessor => 'foo_required',
            required => 1,
        );
    };
    ::ok(!$@, '... created the required accessor method okay');

    eval {
        has 'foo_int' => (
            accessor => 'foo_int',
            isa      => 'Int',
        );
    };
    ::ok(!$@, '... created the accessor method with type constraint okay');

    eval {
        has 'foo_weak' => (
            accessor => 'foo_weak',
            weak_ref => 1
        );
    };
    ::ok(!$@, '... created the accessor method with weak_ref okay');

    eval {
        has 'foo_deref' => (
            accessor => 'foo_deref',
            isa => 'ArrayRef',
            auto_deref => 1,
        );
    };
    ::ok(!$@, '... created the accessor method with auto_deref okay');

    eval {
        has 'foo_deref_ro' => (



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