use strict;
use warnings;
-use Test::More tests => 9 + 3 * 6;
+use Test::More tests => 9 + 3 * 10;
use LaTeX::TikZ;
\end{scope}
RES
+my $qux = Tikz->raw('qux');
+$seq2 = Tikz->seq($qux, $foo)
+ ->mod($red);
+
+check $seq2, 'mods folding with layers 4', <<'RES', [ 'middle' ];
+\begin{scope} [color=red]
+\draw qux ;
+\begin{pgfonlayer}{middle}
+\draw [color=red] foo ;
+\end{pgfonlayer}
+\end{scope}
+RES
+
+my $seq3 = Tikz->seq($seq2, $bar)
+ ->mod($red);
+
+check $seq3, 'mods folding with layers 5', <<'RES', [ qw/middle top/ ];
+\begin{scope} [color=red]
+\draw qux ;
+\begin{pgfonlayer}{middle}
+\draw [color=red] foo ;
+\end{pgfonlayer}
+\begin{pgfonlayer}{top}
+\draw [color=red] bar ;
+\end{pgfonlayer}
+\end{scope}
+RES
+
+$seq3 = Tikz->seq($bar, $seq2)
+ ->mod($red);
+
+check $seq3, 'mods folding with layers 6', <<'RES', [ qw/middle top/ ];
+\begin{scope} [color=red]
+\begin{pgfonlayer}{top}
+\draw [color=red] bar ;
+\end{pgfonlayer}
+\draw qux ;
+\begin{pgfonlayer}{middle}
+\draw [color=red] foo ;
+\end{pgfonlayer}
+\end{scope}
+RES
+
+my $blue = Tikz->color('blue');
+$qux->mod($blue);
+
+check $seq2, 'mods folding with layers 7', <<'RES', [ 'middle' ];
+\begin{scope} [color=red]
+\draw [color=blue] qux ;
+\begin{pgfonlayer}{middle}
+\draw [color=red] foo ;
+\end{pgfonlayer}
+\end{scope}
+RES