File: selector.t

package info (click to toggle)
libpandoc-elements-perl 0.38-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 732 kB
  • sloc: perl: 1,630; makefile: 15; sh: 1
file content (39 lines) | stat: -rw-r--r-- 1,192 bytes parent folder | download | duplicates (3)
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
31
32
33
34
35
36
37
38
39
use strict;
use Test::More;
use Pandoc::Elements;
use Pandoc::Selector;

# test matching on elements
ok Str('')->match('Str'), 'match name';
ok !Str('')->match('Para'), 'no match';

ok Str('')->match('str'), 'case-insensitive';

ok Str('')->match(':inline'), 'type match';
ok !Str('')->match(':block'), 'type not match';

ok Str('')->match('str:inline'), 'multiple match';
ok Str('')->match('Foo|Str'), '| match';

ok !Str('')->match(Pandoc::Selector->new('#id')), 'no id match';

my $e = Code attributes { id => 'abc', class => ['f0_0','bar']} , '';

# test matching with selector
ok(Pandoc::Selector->new('#abc')->match($e), 'id match');
ok(!Pandoc::Selector->new('#xyz')->match($e), 'id no match');
ok(!Pandoc::Selector->new('#1')->match($e), 'id no match');

ok(Pandoc::Selector->new('.f0_0')->match($e), 'class match');
ok(Pandoc::Selector->new('.bar .f0_0')->match($e), 'classes match');
ok(!Pandoc::Selector->new('.xyz')->match($e), 'class no match');

ok $e->match("code\t:inline .bar#abc  .f0_0"), 'multiple match';

{
    my $plain = Plain [ Math InlineMath, 'x' ];
    is_deeply $plain->query(':inline'), $plain->content,
        ':inline match without keywords';
}

done_testing;