]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - t/11-point.t
Make Points into a real class
[perl/modules/LaTeX-TikZ.git] / t / 11-point.t
diff --git a/t/11-point.t b/t/11-point.t
new file mode 100644 (file)
index 0000000..c7f53cd
--- /dev/null
@@ -0,0 +1,44 @@
+#!perl -T
+
+use strict;
+use warnings;
+
+use Test::More tests => 1 + 2 * 1;
+
+use Math::Complex;
+
+use LaTeX::TikZ;
+
+my $tikz = 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 $z = Math::Complex->make(1, 2);
+
+my $p = eval {
+ Tikz->point($z);
+};
+is $@, '', 'creating a point from a Math::Complex object doesn\'t croak';
+
+check $p, 'a point from a Math::Complex object', <<'RES';
+\draw (1cm,2cm) ;
+RES