X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F20-mod.t;h=7a68349c197cc7adffe3869e4a24918693582554;hb=d823d115ca3d3718e078dbb986d2c7eb5750df24;hp=38ab3fe5dcb13b22f1da4ebbe74cafee4c523633;hpb=ad9a80bf0294a4f31f7b0ad765f80a81918221d4;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/t/20-mod.t b/t/20-mod.t index 38ab3fe..7a68349 100644 --- a/t/20-mod.t +++ b/t/20-mod.t @@ -3,12 +3,11 @@ use strict; use warnings; -use Test::More tests => 14 + 2 * 18; +use Test::More tests => 19 + 2 * 21; use LaTeX::TikZ; -use LaTeX::TikZ::Formatter; -my $tikz = LaTeX::TikZ::Formatter->new( +my $tikz = Tikz->formatter( format => '%d', ); @@ -46,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); }; @@ -270,7 +280,7 @@ eval { }; is $@, '', 'creating and adding another width mod doesn\'t croak'; -check $seq, 'mod covering 4', <<'RES'; +check $seq, 'mod covering 5', <<'RES'; \begin{scope} [color=red,raw2] \begin{scope} [line width=4.0pt] \begin{scope} [raw1] @@ -282,3 +292,44 @@ check $seq, 'mod covering 4', <<'RES'; \draw [raw3] baz ; \end{scope} RES + +my ($fred, $fblue) = eval { + map Tikz->fill($_), qw/red blue/; +}; +is $@, '', 'creating two fill mods doesn\'t croak'; + +$seq = eval { + Tikz->seq( + Tikz->raw("foo") + ->mod($fred) + )->mod($fred); +}; +is $@, '', 'creating a structure with two identical fill mods doesn\'t croak'; + +check $seq, 'mod covering 6', <<'RES'; +\draw [fill=red] foo ; +RES + +$seq = eval { + Tikz->seq( + Tikz->raw("foo") + ->mod($fblue) + )->mod($fred); +}; +is $@, '', 'creating a structure with two different fill mods doesn\'t croak'; + +check $seq, 'mod covering 7', <<'RES'; +\draw [fill=red,fill=blue] foo ; +RES + +$seq = eval { + Tikz->seq( + Tikz->raw("foo") + ->mod($red) + )->mod($fred); +}; +is $@, '', 'creating a structure with color and fill mods doesn\'t croak'; + +check $seq, 'mod covering 8', <<'RES'; +\draw [fill=red,color=red] foo ; +RES