MooseX Release Notes :: Types, hard test case :)

So, after an embarrassing debugging time, I finally split this problem up into a simple test case. I would humbly ask for some help to understand why it fails. :) Here is the error message I get:

plxc16479> $h2/tmp/tmp18.pl
This method [new] requires a single argument. at /nfs/pdx/disks/nehalem.pde.077/perl/5.12.2/lib64/site_perl/MooseX/Types/TypeDecorator.pm line 91

MooseX::Types::TypeDecorator::new('MooseX::Types::TypeDecorator=HASH(0x655b90)') called at /nfs/pdx/disks/nehalem.pde.077/projects/lib/Program-Plist-Pl/lib/Program/Plist/Pl.pm line 10

Program::Plist::Pl::BUILD('Program::Plist::Pl=HASH(0x63d478)', 'HASH(0x63d220)') called at generated method (unknown origin) line 29

Program::Plist::Pl::new('Program::Plist::Pl') called at /nfs/pdx/disks/nehalem.pde.077/tmp/tmp18.pl line 10

Script wrapper test:

use strict;
use warnings;

BEGIN {push(@INC, split(':', $ENV{PERL_TEST_LIBS}))};

use Program::Plist::Pl;

my $obj = Program::Plist::Pl->new();

Program :: Plist :: Pl file:

package Program::Plist::Pl;

use Moose;
use namespace::autoclean;

use Program::Types qw(Pattern); # <-- Removing this fixes error
use Program::Plist::Pl::Pattern;

sub BUILD {
  my $pattern_obj = Program::Plist::Pl::Pattern->new();
}

__PACKAGE__->meta->make_immutable;

1;

Program File :: Types:

package Program::Types;

use MooseX::Types -declare => [qw(Pattern)];

class_type Pattern, {class => 'Program::Plist::Pl::Pattern'};

1;

And the file Program :: Plist :: Pl :: Pattern:

package Program::Plist::Pl::Pattern;

use Moose;
use namespace::autoclean;

__PACKAGE__->meta->make_immutable;

1;

Notes. Although I do not need the type Patternfrom Program::Typesin the above code, I do it in another code that is deprived. PERL_TEST_LIBSenv var, from which I pull the paths INC, contains only the paths to the project modules. There are no other modules on these paths.

, MooseX::Types Pattern , , . , , , class_type, . Intent Pattern MooseX::Params::Validate, , Program::Plist::Pl::Program.

, Program::Plist::Pl Pattern->new tmp18.pl , Program::Types Pattern.

+3
1

package Program::Plist::Pl;
...
use Program::Types qw(Pattern);

Pattern Program::Plist::Pl. Program::Plist::Pl::Pattern. ,

Program::Plist::Pl::Pattern->new();

Program::Plist::Pl::Pattern()->new();

'Program::Plist::Pl::Pattern'->new();

. , ( ), . , ( PatternObj).

namespace::autoclean . . Program::Plist::Pl::Pattern() , .

+5

Source: https://habr.com/ru/post/1784626/


All Articles