6 use Test::More tests => 2 + 2 * 10;
10 my $tikz = Tikz->formatter(
15 my ($set, $desc, $exp) = @_;
17 local $Test::Builder::Level = $Test::Builder::Level + 1;
19 my ($head, $decl, $body) = eval {
20 $tikz->render(ref $set eq 'ARRAY' ? @$set : $set);
22 is $@, '', "$desc: no error";
24 unless (ref $exp eq 'ARRAY') {
25 $exp = [ split /\n/, $exp ];
27 unshift @$exp, '\begin{tikzpicture}';
28 push @$exp, '\end{tikzpicture}';
30 is_deeply $body, $exp, $desc;
33 my $clip1 = Tikz->raw('clip1');
34 my $clip2 = Tikz->raw('clip2');
40 is $@, '', 'creating a clipping a raw path with ->clip doesn\'t croak';
42 check $foo, 'one clipped raw set', <<'RES';
51 ->mod(Tikz->clip(Tikz->raw('clip1')));
53 is $@, '', 'creating a clipping a raw path with ->mod doesn\'t croak';
55 check $bar, 'another clipped raw set', <<'RES';
62 my $seq = Tikz->seq($foo, $bar);
64 check $seq, 'mods folding with clips 1', <<'RES';
72 my $baz = Tikz->raw('baz')
75 check Tikz->seq($seq, $baz), 'mods folding with clips 2', <<'RES';
87 check Tikz->seq($baz, $seq), 'mods folding with clips 3', <<'RES';
99 my $seq2 = Tikz->seq($seq, $baz)
102 check $seq2, 'mods folding with clips 4', <<'RES';
114 $seq2 = Tikz->seq($seq, $baz)
117 check $seq2, 'mods folding with clips 5', <<'RES';
131 check $seq2, 'mods folding with clips 6', <<'RES';
143 $seq2->mod(Tikz->color('red'));
145 check $seq2, 'mods folding with clips 7', <<'RES';
146 \begin{scope} [color=red]
158 $seq->layer('bottom');
160 check $seq2, 'mods folding with clips and layers', <<'RES';
161 \begin{pgfonlayer}{top}
162 \begin{scope} [color=red]
166 \begin{pgfonlayer}{bottom}
167 \begin{scope} [color=red]