File: by_name.t

package info (click to toggle)
liblatex-tom-perl 1.06-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 304 kB
  • sloc: perl: 1,787; makefile: 2
file content (41 lines) | stat: -rwxr-xr-x 786 bytes parent folder | download | duplicates (2)
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
40
41
#!/usr/bin/perl

use strict;
use warnings;

use LaTeX::TOM;
use Test::More tests => 2;

my $parser = LaTeX::TOM->new;

my $tex = do { local $/; <DATA> };

my $tree = $parser->parse($tex);

{
    my $nodes = $tree->getCommandNodesByName('section');

    my $ok = (@$nodes == 1
           &&  $nodes->[0]->getNodeType    eq 'COMMAND'
           &&  $nodes->[0]->getCommandName eq 'section'
    );

    ok($ok, 'getCommandNodesByName');
}

{
    my $nodes = $tree->getEnvironmentsByName('document');

    my $ok = (@$nodes == 1
           &&  $nodes->[0]->getNodeType         eq 'ENVIRONMENT'
           &&  $nodes->[0]->getEnvironmentClass eq 'document'
    );

    ok($ok, 'getEnvironmentsByName');
}

__DATA__
\documentclass[10pt]{article}
\begin{document}
\section{abc}
\end{document}