port CSS fixes from Mojolicious 6.31 and 6.32
[catagits/DOM-Tiny.git] / t / dom.t
diff --git a/t/dom.t b/t/dom.t
index e345d27..a6b8a72 100644 (file)
--- a/t/dom.t
+++ b/t/dom.t
@@ -979,28 +979,28 @@ $dom->find('li:nth-last-child(4n+1)')->each(sub { push @li, shift->text });
 is_deeply \@li, [qw(D H)], 'found the right li elements';
 @li = ();
 $dom->find('li:nth-child(4n+4)')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(D H)], 'found the right li element';
+is_deeply \@li, [qw(D H)], 'found the right li elements';
 @li = ();
 $dom->find('li:nth-last-child(4n+4)')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(A E)], 'found the right li element';
+is_deeply \@li, [qw(A E)], 'found the right li elements';
 @li = ();
 $dom->find('li:nth-child(4n)')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(D H)], 'found the right li element';
+is_deeply \@li, [qw(D H)], 'found the right li elements';
 @li = ();
 $dom->find('li:nth-child( 4n )')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(D H)], 'found the right li element';
+is_deeply \@li, [qw(D H)], 'found the right li elements';
 @li = ();
 $dom->find('li:nth-last-child(4n)')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(A E)], 'found the right li element';
+is_deeply \@li, [qw(A E)], 'found the right li elements';
 @li = ();
 $dom->find('li:nth-child(5n-2)')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(C H)], 'found the right li element';
+is_deeply \@li, [qw(C H)], 'found the right li elements';
 @li = ();
 $dom->find('li:nth-child( 5n - 2 )')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(C H)], 'found the right li element';
+is_deeply \@li, [qw(C H)], 'found the right li elements';
 @li = ();
 $dom->find('li:nth-last-child(5n-2)')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(A F)], 'found the right li element';
+is_deeply \@li, [qw(A F)], 'found the right li elements';
 @li = ();
 $dom->find('li:nth-child(-n+3)')->each(sub { push @li, shift->text });
 is_deeply \@li, [qw(A B C)], 'found first three li elements';
@@ -1029,26 +1029,43 @@ is_deeply \@li, [qw(C F)], 'found every third li elements';
 $dom->find('li:Nth-Last-Child(3N)')->each(sub { push @li, shift->text });
 is_deeply \@li, [qw(C F)], 'found every third li elements';
 @li = ();
-$dom->find('li:nth-child(3)')->each(sub { push @li, shift->text });
+$dom->find('li:nth-child( 3 )')->each(sub { push @li, shift->text });
 is_deeply \@li, ['C'], 'found third li element';
 @li = ();
-$dom->find('li:nth-last-child(3)')->each(sub { push @li, shift->text });
+$dom->find('li:nth-last-child( +3 )')->each(sub { push @li, shift->text });
 is_deeply \@li, ['F'], 'found third last li element';
 @li = ();
 $dom->find('li:nth-child(1n+0)')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(A B C D E F G)], 'found first three li elements';
+is_deeply \@li, [qw(A B C D E F G)], 'found all li elements';
+@li = ();
+$dom->find('li:nth-child(1n-0)')->each(sub { push @li, shift->text });
+is_deeply \@li, [qw(A B C D E F G)], 'found all li elements';
 @li = ();
 $dom->find('li:nth-child(n+0)')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(A B C D E F G)], 'found first three li elements';
+is_deeply \@li, [qw(A B C D E F G)], 'found all li elements';
+@li = ();
+$dom->find('li:nth-child(n)')->each(sub { push @li, shift->text });
+is_deeply \@li, [qw(A B C D E F G)], 'found all li elements';
+@li = ();
+$dom->find('li:nth-child(n+0)')->each(sub { push @li, shift->text });
+is_deeply \@li, [qw(A B C D E F G)], 'found all li elements';
 @li = ();
 $dom->find('li:NTH-CHILD(N+0)')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(A B C D E F G)], 'found first three li elements';
+is_deeply \@li, [qw(A B C D E F G)], 'found all li elements';
 @li = ();
 $dom->find('li:Nth-Child(N+0)')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(A B C D E F G)], 'found first three li elements';
+is_deeply \@li, [qw(A B C D E F G)], 'found all li elements';
 @li = ();
 $dom->find('li:nth-child(n)')->each(sub { push @li, shift->text });
-is_deeply \@li, [qw(A B C D E F G)], 'found first three li elements';
+is_deeply \@li, [qw(A B C D E F G)], 'found all li elements';
+@li = ();
+$dom->find('li:nth-child(0n+1)')->each(sub { push @li, shift->text });
+is_deeply \@li, [qw(A)], 'found first li element';
+is $dom->find('li:nth-child(0n+0)')->size,     0, 'no results';
+is $dom->find('li:nth-child(0)')->size,        0, 'no results';
+is $dom->find('li:nth-child()')->size,         0, 'no results';
+is $dom->find('li:nth-child(whatever)')->size, 0, 'no results';
+is $dom->find('li:whatever(whatever)')->size,  0, 'no results';
 
 # Even more pseudo-classes
 $dom = DOM::Tiny->new(<<EOF);
@@ -1127,6 +1144,9 @@ is_deeply \@e, ['I'], 'found last child';
 $dom->find('ul :nth-child(-n+3):not(li)')->each(sub { push @e, shift->text });
 is_deeply \@e, ['B'], 'found first p element';
 @e = ();
+$dom->find('ul :nth-child(-n+3):NOT(li)')->each(sub { push @e, shift->text });
+is_deeply \@e, ['B'], 'found first p element';
+@e = ();
 $dom->find('ul :nth-child(-n+3):not(:first-child)')
   ->each(sub { push @e, shift->text });
 is_deeply \@e, [qw(B C)], 'found second and third element';