6 use Test::More tests => 9 + 2 * 6;
9 use LaTeX::TikZ::Formatter;
11 my $tikz = LaTeX::TikZ::Formatter->new(
16 my ($set, $desc, $exp) = @_;
18 my ($head, $decl, $body) = eval {
19 $tikz->render(ref $set eq 'ARRAY' ? @$set : $set);
21 is $@, '', "$desc: no error";
23 unless (ref $exp eq 'ARRAY') {
24 $exp = [ split /\n/, $exp ];
26 unshift @$exp, '\begin{tikzpicture}';
27 push @$exp, '\end{tikzpicture}';
29 is_deeply $body, $exp, $desc;
35 is $@, '', 'creating a raw set doesn\'t croak';
37 check $foo, 'one raw set', <<'RES';
42 Tikz->seq($foo, $foo);
44 is $@, '', 'creating a 2-sequence doesn\'t croak';
46 check $seq2, 'two identical raw sets', <<'RES';
54 is $@, '', 'creating another raw set doesn\'t croak';
57 Tikz->seq($foo, $bar);
59 is $@, '', 'creating another 2-sequence doesn\'t croak';
61 check $seq2, 'two different raw sets', <<'RES';
67 Tikz->seq($bar, $seq2, $foo);
69 is $@, '', 'creating a complex sequence doesn\'t croak';
71 check $seq3, 'two different raw sets and a sequence', <<'RES';
81 is $@, '', 'creating yet another raw set doesn\'t croak';
86 like $@, qr/Can't locate object method "add"/,
87 'adding something to a raw set croaks';
90 $seq2->add($baz, $baz);
92 is $@, '', 'adding something to a sequence set doesn\'t croak';
94 check $seq3, 'two different raw sets and an extended sequence', <<'RES';
104 Tikz->path($foo, $bar, $baz);
106 is $@, '', 'creating a path set doesn\'t croak';
108 check [ $path, $path ], 'two identical path sets', <<'RES';