From: Vincent Pit Date: Wed, 21 Jul 2010 15:47:16 +0000 (+0200) Subject: Always call ->assert_valid after ->coerce X-Git-Tag: v0.01~24 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=a2871e9a7be49f59dab5d64afab543404b1e13f4;p=perl%2Fmodules%2FLaTeX-TikZ.git Always call ->assert_valid after ->coerce --- diff --git a/lib/LaTeX/TikZ/Scope.pm b/lib/LaTeX/TikZ/Scope.pm index c048a1c..3686beb 100644 --- a/lib/LaTeX/TikZ/Scope.pm +++ b/lib/LaTeX/TikZ/Scope.pm @@ -54,7 +54,8 @@ sub mod { my $cache = $scope->_mods_cache; for (@_) { - my $mod = $ltmf_tc->check($_) ? $_ : $ltmf_tc->coerce($_); + my $mod = $ltmf_tc->coerce($_); + $ltmf_tc->assert_valid($mod); my $tag = $mod->tag; next if exists $cache->{$tag}; $cache->{$tag} = $mod; diff --git a/lib/LaTeX/TikZ/Set.pm b/lib/LaTeX/TikZ/Set.pm index 78b53ce..d4f67b6 100644 --- a/lib/LaTeX/TikZ/Set.pm +++ b/lib/LaTeX/TikZ/Set.pm @@ -44,9 +44,10 @@ my $ltmc_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod::Clip'); sub mod { my $set = shift; - $ltm_tc->assert_valid($_) for @_; + my @mods = map $ltm_tc->coerce($_), @_; + $ltm_tc->assert_valid($_) for @mods; - push @{$set->_mods}, @_; + push @{$set->_mods}, @mods; $set; } diff --git a/lib/LaTeX/TikZ/Set/Arc.pm b/lib/LaTeX/TikZ/Set/Arc.pm index 3ac58e0..3bbe83d 100644 --- a/lib/LaTeX/TikZ/Set/Arc.pm +++ b/lib/LaTeX/TikZ/Set/Arc.pm @@ -37,6 +37,7 @@ use LaTeX::TikZ::Interface arc => sub { for ($a, $b, $c) { my $p = $ltp_tc->coerce($_); + $ltp_tc->assert_valid($p); $_ = Math::Complex->make($p->x, $p->y); } diff --git a/lib/LaTeX/TikZ/Set/Rectangle.pm b/lib/LaTeX/TikZ/Set/Rectangle.pm index 08cba5a..8e585bc 100644 --- a/lib/LaTeX/TikZ/Set/Rectangle.pm +++ b/lib/LaTeX/TikZ/Set/Rectangle.pm @@ -72,7 +72,7 @@ Attributes 'width' and 'height' are required when 'to' was not given MSG $args{from} = $tc1->coerce($args{from}); $meta->find_attribute_by_name($_)->type_constraint->assert_valid($args{$_}) - for qw/width height/; + for qw/from width height/; my $p = $args{from}->point; $args{to} = LaTeX::TikZ::Point->new( x => $p->x + $args{width},