use strict;
use warnings;
-use Test::More tests => 19 + 2 * 20;
+use Test::More tests => 20 + 2 * 22;
use LaTeX::TikZ;
-use LaTeX::TikZ::Formatter;
-my $tikz = LaTeX::TikZ::Formatter->new(
+my $tikz = Tikz->formatter(
format => '%d',
);
\draw [color=red] foo ;
RES
+my $foo2 = eval {
+ Tikz->raw('foo')
+ ->mod('->')
+};
+is $@, '', 'creating a modded raw set from a string doesn\'t croak';
+
+check $foo2, 'one modded raw set from a string', <<'RES';
+\draw [->] foo ;
+RES
+
+sub failed_valid {
+ my ($tc) = @_;
+ qr/Validation failed for '\Q$tc\E'/;
+}
+
+eval {
+ Tikz->raw([ 'fail' ])
+ ->mod(Tikz->raw('epic'));
+};
+like $@, failed_valid('LaTeX::TikZ::Mod'), 'trying to use a non LTM mod croaks';
+
my $width = eval {
Tikz->width(25);
};
RES
my $bar = Tikz->raw('bar');
-eval {
- $foo->add($bar);
+$foo = eval {
+ Tikz->seq(
+ Tikz->raw('foo'),
+ $bar
+ )->mod($red, $width);
};
-is $@, '', 'appending to a modded set doesn\'t croak';
+is $@, '', 'setting two mods in a row doesn\'t croak';
-check $foo, 'one triple modded sequence of raw sets (with duplicates)', <<'RES';
+check $foo, 'one triple modded sequence of raw sets', <<'RES';
\begin{scope} [color=red,line width=4.0pt]
\draw foo ;
\draw bar ;
\end{scope}
RES
-my $set = Tikz->raw('wut');
-
-my $set_mod = eval {
- $set->mod;
-};
-is $@, '', 'calling empty mod out of a set doesn\'t croak';
-is "$set_mod", "$set", 'calling empty mod out of a set returns the set';
-
-my $new = eval {
- $set->mod(Tikz->raw_mod('raw1'));
-};
-is $@, '',
- 'creating and applying a raw mod on a set in scalar context doesn\'t croak';
-is ref($new), 'LaTeX::TikZ::Set::Mod', 'new set is of the right kind';
-isnt "$new", "$set", 'new set is different from the old one';
-
-check $set, '', <<'RES';
-\draw wut ;
-RES
-
-check $new, '', <<'RES';
-\draw [raw1] wut ;
-RES
-
-eval {
- $set->mod(Tikz->raw_mod('raw2'));
- ();
+my $nested = eval {
+ Tikz->seq(
+ Tikz->seq(Tikz->raw("foo"))
+ ->mod($red)
+ )->mod($width)
};
-is $@, '',
- 'creating and applying a raw mod on a set in void context doesn\'t croak';
-is ref($new), 'LaTeX::TikZ::Set::Mod', 'new set is of the right kind';
-
-check $set, '', <<'RES';
-\draw [raw2] wut ;
-RES
+is $@, '', 'creating nested modded sequences doesn\'t croak';
-check $new, '', <<'RES';
-\draw [raw1] wut ;
+check $nested, 'nested modded sequences', <<'RES';
+\draw [line width=4.0pt,color=red] foo ;
RES
my $baz = eval {
\draw [raw3] baz ;
\end{scope}
RES
+
+eval {
+ $bar->mod(Tikz->width(50));
+};
+is $@, '', 'creating and adding another width mod doesn\'t croak';
+
+check $seq, 'mod covering 5', <<'RES';
+\begin{scope} [color=red,raw2]
+\begin{scope} [line width=4.0pt]
+\begin{scope} [raw1]
+\draw foo ;
+\draw [line width=8.0pt] bar ;
+\end{scope}
+\draw qux ;
+\end{scope}
+\draw [raw3] baz ;
+\end{scope}
+RES
+
+my ($fred, $fblue) = eval {
+ map Tikz->fill($_), qw/red blue/;
+};
+is $@, '', 'creating two fill mods doesn\'t croak';
+
+$seq = eval {
+ Tikz->seq(
+ Tikz->raw("foo")
+ ->mod($fred)
+ )->mod($fred);
+};
+is $@, '', 'creating a structure with two identical fill mods doesn\'t croak';
+
+check $seq, 'mod covering 6', <<'RES';
+\draw [fill=red] foo ;
+RES
+
+$seq = eval {
+ Tikz->seq(
+ Tikz->raw("foo")
+ ->mod($fblue)
+ )->mod($fred);
+};
+is $@, '', 'creating a structure with two different fill mods doesn\'t croak';
+
+check $seq, 'mod covering 7', <<'RES';
+\draw [fill=red,fill=blue] foo ;
+RES
+
+$seq = eval {
+ Tikz->seq(
+ Tikz->raw("foo")
+ ->mod($red)
+ )->mod($fred);
+};
+is $@, '', 'creating a structure with color and fill mods doesn\'t croak';
+
+check $seq, 'mod covering 8', <<'RES';
+\draw [fill=red,color=red] foo ;
+RES