X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F10-set.t;h=69008aed5d948e3ed2cb011a2e6202bdf7a22c98;hb=6ad93fc8c0660b952c41f0d435683ecb5fe9102a;hp=029fccdd83df223520ced6af1f7972f5375645f4;hpb=263a93f34deb0f2e87e89d6186361c7232b61c04;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/t/10-set.t b/t/10-set.t index 029fccd..69008ae 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; @@ -100,12 +100,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';