=> from 'LaTeX::TikZ::Point'
=> via { $_ };
+coerce 'LaTeX::TikZ::Point::Autocoerce'
+ => from 'Num'
+ => via { LaTeX::TikZ::Point->new(x => $_, y => 0) };
+
+coerce 'LaTeX::TikZ::Point::Autocoerce'
+ => from 'ArrayRef'
+ => via { LaTeX::TikZ::Point->new(x => $_->[0], y => $_->[1]) };
+
__PACKAGE__->meta->make_immutable;
=head1 AUTHOR
use LaTeX::TikZ::Interface point => sub {
shift;
- __PACKAGE__->new(point => $_[0]);
+ __PACKAGE__->new(point => @_ > 1 ? \@_ : $_[0] );
};
__PACKAGE__->meta->make_immutable;
use strict;
use warnings;
-use Test::More tests => 1 + 2 * 1;
+use Test::More tests => 5 + 2 * 5;
use Math::Complex;
check $p, 'a point from a Math::Complex object', <<'RES';
\draw (1cm,2cm) ;
RES
+
+$p = eval {
+ Tikz->point(1-2*i);
+};
+is $@, '', 'creating a point from a Math::Complex constant object doesn\'t croak';
+
+check $p, 'a point from a constant Math::Complex object', <<'RES';
+\draw (1cm,-2cm) ;
+RES
+
+$p = eval {
+ Tikz->point(-7);
+};
+is $@, '', 'creating a point from a numish constant doesn\'t croak';
+
+check $p, 'a point from a numish constant', <<'RES';
+\draw (-7cm,0cm) ;
+RES
+
+$p = eval {
+ Tikz->point(5,-1);
+};
+is $@, '', 'creating a point from two numish constants doesn\'t croak';
+
+check $p, 'a point from two numish constants', <<'RES';
+\draw (5cm,-1cm) ;
+RES
+
+$p = eval {
+ Tikz->point([-3, 2]);
+};
+is $@, '', 'creating a point from an array ref doesn\'t croak';
+
+check $p, 'a point from an array ref', <<'RES';
+\draw (-3cm,2cm) ;
+RES