File: 100_MKDoc_XML_Tokenizer.t

package info (click to toggle)
libmkdoc-xml-perl 0.75-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 404 kB
  • sloc: perl: 2,629; xml: 17; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,059 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::Tokenizer;

{
    my $data = <<EOF;
    <input
      value="test"
      onfocus="if(t.value='';"
    />
EOF

    my $tokens = MKDoc::XML::Tokenizer->process_data ($data);
    like ($tokens->[0]->as_string(), qr/value\=\"test\"/);
}


my $file = (-e 't/data/sample.xml') ? 't/data/sample.xml' : 'data/sample.xml';
my $tokens = MKDoc::XML::Tokenizer->process_file ($file);


like ($tokens->[0]->as_string(), qr/<!-- warning, this XML is entirely/);
like ($tokens->[1]->as_string(), qr/^\s+$/s);
like ($tokens->[2]->as_string(), qr/^<!DOCTYPE html PUBLIC/);
like ($tokens->[3]->as_string(), qr/^\s+$/s);
is   ($tokens->[4]->as_string(), '<?xml version="1.0" encoding="UTF-8"?>');
like ($tokens->[5]->as_string(), qr/^\s+$/s);
like ($tokens->[6]->as_string(), qr/^<rdf:RDF/s);
like ($tokens->[7]->as_string(), qr/^\s+$/s);
is   ($tokens->[8]->as_string(), qq |<!-- let's have a comment -->|);
like ($tokens->[9]->as_string(), qr/^\s+$/s);


1;


__END__