use strict;
use warnings;
-use Test::More tests => 2 + 2 * 10;
+use Test::More tests => 8 + 2 * 16;
use LaTeX::TikZ;
\end{pgfonlayer}
RES
+my $a = Tikz->point;
+my $b = Tikz->point(4, 2);
+my $c = Tikz->point(1, 3);
+my $d = Tikz->point(2, 1);
+
+my $r1 = Tikz->rectangle($a, $b);
+my $r2 = Tikz->rectangle($c, $d);
+
+$seq = eval {
+ Tikz->seq(
+ Tikz->raw("foo")
+ ->clip($r1)
+ )->clip($r2);
+};
+is $@, '', 'two intersecting rectangle clips doesn\'t croak';
+
+check $seq, 'two intersecting rectangle clips', <<'RES';
+\begin{scope}
+\clip (1cm,3cm) rectangle (2cm,1cm) ;
+\begin{scope}
+\clip (0cm,0cm) rectangle (4cm,2cm) ;
+\draw foo ;
+\end{scope}
+\end{scope}
+RES
+
+$r2 = Tikz->rectangle($a, $d); # $r2 is a subset of $r1
+
+$seq = eval {
+ Tikz->seq(
+ Tikz->raw("foo")
+ ->clip($r1)
+ )->clip($r2);
+};
+is $@, '', 'two overlapping rectangle clips 1 doesn\'t croak';
+
+check $seq, 'two overlapping rectangle clips 1', <<'RES';
+\begin{scope}
+\clip (0cm,0cm) rectangle (2cm,1cm) ;
+\draw foo ;
+\end{scope}
+RES
+
+$seq = eval {
+ Tikz->seq(
+ Tikz->raw("foo")
+ ->clip($r2)
+ )->clip($r1);
+};
+is $@, '', 'two overlapping rectangle clips 2 doesn\'t croak';
+
+check $seq, 'two overlapping rectangle clips 2', <<'RES';
+\begin{scope}
+\clip (0cm,0cm) rectangle (4cm,2cm) ;
+\begin{scope}
+\clip (0cm,0cm) rectangle (2cm,1cm) ;
+\draw foo ;
+\end{scope}
+\end{scope}
+RES
+
+my $c1 = Tikz->circle($a, 2);
+my $c2 = Tikz->circle($d, 3);
+
+$seq = eval {
+ Tikz->seq(
+ Tikz->raw("foo")
+ ->clip($c1)
+ )->clip($c2);
+};
+is $@, '', 'two intersecting circle clips doesn\'t croak';
+
+check $seq, 'two intersecting circle clips', <<'RES';
+\begin{scope}
+\clip (2cm,1cm) circle (3cm) ;
+\begin{scope}
+\clip (0cm,0cm) circle (2cm) ;
+\draw foo ;
+\end{scope}
+\end{scope}
+RES
+
+$c2 = Tikz->circle($a, 1); # $c2 is a subset of $c1
+
+$seq = eval {
+ Tikz->seq(
+ Tikz->raw("foo")
+ ->clip($c1)
+ )->clip($c2);
+};
+is $@, '', 'two overlapping circle clips 1 doesn\'t croak';
+
+check $seq, 'two overlapping circle clips 1', <<'RES';
+\begin{scope}
+\clip (0cm,0cm) circle (1cm) ;
+\draw foo ;
+\end{scope}
+RES
+
+$seq = eval {
+ Tikz->seq(
+ Tikz->raw("foo")
+ ->clip($c2)
+ )->clip($c1);
+};
+is $@, '', 'two overlapping circle clips 2 doesn\'t croak';
+
+check $seq, 'two overlapping circle clips 2', <<'RES';
+\begin{scope}
+\clip (0cm,0cm) circle (2cm) ;
+\begin{scope}
+\clip (0cm,0cm) circle (1cm) ;
+\draw foo ;
+\end{scope}
+\end{scope}
+RES