From: Vincent Pit Date: Wed, 21 Jul 2010 17:25:56 +0000 (+0200) Subject: Pattern covering tests X-Git-Tag: v0.01~19 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FLaTeX-TikZ.git;a=commitdiff_plain;h=020cd49eae523421e5f50beb2429a818e91b5bfc Pattern covering tests --- diff --git a/t/23-pattern.t b/t/23-pattern.t index d5aa474..5f69bd0 100644 --- a/t/23-pattern.t +++ b/t/23-pattern.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 2 + 4 * 2; +use Test::More tests => 5 + 4 * 5; use LaTeX::TikZ; @@ -68,3 +68,74 @@ check $dots, 'a dot pattern', <<'DECL', <<'BODY'; DECL \draw [fill,pattern=patb] foo ; BODY + +my ($lines_mod) = $lines->mods; +my ($dots_mod) = $dots->mods; + +my $seq = eval { + Tikz->seq( + Tikz->raw('foo') + ->mod($lines_mod) + )->mod($lines_mod); +}; +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}}{ +\pgfsetlinewidth{0.2pt} +\pgfpathmoveto{\pgfqpoint{-0.2pt}{0.1pt}} +\pgfpathlineto{\pgfqpoint{0.3pt}{0.1pt}} +\pgfusepath{stroke} +} +DECL +\draw [fill,pattern=pata] foo ; +BODY + +$seq = eval { + Tikz->seq( + Tikz->raw('foo') + ->mod($lines_mod) + )->mod(Tikz->pattern(class => 'Lines', direction => 'vertical')); +}; +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}}{ +\pgfsetlinewidth{0.2pt} +\pgfpathmoveto{\pgfqpoint{0.1pt}{-0.2pt}} +\pgfpathlineto{\pgfqpoint{0.1pt}{0.3pt}} +\pgfusepath{stroke} +} +\pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{0.3pt}{0.3pt}}{\pgfqpoint{0.2pt}{0.2pt}}{ +\pgfsetlinewidth{0.2pt} +\pgfpathmoveto{\pgfqpoint{-0.2pt}{0.1pt}} +\pgfpathlineto{\pgfqpoint{0.3pt}{0.1pt}} +\pgfusepath{stroke} +} +DECL +\draw [fill,pattern=patc,pattern=pata] foo ; +BODY + +$seq = eval { + Tikz->seq( + Tikz->raw('foo') + ->mod($lines_mod) + )->mod($dots_mod); +}; +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} +\pgfusepath{fill} +} +\pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{0.3pt}{0.3pt}}{\pgfqpoint{0.2pt}{0.2pt}}{ +\pgfsetlinewidth{0.2pt} +\pgfpathmoveto{\pgfqpoint{-0.2pt}{0.1pt}} +\pgfpathlineto{\pgfqpoint{0.3pt}{0.1pt}} +\pgfusepath{stroke} +} +DECL +\draw [fill,pattern=patb,pattern=pata] foo ; +BODY