use strict;
use warnings;
-use Test::More tests => 7 * 4;
+use Test::More tests => 3 + 7 * 4;
use lib 't/lib';
use LaTeX::TikZ::Meta::TypeConstraint::Autocoerce;
+{
+ my $tc = eval {
+ LaTeX::TikZ::Meta::TypeConstraint::Autocoerce->new(
+ target => undef,
+ );
+ };
+ like $@, qr/^No meta object for undefined target/, 'Undef target';
+}
+
+{
+ my $target = 'LaTeX::TikZ::A::Class::Likely::Not::To::Exist';
+ my $tc = eval {
+ LaTeX::TikZ::Meta::TypeConstraint::Autocoerce->new(
+ target => $target,
+ );
+ };
+ like $@, qr/^No meta object for target \Q$target\E/, 'Nonexistent target';
+}
+
+{
+ my $tc = eval {
+ LaTeX::TikZ::Meta::TypeConstraint::Autocoerce->new(
+ target => 'LaTeX::TikZ::Meta::TypeConstraint::Autocoerce',
+ );
+ };
+ is $@, '', 'Valid target';
+}
+
{
package LaTeX::TikZ::TestX;
- use Any::Moose;
- use Any::Moose 'Util::TypeConstraints' => [ qw/
- coerce
- from
- via
+ use Mouse;
+ use Mouse::Util::TypeConstraints qw<
+ coerce from via
find_type_constraint
register_type_constraint
- / ];
+ >;
has 'id' => (
is => 'ro',
register_type_constraint(
LaTeX::TikZ::Meta::TypeConstraint::Autocoerce->new(
name => 'LaTeX::TikZ::TestX::Autocoerce',
- parent => find_type_constraint(__PACKAGE__),
+ target => find_type_constraint(__PACKAGE__),
mapper => sub {
shift;
my ($last) = $_[0] =~ /::([^:]+)$/;
{
package LaTeX::TikZ::TestY;
- use Any::Moose;
+ use Mouse;
has 'num' => (
is => 'ro',
{
package LaTeX::TikZ::TestZ;
- use Any::Moose;
+ use Mouse;
has 'x' => (
is => 'ro',
{
package LaTeX::TikZ::TestW;
- use Any::Moose;
- use Any::Moose 'Util::TypeConstraints';
+ use Mouse;
+ use Mouse::Util::TypeConstraints;
has 'x' => (
is => 'ro',
);
coerce 'LaTeX::TikZ::TestX::Autocoerce'
- => from __PACKAGE__
+ => from +(__PACKAGE__)
=> via { $_->x };
__PACKAGE__->meta->make_immutable;