X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F23-pattern.t;h=03703223044679d1ef859b142e54a38a81df1ff2;hb=1ace068a681d0dea45c546bb6509586212adec98;hp=5f69bd0f22290156244f9ba0809d4f4cf6ceabe9;hpb=020cd49eae523421e5f50beb2429a818e91b5bfc;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/t/23-pattern.t b/t/23-pattern.t index 5f69bd0..0370322 100644 --- a/t/23-pattern.t +++ b/t/23-pattern.t @@ -7,19 +7,19 @@ use Test::More tests => 5 + 4 * 5; use LaTeX::TikZ; -my $tikz = Tikz->formatter( +use lib 't/lib'; +use LaTeX::TikZ::TestHelper; + +using Tikz->formatter( format => '%d', ); -sub check { +sub check_patterns { my ($set, $desc, $exp_decl, $exp) = @_; local $Test::Builder::Level = $Test::Builder::Level + 1; - my ($head, $decl, $body) = eval { - $tikz->render(ref $set eq 'ARRAY' ? @$set : $set); - }; - is $@, '', "$desc: no error"; + my ($head, $decl, $body) = check($set, $desc, $exp); is $head->[-1], '\usetikzlibrary{patterns}', "$desc: header"; @@ -27,14 +27,7 @@ sub check { $exp_decl = [ split /\n/, $exp_decl ]; } - unless (ref $exp eq 'ARRAY') { - $exp = [ split /\n/, $exp ]; - } - unshift @$exp, '\begin{tikzpicture}'; - push @$exp, '\end{tikzpicture}'; - is_deeply $decl, $exp_decl, "$desc: declarations"; - is_deeply $body, $exp, "$desc: body"; } my $lines = eval { @@ -43,11 +36,11 @@ my $lines = eval { }; is $@, '', 'creating a line pattern doesn\'t croak'; -check $lines, 'a line pattern', <<'DECL', <<'BODY'; -\pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{0.3pt}{0.3pt}}{\pgfqpoint{0.2pt}{0.2pt}}{ +check_patterns $lines, 'a line pattern', <<'DECL', <<'BODY'; +\pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{ \pgfsetlinewidth{0.2pt} -\pgfpathmoveto{\pgfqpoint{-0.2pt}{0.1pt}} -\pgfpathlineto{\pgfqpoint{0.3pt}{0.1pt}} +\pgfpathmoveto{\pgfqpoint{-0.2pt}{0.8pt}} +\pgfpathlineto{\pgfqpoint{1.8pt}{0.8pt}} \pgfusepath{stroke} } DECL @@ -60,9 +53,9 @@ my $dots = eval { }; is $@, '', 'creating a dot pattern doesn\'t croak'; -check $dots, 'a dot pattern', <<'DECL', <<'BODY'; -\pgfdeclarepatternformonly{patb}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{0.3pt}{0.3pt}}{\pgfqpoint{0.2pt}{0.2pt}}{ -\pgfpathcircle{\pgfqpoint{0.1pt}{0.1pt}}{0.2pt} +check_patterns $dots, 'a dot pattern', <<'DECL', <<'BODY'; +\pgfdeclarepatternformonly{patb}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{ +\pgfpathcircle{\pgfqpoint{0.8pt}{0.8pt}}{0.2pt} \pgfusepath{fill} } DECL @@ -80,11 +73,11 @@ my $seq = eval { }; is $@, '', 'creating a sequence with two identic patterns doesn\'t croak'; -check $seq, 'a sequence with two identic patterns', <<'DECL', <<'BODY'; -\pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{0.3pt}{0.3pt}}{\pgfqpoint{0.2pt}{0.2pt}}{ +check_patterns $seq, 'a sequence with two identic patterns', <<'DECL', <<'BODY'; +\pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{ \pgfsetlinewidth{0.2pt} -\pgfpathmoveto{\pgfqpoint{-0.2pt}{0.1pt}} -\pgfpathlineto{\pgfqpoint{0.3pt}{0.1pt}} +\pgfpathmoveto{\pgfqpoint{-0.2pt}{0.8pt}} +\pgfpathlineto{\pgfqpoint{1.8pt}{0.8pt}} \pgfusepath{stroke} } DECL @@ -100,17 +93,18 @@ $seq = eval { is $@, '', 'creating a sequence with two orthogonal line patterns doesn\'t croak'; -check $seq, 'a sequence with two orthogonal line patterns', <<'DECL', <<'BODY'; -\pgfdeclarepatternformonly{patc}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{0.3pt}{0.3pt}}{\pgfqpoint{0.2pt}{0.2pt}}{ +check_patterns $seq, 'a sequence with two orthogonal line patterns', + <<'DECL', <<'BODY'; +\pgfdeclarepatternformonly{patc}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{ \pgfsetlinewidth{0.2pt} -\pgfpathmoveto{\pgfqpoint{0.1pt}{-0.2pt}} -\pgfpathlineto{\pgfqpoint{0.1pt}{0.3pt}} +\pgfpathmoveto{\pgfqpoint{0.8pt}{-0.2pt}} +\pgfpathlineto{\pgfqpoint{0.8pt}{1.8pt}} \pgfusepath{stroke} } -\pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{0.3pt}{0.3pt}}{\pgfqpoint{0.2pt}{0.2pt}}{ +\pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{ \pgfsetlinewidth{0.2pt} -\pgfpathmoveto{\pgfqpoint{-0.2pt}{0.1pt}} -\pgfpathlineto{\pgfqpoint{0.3pt}{0.1pt}} +\pgfpathmoveto{\pgfqpoint{-0.2pt}{0.8pt}} +\pgfpathlineto{\pgfqpoint{1.8pt}{0.8pt}} \pgfusepath{stroke} } DECL @@ -125,15 +119,16 @@ $seq = eval { }; is $@, '', 'creating a sequence with two different patterns doesn\'t croak'; -check $seq, 'a sequence with two different patterns', <<'DECL', <<'BODY'; -\pgfdeclarepatternformonly{patb}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{0.3pt}{0.3pt}}{\pgfqpoint{0.2pt}{0.2pt}}{ -\pgfpathcircle{\pgfqpoint{0.1pt}{0.1pt}}{0.2pt} +check_patterns $seq, 'a sequence with two different patterns', + <<'DECL', <<'BODY'; +\pgfdeclarepatternformonly{patb}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{ +\pgfpathcircle{\pgfqpoint{0.8pt}{0.8pt}}{0.2pt} \pgfusepath{fill} } -\pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{0.3pt}{0.3pt}}{\pgfqpoint{0.2pt}{0.2pt}}{ +\pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{ \pgfsetlinewidth{0.2pt} -\pgfpathmoveto{\pgfqpoint{-0.2pt}{0.1pt}} -\pgfpathlineto{\pgfqpoint{0.3pt}{0.1pt}} +\pgfpathmoveto{\pgfqpoint{-0.2pt}{0.8pt}} +\pgfpathlineto{\pgfqpoint{1.8pt}{0.8pt}} \pgfusepath{stroke} } DECL