6 use Test::More tests => 29 + 2 * 21;
11 use LaTeX::TikZ::TestHelper;
13 using Tikz->formatter(
20 is $@, '', 'creating a raw set doesn\'t croak';
22 check $foo, 'one raw set', <<'RES';
27 Tikz->seq($foo, $foo);
29 is $@, '', 'creating a 2-sequence doesn\'t croak';
31 check $seq2, 'two identical raw sets', <<'RES';
39 is $@, '', 'creating another raw set doesn\'t croak';
42 Tikz->seq($foo, $bar);
44 is $@, '', 'creating another 2-sequence doesn\'t croak';
46 check $seq2, 'two different raw sets', <<'RES';
52 Tikz->seq($bar, $seq2, $foo);
54 is $@, '', 'creating a complex sequence doesn\'t croak';
56 check $seq3, 'two different raw sets and a sequence', <<'RES';
66 is $@, '', 'creating yet another raw set doesn\'t croak';
71 like $@, qr/Can't locate object method "add"/,
72 'adding something to a raw set croaks';
75 $seq2->add($baz, $baz);
77 is $@, '', 'adding something to a sequence set doesn\'t croak';
79 check $seq3, 'two different raw sets and an extended sequence', <<'RES';
91 is $@, '', 'creating an empty sequence doesn\'t croak';
93 check $seq4, 'an empty sequence', '';
98 is $@, '', 'creating a sequence that contains an empty sequence doesn\'t croak';
100 check $seq4, 'a sequence that contains an empty sequence', '';
103 Tikz->seq($foo, Tikz->seq);
106 'creating a sequence that contains a set and an empty sequence doesn\'t croak';
108 check $seq4, 'a sequence that contains a set and an empty sequence', <<'RES';
113 Tikz->seq(Tikz->seq, $foo);
116 'creating a sequence that contains an empty sequence and a set doesn\'t croak';
118 check $seq4, 'a sequence that contains an empty sequence and a set', <<'RES';
123 Tikz->seq($foo, $bar, Tikz->seq);
126 'creating a sequence that contains 2 sets and an empty sequence doesn\'t croak';
128 check $seq4, 'a sequence that contains 2 sets and an empty sequence', <<'RES';
134 Tikz->seq($foo, Tikz->seq, $bar);
136 is $@, '', 'creating a sequence that contains a set, an empty sequence, a set doesn\'t croak';
138 check $seq4, 'a sequence that contains a set, an empty sequence, a set',<<'RES';
144 Tikz->seq(Tikz->seq, $foo, $bar);
147 'creating a sequence that contains an empty sequence and 2 sets';
149 check $seq4, 'a sequence that contains an empty sequence and 2 sets', <<'RES';
156 qr/Validation failed for '\Q$tc\E'/;
160 Tikz->union($foo, $seq2);
162 like $@, failed_valid('Maybe[ArrayRef[LaTeX::TikZ::Set::Path]]'),
163 'creating an union that contains a sequence croaks';
166 Tikz->union($foo, $bar, $baz);
168 is $@, '', 'creating an union set doesn\'t croak';
170 check $union, 'one union set', <<'RES';
177 is $@, '', 'adding something to a union set doesn\'t croak';
179 check Tikz->seq($union, $union), 'two identical union sets', <<'RES';
180 \draw foo bar baz foo ;
181 \draw foo bar baz foo ;
187 like $@, failed_valid('LaTeX::TikZ::Set::Path'),
188 'adding a sequence to a union croaks';
191 Tikz->join('--' => $foo, $bar, $baz);
193 is $@, '', 'creating an chain set joined with a string doesn\'t croak';
195 check $join, 'one chain set joined with a string', <<'RES';
196 \draw foo -- bar -- baz ;
202 is $@, '', 'adding a set to a chain set joined with a string doesn\'t croak';
204 check $join, 'one appended chain set joined with a string', <<'RES';
205 \draw foo -- bar -- baz -- foo ;
209 Tikz->join(sub { ' ' } => $foo, $bar, $baz);
211 is $@, '', 'creating an chain set joined with a coderef doesn\'t croak';
213 check $join, 'one chain set joined with a string', <<'RES';
220 is $@, '', 'adding a set to a chain set joined with a coderef doesn\'t croak';
222 check $join, 'one appended chain set joined with a coderef', <<'RES';
223 \draw foo bar baz foo ;
227 Tikz->join([ '', '..', '--' ] => $foo, $bar, $baz);
229 is $@, '', 'creating an chain set joined with an arrayref doesn\'t croak';
231 check $join, 'one chain set joined with a string', <<'RES';
232 \draw foo bar .. baz ;
238 is $@, '', 'adding a set to a chain set joined with an arrayref doesn\'t croak';
240 check $join, 'one appended chain set joined with an arrayref', <<'RES';
241 \draw foo bar .. baz -- foo ;
248 'adding too many sets to a chain set joined with an arrayref doesn\'t croak';
251 using()->render($join);
253 like $@, qr/^Invalid connector/,
254 'adding too many sets to a chain set joined with an arrayref croaks';
257 Tikz->chain($foo => '--' => $bar => '->' => $baz);
259 is $@, '', 'creating an chain set with chain doesn\'t croak';
261 check $chain, 'one chain set from chain', <<'RES';
262 \draw foo -- bar -> baz ;
266 Tikz->chain($foo, '--', $bar, '--');
268 like $@, qr/^The 'chain' command expects an odd number of arguments/,
269 'creating an union that contains a sequence croaks';