6 use Test::More tests => 11 + 2 * 15;
9 use LaTeX::TikZ::Formatter;
11 my $tikz = LaTeX::TikZ::Formatter->new(
16 my ($set, $desc, $exp) = @_;
18 local $Test::Builder::Level = $Test::Builder::Level + 1;
20 my ($head, $decl, $body) = eval {
21 $tikz->render(ref $set eq 'ARRAY' ? @$set : $set);
23 is $@, '', "$desc: no error";
25 unless (ref $exp eq 'ARRAY') {
26 $exp = [ split /\n/, $exp ];
28 unshift @$exp, '\begin{tikzpicture}';
29 push @$exp, '\end{tikzpicture}';
31 is_deeply $body, $exp, $desc;
37 is $@, '', 'creating a color mod doesn\'t croak';
43 is $@, '', 'creating a modded raw set doesn\'t croak';
45 check $foo, 'one modded raw set', <<'RES';
46 \draw [color=red] foo ;
52 is $@, '', 'creating a width mod doesn\'t croak';
57 is $@, '', 'adding another mod doesn\'t croak';
59 check $foo, 'one double modded raw set', <<'RES';
60 \draw [color=red,line width=4.0pt] foo ;
66 is $@, '', 're-adding an previously set mod doesn\'t croak';
68 check $foo, 'one triple modded raw set (with duplicates)', <<'RES';
69 \draw [color=red,line width=4.0pt] foo ;
72 my $bar = Tikz->raw('bar');
76 is $@, '', 'appending to a modded set doesn\'t croak';
78 check $foo, 'one triple modded sequence of raw sets (with duplicates)', <<'RES';
79 \begin{scope} [color=red,line width=4.0pt]
89 is $@, '', 'creating another colored raw set doesn\'t croak';
91 check [ $foo, $baz ], 'mods folding 1', <<'RES';
92 \begin{scope} [color=red]
93 \begin{scope} [line width=4.0pt]
101 check [ $baz, $foo ], 'mods folding 2', <<'RES';
102 \begin{scope} [color=red]
104 \begin{scope} [line width=4.0pt]
115 is $@, '', 'creating another raw set with modded width doesn\'t croak';
117 check [ $foo, $baz, $qux ], 'mods folding 3', <<'RES';
118 \begin{scope} [color=red]
119 \begin{scope} [line width=4.0pt]
125 \draw [line width=4.0pt] qux ;
128 check [ $foo, $qux, $baz ], 'mods folding 4', <<'RES';
129 \begin{scope} [line width=4.0pt]
130 \begin{scope} [color=red]
136 \draw [color=red] baz ;
139 check [ $baz, $foo, $qux ], 'mods folding 5', <<'RES';
140 \begin{scope} [color=red]
142 \begin{scope} [line width=4.0pt]
147 \draw [line width=4.0pt] qux ;
150 check [ $baz, $qux, $foo ], 'mods folding 6', <<'RES';
151 \draw [color=red] baz ;
152 \draw [line width=4.0pt] qux ;
153 \begin{scope} [color=red,line width=4.0pt]
159 check [ $qux, $foo, $baz ], 'mods folding 7', <<'RES';
160 \begin{scope} [line width=4.0pt]
162 \begin{scope} [color=red]
167 \draw [color=red] baz ;
170 check [ $qux, $baz, $foo ], 'mods folding 8', <<'RES';
171 \draw [line width=4.0pt] qux ;
172 \draw [color=red] baz ;
173 \begin{scope} [color=red,line width=4.0pt]
180 Tikz->seq($foo, $qux, $baz)
183 is $@, '', 'creating a modded sequence set doesn\'t croak';
185 check $seq, 'mod covering 1', <<'RES';
186 \begin{scope} [color=red]
187 \begin{scope} [line width=4.0pt]
197 Tikz->seq($seq, $qux)
198 ->mod(Tikz->color('blue'));
200 is $@, '', 'creating another modded sequence set doesn\'t croak';
202 check $seq2, 'mod covering 2', <<'RES';
203 \begin{scope} [color=blue]
204 \begin{scope} [color=red]
205 \begin{scope} [line width=4.0pt]
212 \draw [line width=4.0pt] qux ;
217 $foo->mod(Tikz->raw_mod('raw1'));
218 $seq->mod(Tikz->raw_mod('raw2'));
220 is $@, '', 'creating and adding raw mods doesn\'t croak';
222 check $seq, 'mod covering 3', <<'RES';
223 \begin{scope} [color=red,raw2]
224 \begin{scope} [line width=4.0pt]