6 use Test::More tests => 23 + 2 * 24;
11 use LaTeX::TikZ::TestHelper;
13 using Tikz->formatter(
20 is $@, '', 'creating a color mod doesn\'t croak';
26 is $@, '', 'creating a modded raw set doesn\'t croak';
28 check $foo, 'one modded raw set', <<'RES';
29 \draw [color=red] foo ;
36 is $@, '', 'creating a modded raw set from a string doesn\'t croak';
38 check $foo2, 'one modded raw set from a string', <<'RES';
44 qr/Validation failed for '\Q$tc\E'/;
49 ->mod(Tikz->raw('epic'));
51 like $@, failed_valid('LaTeX::TikZ::Mod'), 'trying to use a non LTM mod croaks';
56 is $@, '', 'creating a scale mod doesn\'t croak';
62 is $@, '', 'applying a scale mod doesn\'t croak';
64 check $foo2, 'a raw set with a scale mod', <<'RES';
65 \draw [scale=2.000] foo ;
72 )->mod(Tikz->scale(4));
74 is $@, '', 'applying two scale mods doesn\'t croak';
76 check $foo2, 'a union of a raw set with two scale mods', <<'RES';
77 \draw [scale=4.000] foo ;
83 is $@, '', 'creating a width mod doesn\'t croak';
88 is $@, '', 'adding another mod doesn\'t croak';
90 check $foo, 'one double modded raw set', <<'RES';
91 \draw [color=red,line width=4.0pt] foo ;
97 is $@, '', 're-adding an previously set mod doesn\'t croak';
99 check $foo, 'one triple modded raw set (with duplicates)', <<'RES';
100 \draw [color=red,line width=4.0pt] foo ;
103 my $bar = Tikz->raw('bar');
108 )->mod($red, $width);
110 is $@, '', 'setting two mods in a row doesn\'t croak';
112 check $foo, 'one triple modded sequence of raw sets', <<'RES';
113 \begin{scope} [color=red,line width=4.0pt]
121 Tikz->seq(Tikz->raw("foo"))
125 is $@, '', 'creating nested modded sequences doesn\'t croak';
127 check $nested, 'nested modded sequences', <<'RES';
128 \draw [line width=4.0pt,color=red] foo ;
135 is $@, '', 'creating another colored raw set doesn\'t croak';
137 check Tikz->seq($foo, $baz), 'mods folding 1', <<'RES';
138 \begin{scope} [color=red]
139 \begin{scope} [line width=4.0pt]
147 check Tikz->seq($baz, $foo), 'mods folding 2', <<'RES';
148 \begin{scope} [color=red]
150 \begin{scope} [line width=4.0pt]
161 is $@, '', 'creating another raw set with modded width doesn\'t croak';
163 check Tikz->seq($foo, $baz, $qux), 'mods folding 3', <<'RES';
164 \begin{scope} [color=red]
165 \begin{scope} [line width=4.0pt]
171 \draw [line width=4.0pt] qux ;
174 check Tikz->seq($foo, $qux, $baz), 'mods folding 4', <<'RES';
175 \begin{scope} [line width=4.0pt]
176 \begin{scope} [color=red]
182 \draw [color=red] baz ;
185 check Tikz->seq($baz, $foo, $qux), 'mods folding 5', <<'RES';
186 \begin{scope} [color=red]
188 \begin{scope} [line width=4.0pt]
193 \draw [line width=4.0pt] qux ;
196 check Tikz->seq($baz, $qux, $foo), 'mods folding 6', <<'RES';
197 \draw [color=red] baz ;
198 \draw [line width=4.0pt] qux ;
199 \begin{scope} [color=red,line width=4.0pt]
205 check Tikz->seq($qux, $foo, $baz), 'mods folding 7', <<'RES';
206 \begin{scope} [line width=4.0pt]
208 \begin{scope} [color=red]
213 \draw [color=red] baz ;
216 check Tikz->seq($qux, $baz, $foo), 'mods folding 8', <<'RES';
217 \draw [line width=4.0pt] qux ;
218 \draw [color=red] baz ;
219 \begin{scope} [color=red,line width=4.0pt]
226 Tikz->seq($foo, $qux, $baz)
229 is $@, '', 'creating a modded sequence set doesn\'t croak';
231 check $seq, 'mod covering 1', <<'RES';
232 \begin{scope} [color=red]
233 \begin{scope} [line width=4.0pt]
243 Tikz->seq($seq, $qux)
244 ->mod(Tikz->color('blue'));
246 is $@, '', 'creating another modded sequence set doesn\'t croak';
248 check $seq2, 'mod covering 2', <<'RES';
249 \begin{scope} [color=blue]
250 \begin{scope} [color=red]
251 \begin{scope} [line width=4.0pt]
258 \draw [line width=4.0pt] qux ;
263 $foo->mod(Tikz->raw_mod('raw1'));
264 $seq->mod(Tikz->raw_mod('raw2'));
266 is $@, '', 'creating and adding raw mods doesn\'t croak';
268 check $seq, 'mod covering 3', <<'RES';
269 \begin{scope} [color=red,raw2]
270 \begin{scope} [line width=4.0pt]
282 $baz->mod(Tikz->raw_mod($_)) for qw<raw2 raw3>;
284 is $@, '', 'creating and adding another raw mod doesn\'t croak';
286 check $seq, 'mod covering 4', <<'RES';
287 \begin{scope} [color=red,raw2]
288 \begin{scope} [line width=4.0pt]
295 \draw [raw2,raw3] baz ;
300 $bar->mod(Tikz->width(50));
302 is $@, '', 'creating and adding another width mod doesn\'t croak';
304 check $seq, 'mod covering 5', <<'RES';
305 \begin{scope} [color=red,raw2]
306 \begin{scope} [line width=4.0pt]
309 \draw [line width=8.0pt] bar ;
313 \draw [raw2,raw3] baz ;
317 my ($fred, $fblue) = eval {
318 map Tikz->fill($_), qw<red blue>;
320 is $@, '', 'creating two fill mods doesn\'t croak';
328 is $@, '', 'creating a structure with two identical fill mods doesn\'t croak';
330 check $seq, 'mod covering 6', <<'RES';
331 \draw [fill=red] foo ;
340 is $@, '', 'creating a structure with two different fill mods doesn\'t croak';
342 check $seq, 'mod covering 7', <<'RES';
343 \draw [fill=red,fill=blue] foo ;
352 is $@, '', 'creating a structure with color and fill mods doesn\'t croak';
354 check $seq, 'mod covering 8', <<'RES';
355 \draw [fill=red,color=red] foo ;