X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F10-set.t;h=190846c6972956359b799d9f0db65f28fcf7b206;hb=ee0f9123624eb8e48675f80303ed436b9a94e348;hp=029fccdd83df223520ced6af1f7972f5375645f4;hpb=263a93f34deb0f2e87e89d6186361c7232b61c04;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/t/10-set.t b/t/10-set.t index 029fccd..190846c 100644 --- a/t/10-set.t +++ b/t/10-set.t @@ -3,18 +3,19 @@ use strict; use warnings; -use Test::More tests => 9 + 2 * 6; +use Test::More tests => 12 + 2 * 7; use LaTeX::TikZ; -use LaTeX::TikZ::Formatter; -my $tikz = LaTeX::TikZ::Formatter->new( +my $tikz = Tikz->formatter( format => '%d', ); sub check { my ($set, $desc, $exp) = @_; + local $Test::Builder::Level = $Test::Builder::Level + 1; + my ($head, $decl, $body) = eval { $tikz->render(ref $set eq 'ARRAY' ? @$set : $set); }; @@ -100,12 +101,40 @@ check $seq3, 'two different raw sets and an extended sequence', <<'RES'; \draw foo ; RES +sub failed_valid { + my ($tc) = @_; + qr/Validation failed for '\Q$tc\E'/; +} + +my $err_path = qr/does not pass the type constraint because: Validation failed for 'Maybe\[ArrayRef\[LaTeX::TikZ::Set::Path::Elements\]\]/; + +eval { + Tikz->path($foo, $seq2); +}; +like $@, failed_valid('Maybe[ArrayRef[LaTeX::TikZ::Set::Path::Elements]]'), + 'creating a path that contains a sequence croaks'; + my $path = eval { Tikz->path($foo, $bar, $baz); }; is $@, '', 'creating a path set doesn\'t croak'; -check [ $path, $path ], 'two identical path sets', <<'RES'; -\draw foo bar baz ; +check $path, 'one path set', <<'RES'; \draw foo bar baz ; RES + +eval { + $path->add($foo); +}; +is $@, '', 'adding something to a path set doesn\'t croak'; + +check Tikz->seq($path, $path), 'two identical path sets', <<'RES'; +\draw foo bar baz foo ; +\draw foo bar baz foo ; +RES + +eval { + $path->add($seq2); +}; +like $@, failed_valid('LaTeX::TikZ::Set::Path::Elements'), + 'adding a sequence to a path croaks';