our $VERSION = '0.01';
-use LaTeX::TikZ::Tools;
-
use Any::Moose;
+use Any::Moose 'Util::TypeConstraints'
+ => [ qw/subtype as where find_type_constraint/ ];
with qw(
LaTeX::TikZ::Set::Op
LaTeX::TikZ::Set::Mutable
);
+subtype 'LaTeX::TikZ::Set::Path::Elements'
+ => as 'Object'
+ => where { $_->does('LaTeX::TikZ::Set::Op') };
+
has '_ops' => (
is => 'ro',
- isa => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Op]]',
+ isa => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Path::Elements]]',
init_arg => 'ops',
default => sub { [ ] },
);
sub ops { @{$_[0]->_ops} }
-my $ltso_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Set::Op');
+my $ltspe_tc = find_type_constraint('LaTeX::TikZ::Set::Path::Elements');
sub add {
my $set = shift;
- $ltso_tc->check($_) for @_;
+ $ltspe_tc->check($_) for @_;
push @{$_[0]->_ops}, @_;
use strict;
use warnings;
-use Test::More tests => 5 + 2 * 4;
+use Test::More tests => 9 + 2 * 6;
use LaTeX::TikZ;
use LaTeX::TikZ::Formatter;
\draw bar ;
\draw foo ;
RES
+
+my $baz = eval {
+ Tikz->raw('baz');
+};
+is $@, '', 'creating yet another raw set doesn\'t croak';
+
+eval {
+ $foo->add($baz);
+};
+like $@, qr/Can't locate object method "add"/,
+ 'adding something to a raw set croaks';
+
+eval {
+ $seq2->add($baz, $baz);
+};
+is $@, '', 'adding something to a sequence set doesn\'t croak';
+
+check $seq3, 'two different raw sets and an extended sequence', <<'RES';
+\draw bar ;
+\draw foo ;
+\draw bar ;
+\draw baz ;
+\draw baz ;
+\draw foo ;
+RES
+
+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 ;
+\draw foo bar baz ;
+RES