]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blob - t/11-point.t
c7f53cdf11adceee590bffc31cafd1f7a3ff1134
[perl/modules/LaTeX-TikZ.git] / t / 11-point.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 1 + 2 * 1;
7
8 use Math::Complex;
9
10 use LaTeX::TikZ;
11
12 my $tikz = Tikz->formatter(
13  format => '%d',
14 );
15
16 sub check {
17  my ($set, $desc, $exp) = @_;
18
19  local $Test::Builder::Level = $Test::Builder::Level + 1;
20
21  my ($head, $decl, $body) = eval {
22   $tikz->render(ref $set eq 'ARRAY' ? @$set : $set);
23  };
24  is $@, '', "$desc: no error";
25
26  unless (ref $exp eq 'ARRAY') {
27   $exp = [ split /\n/, $exp ];
28  }
29  unshift @$exp, '\begin{tikzpicture}';
30  push    @$exp, '\end{tikzpicture}';
31
32  is_deeply $body, $exp, $desc;
33 }
34
35 my $z = Math::Complex->make(1, 2);
36
37 my $p = eval {
38  Tikz->point($z);
39 };
40 is $@, '', 'creating a point from a Math::Complex object doesn\'t croak';
41
42 check $p, 'a point from a Math::Complex object', <<'RES';
43 \draw (1cm,2cm) ;
44 RES