X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F10-set.t;h=f21f587578d972afa6e00e4a27f2ada043b80d16;hb=9eaa7c633f6b14fe72e7a6b479bd198c93c7d8ff;hp=029fccdd83df223520ced6af1f7972f5375645f4;hpb=263a93f34deb0f2e87e89d6186361c7232b61c04;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/t/10-set.t b/t/10-set.t index 029fccd..f21f587 100644 --- a/t/10-set.t +++ b/t/10-set.t @@ -3,7 +3,7 @@ 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; @@ -15,6 +15,8 @@ my $tikz = LaTeX::TikZ::Formatter->new( 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 +102,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 [ $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';