From: Vincent Pit Date: Sun, 18 Jul 2010 23:06:19 +0000 (+0200) Subject: Make sure Set->mod only accepts mods X-Git-Tag: v0.01~43 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=ab352fc19c13fff9561888d8a4b951073278bd10;p=perl%2Fmodules%2FLaTeX-TikZ.git Make sure Set->mod only accepts mods --- diff --git a/lib/LaTeX/TikZ/Set.pm b/lib/LaTeX/TikZ/Set.pm index 655eb2f..da636a4 100644 --- a/lib/LaTeX/TikZ/Set.pm +++ b/lib/LaTeX/TikZ/Set.pm @@ -44,9 +44,9 @@ my $ltmc_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod::Clip'); sub mod { my $set = shift; - push @{$set->_mods}, - map { $ltm_tc->check($_) ? $_ : $ltm_tc->coerce($_) } - @_; + $ltm_tc->assert_valid($_) for @_; + + push @{$set->_mods}, @_; $set; } diff --git a/t/20-mod.t b/t/20-mod.t index a47106e..50d9db8 100644 --- a/t/20-mod.t +++ b/t/20-mod.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 14 + 2 * 18; +use Test::More tests => 15 + 2 * 18; use LaTeX::TikZ; @@ -45,6 +45,17 @@ check $foo, 'one modded raw set', <<'RES'; \draw [color=red] foo ; RES +sub failed_valid { + my ($tc) = @_; + qr/Validation failed for '\Q$tc\E'/; +} + +eval { + Tikz->raw('fail') + ->mod(Tikz->raw('epic')); +}; +like $@, failed_valid('LaTeX::TikZ::Mod'), 'trying to use a non LTM mod croaks'; + my $width = eval { Tikz->width(25); };