6 use Test::More tests => 2 + 4 * 2;
10 my $tikz = Tikz->formatter(
15 my ($set, $desc, $exp_decl, $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 is $head->[-1], '\usetikzlibrary{patterns}', "$desc: header";
26 unless (ref $exp_decl eq 'ARRAY') {
27 $exp_decl = [ split /\n/, $exp_decl ];
30 unless (ref $exp eq 'ARRAY') {
31 $exp = [ split /\n/, $exp ];
33 unshift @$exp, '\begin{tikzpicture}';
34 push @$exp, '\end{tikzpicture}';
36 is_deeply $decl, $exp_decl, "$desc: declarations";
37 is_deeply $body, $exp, "$desc: body";
42 ->mod(Tikz->pattern(class => 'Lines'));
44 is $@, '', 'creating a line pattern doesn\'t croak';
46 check $lines, 'a line pattern', <<'DECL', <<'BODY';
47 \pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{0.3pt}{0.3pt}}{\pgfqpoint{0.2pt}{0.2pt}}{
48 \pgfsetlinewidth{0.2pt}
49 \pgfpathmoveto{\pgfqpoint{-0.2pt}{0.1pt}}
50 \pgfpathlineto{\pgfqpoint{0.3pt}{0.1pt}}
54 \draw [fill,pattern=pata] foo ;
59 ->mod(Tikz->pattern(class => 'Dots'));
61 is $@, '', 'creating a dot pattern doesn\'t croak';
63 check $dots, 'a dot pattern', <<'DECL', <<'BODY';
64 \pgfdeclarepatternformonly{patb}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{0.3pt}{0.3pt}}{\pgfqpoint{0.2pt}{0.2pt}}{
65 \pgfpathcircle{\pgfqpoint{0.1pt}{0.1pt}}{0.2pt}
69 \draw [fill,pattern=patb] foo ;