File: match_and_not.t

package info (click to toggle)
libweb-query-perl 1.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 424 kB
  • sloc: perl: 984; xml: 329; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 610 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use strict;
use warnings;

use Test2::V0;

use lib 't/lib';

use WQTest;

WQTest::test {
    my $class = shift;
    
    my $wq = $class->new(<<HTML);
    <div>
        <p id="first" class="foo">one</p>
        <p id="second">two</p>
        <p class="foo">three</p>
    </div>
    
HTML
    
    is $wq->find('p')->not( '#second' )->size => 2, 'not';
    is $wq->find('p')->filter( '#second' )->size => 1, 'filter';

    subtest 'match' => sub {
        is [ $wq->find('p')->match( '.foo' ) ], [ 1, '', 1 ], "list context";
        is scalar $wq->find('p')->match( '.foo' ) =>  1, "scalar context";
    };

}