From: Vincent Pit Date: Wed, 21 Jul 2010 15:55:45 +0000 (+0200) Subject: Really allow coercing a string into a mod object X-Git-Tag: v0.01~23 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=17bd99ecff97751a8323f7f89a97bacb7cd29ec2;p=perl%2Fmodules%2FLaTeX-TikZ.git Really allow coercing a string into a mod object --- diff --git a/lib/LaTeX/TikZ/Mod.pm b/lib/LaTeX/TikZ/Mod.pm index dbee13d..b5921e9 100644 --- a/lib/LaTeX/TikZ/Mod.pm +++ b/lib/LaTeX/TikZ/Mod.pm @@ -27,7 +27,7 @@ requires qw( coerce 'LaTeX::TikZ::Mod' => from 'Str' - => via { LaTeX::TikZ::Mod::Raw->new($_) }; + => via { LaTeX::TikZ::Mod::Raw->new(content => $_) }; =head1 AUTHOR diff --git a/t/20-mod.t b/t/20-mod.t index 7a68349..b6db376 100644 --- a/t/20-mod.t +++ b/t/20-mod.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 19 + 2 * 21; +use Test::More tests => 20 + 2 * 22; use LaTeX::TikZ; @@ -45,13 +45,23 @@ check $foo, 'one modded raw set', <<'RES'; \draw [color=red] foo ; RES +my $foo2 = eval { + Tikz->raw('foo') + ->mod('->') +}; +is $@, '', 'creating a modded raw set from a string doesn\'t croak'; + +check $foo2, 'one modded raw set from a string', <<'RES'; +\draw [->] foo ; +RES + sub failed_valid { my ($tc) = @_; qr/Validation failed for '\Q$tc\E'/; } eval { - Tikz->raw('fail') + Tikz->raw([ 'fail' ]) ->mod(Tikz->raw('epic')); }; like $@, failed_valid('LaTeX::TikZ::Mod'), 'trying to use a non LTM mod croaks';