File: 00_basic.t

package info (click to toggle)
libxml-dt-perl 0.69-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 388 kB
  • sloc: perl: 1,432; xml: 438; makefile: 16
file content (110 lines) | stat: -rw-r--r-- 3,737 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# -*- cperl -*-

use Test::More tests => 27;

BEGIN {
  use_ok( 'XML::DT' );
}

# normalize_space
is(XML::DT::_normalize_space("  teste  "), "teste");
is(XML::DT::_normalize_space("\tteste\t"), "teste");
is(XML::DT::_normalize_space("\tteste  "), "teste");

is(XML::DT::_normalize_space(" spaces   in   \t the middle\t"),
   "spaces in the middle");

# toxml as function
is(toxml("a",{},""), "<a/>");

is(tohtml("a",{},""), "<a></a>");
is(tohtml("br",{},""), "<br>");
is(tohtml("hr",{},""), "<hr>");
is(tohtml("link",{type=>"bar"},""), "<link type=\"bar\">");
is(tohtml("img",{src=>"foo"},""), "<img src=\"foo\">");

is(toxml("a",{},"c"), "<a>c</a>");
is(tohtml("a",{},"c"), "<a>c</a>");

is(toxml("a",{a=>1},"c"), "<a a=\"1\">c</a>");
is(tohtml("a",{a=>1},"c"), "<a a=\"1\">c</a>");

is(toxml({ -q => "html",
           -c => { -q => "head",
                   -c => { -q => "title",
                           -c => "Titulo da pagina" }}}),
   "<html><head><title>Titulo da pagina</title></head></html>");
is(tohtml({ -q => "html",
           -c => { -q => "head",
                   -c => { -q => "title",
                           -c => "Titulo da pagina" }}}),
   "<html><head><title>Titulo da pagina</title></head></html>");

is(toxml({ -q => "html",
           -c => { -q => "head",
                   -c => []
		 }
	 }),   "<html><head/></html>");
is(tohtml({ -q => "html",
	           -c => { -q => "head",
	                   -c => []
			 }
		 }),   "<html><head></head></html>");


is(toxml({ -q => "html",
           -c => { -q => "head",
                   -c => [ { -q => "title",
                             -c => "Titulo da pagina" },
			   { -q => "title",
                             -c => "Titulo da pagina" }]}}),
   "<html><head><title>Titulo da pagina</title>\n<title>Titulo da pagina</title></head></html>");
is(tohtml({ -q => "html",
           -c => { -q => "head",
                   -c => [ { -q => "title",
                             -c => "Titulo da pagina" },
			   { -q => "title",
                             -c => "Titulo da pagina" }]}}),
   "<html><head><title>Titulo da pagina</title>\n<title>Titulo da pagina</title></head></html>");


is(toxml({ -q => "html",
           -c => [ { -q => "head",
                     -c => [ { -q => "title",
                               -c => "Titulo da pagina" },
			     { -q => "title",
                               -c => "Titulo da pagina" }]},
		   { -q => "head",
                     -c => [ { -q => "title",
                               -c => "Titulo da pagina" },
			     { -q => "title",
                               -c => "Titulo da pagina" }]}]}),
   "<html><head><title>Titulo da pagina</title>\n<title>Titulo da pagina</title></head>\n<head><title>Titulo da pagina</title>\n<title>Titulo da pagina</title></head></html>");
is(tohtml({ -q => "html",
           -c => [ { -q => "head",
                     -c => [ { -q => "title",
                               -c => "Titulo da pagina" },
			     { -q => "title",
                               -c => "Titulo da pagina" }]},
		   { -q => "head",
                     -c => [ { -q => "title",
                               -c => "Titulo da pagina" },
			     { -q => "title",
                               -c => "Titulo da pagina" }]}]}),
   "<html><head><title>Titulo da pagina</title>\n<title>Titulo da pagina</title></head>\n<head><title>Titulo da pagina</title>\n<title>Titulo da pagina</title></head></html>");


# this is one of the most important tests for MathML
is(toxml("foo",{},"0"), "<foo>0</foo>");

# toxml with variables
$q = "a";
$c = "b";
%v = ();
is(toxml, "<a>b</a>");

$v{foo} = "bar";
is(toxml, "<a foo=\"bar\">b</a>");

$c = '0';
is(toxml, "<a foo=\"bar\">0</a>");