From: Vincent Pit Date: Wed, 21 Jul 2010 13:09:35 +0000 (+0200) Subject: Allow a bare Tikz->point for 0 X-Git-Tag: v0.01~29 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=30f5ed56f488e23570b3ed768de0614c99dcd70e;p=perl%2Fmodules%2FLaTeX-TikZ.git Allow a bare Tikz->point for 0 --- diff --git a/lib/LaTeX/TikZ/Set/Point.pm b/lib/LaTeX/TikZ/Set/Point.pm index 409db5f..868fd5b 100644 --- a/lib/LaTeX/TikZ/Set/Point.pm +++ b/lib/LaTeX/TikZ/Set/Point.pm @@ -48,7 +48,10 @@ sub path { use LaTeX::TikZ::Interface point => sub { shift; - __PACKAGE__->new(point => @_ > 1 ? \@_ : $_[0] ); + my $point = @_ == 0 ? 0 + : @_ == 1 ? $_[0] + : \@_; + __PACKAGE__->new(point => $point); }; __PACKAGE__->meta->make_immutable; diff --git a/t/11-point.t b/t/11-point.t index 9e73f15..7bd64d6 100644 --- a/t/11-point.t +++ b/t/11-point.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 5 + 2 * 5; +use Test::More tests => 6 + 2 * 6; use Math::Complex; @@ -52,6 +52,15 @@ check $p, 'a point from a constant Math::Complex object', <<'RES'; \draw (1cm,-2cm) ; RES +$p = eval { + Tikz->point; +}; +is $@, '', 'creating a point from nothing doesn\'t croak'; + +check $p, 'a point from nothing', <<'RES'; +\draw (0cm,0cm) ; +RES + $p = eval { Tikz->point(-7); };