X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F20-mod.t;h=a6c44651b6493757a1921df979477eb5d0b9695c;hb=cb3b916e0590c6a0b70b60f30304921385462faa;hp=724fbe96c0a0f4cc3aeba2c345e7222fd58369ff;hpb=e0a78fcfb70f3e83bafc4a7ca16731229d6e3e7c;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/t/20-mod.t b/t/20-mod.t index 724fbe9..a6c4465 100644 --- a/t/20-mod.t +++ b/t/20-mod.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 8 + 2 * 12; +use Test::More tests => 13 + 2 * 17; use LaTeX::TikZ; use LaTeX::TikZ::Formatter; @@ -70,12 +70,15 @@ check $foo, 'one triple modded raw set (with duplicates)', <<'RES'; RES my $bar = Tikz->raw('bar'); -eval { - $foo->add($bar); +$foo = eval { + Tikz->seq( + Tikz->raw('foo'), + $bar + )->mod($red, $width); }; -is $@, '', 'appending to a modded set doesn\'t croak'; +is $@, '', 'setting two mods in a row doesn\'t croak'; -check $foo, 'one triple modded sequence of raw sets (with duplicates)', <<'RES'; +check $foo, 'one triple modded sequence of raw sets', <<'RES'; \begin{scope} [color=red,line width=4.0pt] \draw foo ; \draw bar ; @@ -175,3 +178,95 @@ check [ $qux, $baz, $foo ], 'mods folding 8', <<'RES'; \draw bar ; \end{scope} RES + +my $seq = eval { + Tikz->seq($foo, $qux, $baz) + ->mod($red); +}; +is $@, '', 'creating a modded sequence set doesn\'t croak'; + +check $seq, 'mod covering 1', <<'RES'; +\begin{scope} [color=red] +\begin{scope} [line width=4.0pt] +\draw foo ; +\draw bar ; +\draw qux ; +\end{scope} +\draw baz ; +\end{scope} +RES + +my $seq2 = eval { + Tikz->seq($seq, $qux) + ->mod(Tikz->color('blue')); +}; +is $@, '', 'creating another modded sequence set doesn\'t croak'; + +check $seq2, 'mod covering 2', <<'RES'; +\begin{scope} [color=blue] +\begin{scope} [color=red] +\begin{scope} [line width=4.0pt] +\draw foo ; +\draw bar ; +\draw qux ; +\end{scope} +\draw baz ; +\end{scope} +\draw [line width=4.0pt] qux ; +\end{scope} +RES + +eval { + $foo->mod(Tikz->raw_mod('raw1')); + $seq->mod(Tikz->raw_mod('raw2')); +}; +is $@, '', 'creating and adding raw mods doesn\'t croak'; + +check $seq, 'mod covering 3', <<'RES'; +\begin{scope} [color=red,raw2] +\begin{scope} [line width=4.0pt] +\begin{scope} [raw1] +\draw foo ; +\draw bar ; +\end{scope} +\draw qux ; +\end{scope} +\draw baz ; +\end{scope} +RES + +eval { + $baz->mod(Tikz->raw_mod($_)) for qw/raw2 raw3/; +}; +is $@, '', 'creating and adding another raw mod doesn\'t croak'; + +check $seq, 'mod covering 4', <<'RES'; +\begin{scope} [color=red,raw2] +\begin{scope} [line width=4.0pt] +\begin{scope} [raw1] +\draw foo ; +\draw bar ; +\end{scope} +\draw qux ; +\end{scope} +\draw [raw3] baz ; +\end{scope} +RES + +eval { + $bar->mod(Tikz->width(50)); +}; +is $@, '', 'creating and adding another width mod doesn\'t croak'; + +check $seq, 'mod covering 4', <<'RES'; +\begin{scope} [color=red,raw2] +\begin{scope} [line width=4.0pt] +\begin{scope} [raw1] +\draw foo ; +\draw [line width=8.0pt] bar ; +\end{scope} +\draw qux ; +\end{scope} +\draw [raw3] baz ; +\end{scope} +RES