]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - t/20-mod.t
Update VPIT::TestHelpers to 15e8aee3
[perl/modules/LaTeX-TikZ.git] / t / 20-mod.t
index 50a869e8c61bcec5f86fcd37616f519b52115a28..191c150bdafe48b8502842d1b712a5e14fb4e146 100644 (file)
@@ -3,33 +3,17 @@
 use strict;
 use warnings;
 
-use Test::More tests => 20 + 2 * 22;
+use Test::More tests => 23 + 2 * 24;
 
 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');
 };
@@ -66,6 +50,33 @@ eval {
 };
 like $@, failed_valid('LaTeX::TikZ::Mod'), 'trying to use a non LTM mod croaks';
 
+my $scale = eval {
+ Tikz->scale(2);
+};
+is $@, '', 'creating a scale mod doesn\'t croak';
+
+$foo2 = eval {
+ Tikz->raw('foo')
+     ->mod($scale);
+};
+is $@, '', 'applying a scale mod doesn\'t croak';
+
+check $foo2, 'a raw set with a scale mod', <<'RES';
+\draw [scale=2.000] foo ;
+RES
+
+$foo2 = eval {
+ Tikz->union(
+  Tikz->raw('foo')
+      ->mod($scale),
+ )->mod(Tikz->scale(4));
+};
+is $@, '', 'applying two scale mods doesn\'t croak';
+
+check $foo2, 'a union of a raw set with two scale mods', <<'RES';
+\draw [scale=4.000] foo ;
+RES
+
 my $width = eval {
  Tikz->width(25);
 };
@@ -268,7 +279,7 @@ check $seq, 'mod covering 3', <<'RES';
 RES
 
 eval {
- $baz->mod(Tikz->raw_mod($_)) for qw/raw2 raw3/;
+ $baz->mod(Tikz->raw_mod($_)) for qw<raw2 raw3>;
 };
 is $@, '', 'creating and adding another raw mod doesn\'t croak';
 
@@ -281,7 +292,7 @@ check $seq, 'mod covering 4', <<'RES';
 \end{scope}
 \draw qux ;
 \end{scope}
-\draw [raw3] baz ;
+\draw [raw2,raw3] baz ;
 \end{scope}
 RES
 
@@ -299,12 +310,12 @@ check $seq, 'mod covering 5', <<'RES';
 \end{scope}
 \draw qux ;
 \end{scope}
-\draw [raw3] baz ;
+\draw [raw2,raw3] baz ;
 \end{scope}
 RES
 
 my ($fred, $fblue) = eval {
- map Tikz->fill($_), qw/red blue/;
+ map Tikz->fill($_), qw<red blue>;
 };
 is $@, '', 'creating two fill mods doesn\'t croak';