/[suikacvs]/messaging/manakai/t/DOM-EntityReference.t
Suika

Contents of /messaging/manakai/t/DOM-EntityReference.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download) (as text)
Sat Jul 7 11:11:34 2007 UTC (17 years, 4 months ago) by wakaba
Branch: MAIN
CVS Tags: manakai-release-0-4-0, HEAD
Changes since 1.1: +62 -3 lines
File MIME type: application/x-troff
++ manakai/t/ChangeLog	7 Jul 2007 11:11:27 -0000
	* DOM-Element.t: New tests for |create_element|
	and |create_element_ns| are added.

	* DOM-EntityReference.t: New tests for |create_entity_reference|
	are added.

	* DOM-Node.t: Test data for |is_element_content_whitespace|
	are added.

2007-07-07  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/DOM/ChangeLog	7 Jul 2007 11:10:33 -0000
	* CDATASection.pm (is_element_content_whitespace): New.

	* DOMElement.pm (has_attribute): Alpha version.
	(create_element, create_element_ns): Implemented.

	* DocumentType.pm (get_general_entity_node): Alpha version.

	* EntityReference.pm (create_entity_reference): Implemented.

	* ProcessingInstruction.pm (create_processing_instruction): Implemented.

2007-07-07  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 #!/usr/bin/perl
2     use strict;
3     use Test;
4 wakaba 1.2 BEGIN { plan tests => 30 }
5 wakaba 1.1
6     require Message::DOM::DOMImplementation;
7     use Message::Util::Error;
8    
9     my $dom = Message::DOM::DOMImplementation->____new;
10 wakaba 1.2
11     {
12     my $doc = $dom->create_document;
13     my $dt = $doc->create_document_type_definition ('dt');
14     my $ent = $doc->create_general_entity ('ent1');
15     $ent->text_content ('replacement text content');
16     $ent->has_replacement_tree (1);
17     $dt->set_general_entity_node ($ent);
18     $doc->append_child ($dt);
19    
20     my $entref = $doc->create_entity_reference ('ent1');
21     ok UNIVERSAL::isa ($entref, 'Message::IF::EntityReference') ? 1 : 0, 1,
22     'create_er interface [0]';
23     ok $entref->manakai_expanded ? 1 : 0, 1, 'create_er->m_expanded [0]';
24     ok $entref->has_child_nodes ? 1 : 0, 1, 'create_er->has_cn [0]';
25     ok $entref->text_content, 'replacement text content', 'create_er->tx [0]';
26     ok $entref->manakai_read_only ? 1 : 0, 1, 'create_er->mro [0]';
27     }
28    
29     {
30     my $doc = $dom->create_document;
31     my $dt = $doc->create_document_type_definition ('dt');
32     my $ent0 = $doc->create_entity_reference ('ent1');
33     my $et = $doc->create_general_entity ('ent1');
34     $et->append_child ($ent0);
35     $et->has_replacement_tree (1);
36     $dt->set_general_entity_node ($et);
37     $doc->append_child ($dt);
38    
39     my $entref = $doc->create_entity_reference ('ent1');
40     ok UNIVERSAL::isa ($entref, 'Message::IF::EntityReference') ? 1 : 0, 1,
41     'create_er interface [1]';
42     ok $entref->manakai_expanded ? 1 : 0, 1, 'create_er->m_expanded [1]';
43     ok $entref->has_child_nodes ? 1 : 0, 1, 'create_er->has_cn [1]';
44     ok $entref->manakai_read_only ? 1 : 0, 1, 'create_er->mro [1]';
45     ok defined $entref->first_child ? 1 : 0, 1, 'create_er->fc [1]';
46     ok $entref->first_child->manakai_expanded ? 1 : 0, 0, 'create_er->rec x [1]';
47     }
48    
49     {
50     my $doc = $dom->create_document;
51     my $dt = $doc->create_document_type_definition ('dt');
52     my $ent0 = $doc->create_entity_reference ('ent2');
53     my $et = $doc->create_general_entity ('ent1');
54     $et->append_child ($ent0);
55     $et->has_replacement_tree (1);
56     my $ent0_2 = $doc->create_entity_reference ('ent1');
57     my $et_2 = $doc->create_general_entity ('ent2');
58     $et_2->append_child ($ent0_2);
59     $et_2->has_replacement_tree (1);
60     $dt->set_general_entity_node ($et);
61     $dt->set_general_entity_node ($et_2);
62     $doc->append_child ($dt);
63    
64     my $entref = $doc->create_entity_reference ('ent1');
65     ok $entref->manakai_expanded ? 1 : 0, 1, 'create_er->me [2]';
66     ok defined $entref->first_child ? 1 : 0, 1, 'create_er->fc [2]';
67     ok $entref->first_child->manakai_expanded ? 1 : 0, 0, 'create_er->fc->me [2]';
68     }
69    
70 wakaba 1.1 my $doc = $dom->create_document;
71     my $ent = $doc->create_entity_reference ('entity');
72    
73     for my $prop (qw/manakai_expanded manakai_external/) {
74     ok $ent->can ($prop) ? 1 : 0, 1, 'can ' . $prop;
75    
76     for (1, 0, '') {
77     $ent->$prop ($_);
78     ok $ent->$prop ? 1 : 0, $_ ? 1 : 0, $prop . $_;
79     }
80    
81     $ent->$prop (undef);
82     ok $ent->$prop ? 1 : 0, 0, $prop . ' undef';
83     }
84    
85     ## |manakaiEntityBaseURI|.
86     {
87     my $doc2 = $doc->implementation->create_document;
88     my $ent = $doc2->create_entity_reference ('ent1');
89     $ent->manakai_set_read_only (0, 1);
90     ok $ent->manakai_entity_base_uri, undef, "ER->manakai_entity_base_uri [0]";
91    
92     $doc2->document_uri (q<http://www.example/>);
93     ok $ent->manakai_entity_base_uri, q<http://www.example/>,
94     "ER->manakai_entity_base_uri [1]";
95    
96     $ent->manakai_entity_base_uri (q<ftp://www.example/>);
97     ok $ent->manakai_entity_base_uri, q<ftp://www.example/>,
98     "ER->manakai_entity_base_uri [2]";
99     ok $ent->base_uri, q<http://www.example/>,
100     "ER->manakai_entity_base_uri base_uri [2]";
101    
102     $ent->manakai_entity_base_uri (undef);
103     ok $ent->manakai_entity_base_uri, q<http://www.example/>,
104     "ER->manakai_entity_base_uri [3]";
105     ok $ent->base_uri, q<http://www.example/>,
106     "ER->manakai_entity_base_uri base_uri [3]";
107     }
108    
109     =head1 LICENSE
110    
111     Copyright 2007 Wakaba <w@suika.fam.cx>
112    
113     This program is free software; you can redistribute it and/or
114     modify it under the same terms as Perl itself.
115    
116     =cut
117    
118 wakaba 1.2 ## $Date: 2007/06/17 13:37:42 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24