]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - t/20-mod.t
Factor the check() test function in an helper test module
[perl/modules/LaTeX-TikZ.git] / t / 20-mod.t
index b6db3769568134abaec198c40d35a6b417b53469..ae9cc77c6709ed5b09e540597ec8c2865d6458ef 100644 (file)
@@ -7,29 +7,13 @@ use Test::More tests => 20 + 2 * 22;
 
 use LaTeX::TikZ;
 
-my $tikz = Tikz->formatter(
+use lib 't/lib';
+use LaTeX::TikZ::TestHelper;
+
+using 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);
- };
- is $@, '', "$desc: no error";
-
- unless (ref $exp eq 'ARRAY') {
-  $exp = [ split /\n/, $exp ];
- }
- unshift @$exp, '\begin{tikzpicture}';
- push    @$exp, '\end{tikzpicture}';
-
- is_deeply $body, $exp, $desc;
-}
-
 my $red = eval {
  Tikz->color('red');
 };
@@ -123,7 +107,7 @@ my $baz = eval {
 };
 is $@, '', 'creating another colored raw set doesn\'t croak';
 
-check [ $foo, $baz ], 'mods folding 1', <<'RES';
+check Tikz->seq($foo, $baz), 'mods folding 1', <<'RES';
 \begin{scope} [color=red]
 \begin{scope} [line width=4.0pt]
 \draw foo ;
@@ -133,7 +117,7 @@ check [ $foo, $baz ], 'mods folding 1', <<'RES';
 \end{scope}
 RES
 
-check [ $baz, $foo ], 'mods folding 2', <<'RES';
+check Tikz->seq($baz, $foo), 'mods folding 2', <<'RES';
 \begin{scope} [color=red]
 \draw baz ;
 \begin{scope} [line width=4.0pt]
@@ -149,7 +133,7 @@ my $qux = eval {
 };
 is $@, '', 'creating another raw set with modded width doesn\'t croak';
 
-check [ $foo, $baz, $qux ], 'mods folding 3', <<'RES';
+check Tikz->seq($foo, $baz, $qux), 'mods folding 3', <<'RES';
 \begin{scope} [color=red]
 \begin{scope} [line width=4.0pt]
 \draw foo ;
@@ -160,7 +144,7 @@ check [ $foo, $baz, $qux ], 'mods folding 3', <<'RES';
 \draw [line width=4.0pt] qux ;
 RES
 
-check [ $foo, $qux, $baz ], 'mods folding 4', <<'RES';
+check Tikz->seq($foo, $qux, $baz), 'mods folding 4', <<'RES';
 \begin{scope} [line width=4.0pt]
 \begin{scope} [color=red]
 \draw foo ;
@@ -171,7 +155,7 @@ check [ $foo, $qux, $baz ], 'mods folding 4', <<'RES';
 \draw [color=red] baz ;
 RES
 
-check [ $baz, $foo, $qux ], 'mods folding 5', <<'RES';
+check Tikz->seq($baz, $foo, $qux), 'mods folding 5', <<'RES';
 \begin{scope} [color=red]
 \draw baz ;
 \begin{scope} [line width=4.0pt]
@@ -182,7 +166,7 @@ check [ $baz, $foo, $qux ], 'mods folding 5', <<'RES';
 \draw [line width=4.0pt] qux ;
 RES
 
-check [ $baz, $qux, $foo ], 'mods folding 6', <<'RES';
+check Tikz->seq($baz, $qux, $foo), 'mods folding 6', <<'RES';
 \draw [color=red] baz ;
 \draw [line width=4.0pt] qux ;
 \begin{scope} [color=red,line width=4.0pt]
@@ -191,7 +175,7 @@ check [ $baz, $qux, $foo ], 'mods folding 6', <<'RES';
 \end{scope}
 RES
 
-check [ $qux, $foo, $baz ], 'mods folding 7', <<'RES';
+check Tikz->seq($qux, $foo, $baz), 'mods folding 7', <<'RES';
 \begin{scope} [line width=4.0pt]
 \draw qux ;
 \begin{scope} [color=red]
@@ -202,7 +186,7 @@ check [ $qux, $foo, $baz ], 'mods folding 7', <<'RES';
 \draw [color=red] baz ;
 RES
 
-check [ $qux, $baz, $foo ], 'mods folding 8', <<'RES';
+check Tikz->seq($qux, $baz, $foo), 'mods folding 8', <<'RES';
 \draw [line width=4.0pt] qux ;
 \draw [color=red] baz ;
 \begin{scope} [color=red,line width=4.0pt]
@@ -281,7 +265,7 @@ check $seq, 'mod covering 4', <<'RES';
 \end{scope}
 \draw qux ;
 \end{scope}
-\draw [raw3] baz ;
+\draw [raw2,raw3] baz ;
 \end{scope}
 RES
 
@@ -299,7 +283,7 @@ check $seq, 'mod covering 5', <<'RES';
 \end{scope}
 \draw qux ;
 \end{scope}
-\draw [raw3] baz ;
+\draw [raw2,raw3] baz ;
 \end{scope}
 RES