Parse-Method-Signatures
view release on metacpan or search on metacpan
use strict;
use warnings;
use Test::More 'no_plan';
use Test::Exception;
use Test::Differences;
use_ok("Parse::Method::Signatures") or BAIL_OUT("$@");
is( Parse::Method::Signatures->new("ArrayRef")->_ident(), "ArrayRef");
is( Parse::Method::Signatures->new("where::Foo")->_ident(), "where::Foo");
is( Parse::Method::Signatures->new("where Foo")->_ident(), undef);
throws_ok {
Parse::Method::Signatures->new("Foo[Bar")->tc()
} qr/^\QRunaway '[]' in type constraint near '[Bar' at\E/,
q/Runaway '[]' in type constraint near '[Bar' at/;
throws_ok {
Parse::Method::Signatures->new("Foo[Bar:]")->tc()
} qr/^\QError parsing type constraint near ':' in 'Bar:' at\E/,
q/Error parsing type constraint near ':' in 'Bar:' at/;
is( Parse::Method::Signatures->new("ArrayRef")->tc(), "ArrayRef");
is( Parse::Method::Signatures->new("ArrayRef[Str => Str]")->tc(), 'ArrayRef["Str",Str]');
is( Parse::Method::Signatures->new("ArrayRef[Str]")->tc(), "ArrayRef[Str]");
is( Parse::Method::Signatures->new("ArrayRef[0 => Foo]")->tc(), "ArrayRef[0,Foo]");
is( Parse::Method::Signatures->new("ArrayRef[qq/0/]")->tc(), "ArrayRef[qq/0/]");
is( Parse::Method::Signatures->new("Foo|Bar")->tc(), "Foo|Bar");
lives_ok { Parse::Method::Signatures->new('$x')->param() };
throws_ok {
Parse::Method::Signatures->new('$x[0]')->param()
} qr/Error parsing parameter near '\$x' in '\$x\[0\]' at /,
q{Error parsing parameter near '\$x' in '\$x\[0\]' at };
test_param(
Parse::Method::Signatures->new('$x')->param(),
{ required => 1,
sigil => '$',
variable_name => '$x',
__does => ["Parse::Method::Signatures::Param::Positional"],
}
);
test_param(
Parse::Method::Signatures->new('$x!')->param(),
{ required => 1,
sigil => '$',
variable_name => '$x',
__does => ["Parse::Method::Signatures::Param::Positional"],
}
);
test_param(
Parse::Method::Signatures->new('$x?')->param(),
{ required => 0,
sigil => '$',
variable_name => '$x',
__does => ["Parse::Method::Signatures::Param::Positional"],
}
);
( run in 0.489 second using v1.01-cache-2.11-cpan-39bf76dae61 )