MooseX-Extended

 view release on metacpan or  search on metacpan

lib/MooseX/Extended/Core.pm  view on Meta::CPAN

        and not exists $opt_for{writer}
        and not exists $opt_for{default}
        and not exists $opt_for{builder}
        and not defined $opt_for{init_arg}
        and $opt_for{is} eq 'ro' )
    {

        my $call_level = 1 + $opt_for{_call_level};
        my ( undef, $filename, $line ) = caller($call_level);
        Carp::carp("$attr_type '$name' is read-only and has no init_arg or default, defined at $filename line $line\n")
          if $] ge '5.028'
          and warnings::enabled_at_level( 'MooseX::Extended::naked_fields', $call_level );
    }

    delete $opt_for{_call_level};
    _debug( "Setting $attr_type, '$orig_name'", \%opt_for );
    $meta->add_attribute( $orig_name, %opt_for );
}

sub _is_valid_method_name ($name) {
    return if ref $name;

t/warnings.t  view on Meta::CPAN

#!/usr/bin/env perl

use lib 't/lib';
use MooseX::Extended::Tests;

plan skip_all => 'Perl >= 5.028 only'
    if $] lt '5.028';

warnings_like {

    package Local::Test1;
    use MooseX::Extended;
    field 'foo';
}
qr/field 'foo' is read-only and has no init_arg or default, defined at .+\bwarnings.t line 13/;

warning_is {



( run in 3.510 seconds using v1.01-cache-2.11-cpan-a49fcb8fa48 )