libxml-ruby 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY +8 -0
- data/ext/libxml/extconf.h +3 -0
- data/ext/libxml/extconf.rb +30 -26
- data/ext/libxml/ruby_libxml.h +0 -8
- data/ext/libxml/ruby_xml.c +40 -0
- data/ext/libxml/ruby_xml_document.c +1 -1
- data/ext/libxml/ruby_xml_dtd.c +6 -8
- data/ext/libxml/ruby_xml_node.c +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +1 -1
- data/ext/libxml/ruby_xml_version.h +3 -3
- data/lib/libxml-ruby.rb +30 -0
- data/lib/libxml.rb +3 -28
- data/libxml-ruby.gemspec +2 -2
- data/test/test_attr.rb +18 -18
- data/test/test_attr_decl.rb +8 -8
- data/test/test_attributes.rb +10 -10
- data/test/test_canonicalize.rb +16 -24
- data/test/test_deprecated_require.rb +3 -3
- data/test/test_document.rb +118 -112
- data/test/test_document_write.rb +39 -88
- data/test/test_dtd.rb +23 -23
- data/test/test_encoding.rb +15 -15
- data/test/test_encoding_sax.rb +3 -3
- data/test/test_error.rb +51 -51
- data/test/test_helper.rb +2 -9
- data/test/test_html_parser.rb +30 -30
- data/test/test_html_parser_context.rb +6 -6
- data/test/test_namespace.rb +16 -16
- data/test/test_namespaces.rb +25 -25
- data/test/test_node.rb +36 -30
- data/test/test_node_cdata.rb +10 -10
- data/test/test_node_comment.rb +6 -6
- data/test/test_node_copy.rb +2 -2
- data/test/test_node_edit.rb +16 -16
- data/test/test_node_pi.rb +7 -7
- data/test/test_node_text.rb +6 -6
- data/test/test_node_write.rb +16 -26
- data/test/test_node_xlink.rb +6 -6
- data/test/test_parser.rb +68 -72
- data/test/test_parser_context.rb +28 -28
- data/test/test_properties.rb +5 -5
- data/test/test_reader.rb +80 -85
- data/test/test_relaxng.rb +11 -11
- data/test/test_sax_parser.rb +28 -28
- data/test/test_schema.rb +24 -24
- data/test/test_suite.rb +3 -4
- data/test/test_traversal.rb +4 -4
- data/test/test_writer.rb +50 -52
- data/test/test_xinclude.rb +3 -3
- data/test/test_xml.rb +114 -102
- data/test/test_xpath.rb +22 -22
- data/test/test_xpath_context.rb +5 -5
- data/test/test_xpath_expression.rb +6 -6
- data/test/test_xpointer.rb +15 -15
- metadata +6 -5
data/test/test_xinclude.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
require_relative './test_helper'
|
4
4
|
|
5
5
|
class TestXInclude < Minitest::Test
|
6
6
|
def setup
|
7
|
-
@doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/xinclude.xml'))
|
8
|
-
assert_instance_of(XML::Document, @doc)
|
7
|
+
@doc = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'model/xinclude.xml'))
|
8
|
+
assert_instance_of(LibXML::XML::Document, @doc)
|
9
9
|
end
|
10
10
|
|
11
11
|
def teardown
|
data/test/test_xml.rb
CHANGED
@@ -1,250 +1,262 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
require_relative './test_helper'
|
4
4
|
require 'stringio'
|
5
5
|
|
6
6
|
class TestXml < Minitest::Test
|
7
7
|
# ----- Constants ------
|
8
8
|
def test_lib_versions
|
9
|
-
assert(XML.check_lib_versions)
|
9
|
+
assert(LibXML::XML.check_lib_versions)
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_debug_entities
|
13
|
-
original = XML.debug_entities
|
13
|
+
original = LibXML::XML.debug_entities
|
14
14
|
|
15
|
-
XML.debug_entities = false
|
16
|
-
refute(XML.debug_entities)
|
15
|
+
LibXML::XML.debug_entities = false
|
16
|
+
refute(LibXML::XML.debug_entities)
|
17
17
|
|
18
|
-
XML.debug_entities = true
|
19
|
-
assert(XML.debug_entities)
|
18
|
+
LibXML::XML.debug_entities = true
|
19
|
+
assert(LibXML::XML.debug_entities)
|
20
20
|
|
21
|
-
XML.debug_entities = false
|
22
|
-
refute(XML.debug_entities)
|
21
|
+
LibXML::XML.debug_entities = false
|
22
|
+
refute(LibXML::XML.debug_entities)
|
23
23
|
|
24
|
-
XML.debug_entities = original
|
24
|
+
LibXML::XML.debug_entities = original
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_default_compression
|
28
|
-
return unless XML.default_compression
|
28
|
+
return unless LibXML::XML.default_compression
|
29
29
|
|
30
|
-
original = XML.default_compression
|
30
|
+
original = LibXML::XML.default_compression
|
31
31
|
|
32
32
|
0.upto(9) do |i|
|
33
|
-
XML.default_compression = i
|
34
|
-
assert_equal(i, XML.default_compression)
|
33
|
+
LibXML::XML.default_compression = i
|
34
|
+
assert_equal(i, LibXML::XML.default_compression)
|
35
35
|
end
|
36
36
|
|
37
37
|
9.downto(0) do |i|
|
38
|
-
assert_equal(i, XML.default_compression = i)
|
39
|
-
assert_equal(i, XML.default_compression)
|
38
|
+
assert_equal(i, LibXML::XML.default_compression = i)
|
39
|
+
assert_equal(i, LibXML::XML.default_compression)
|
40
40
|
end
|
41
41
|
|
42
42
|
0.downto(-10) do |i|
|
43
|
-
assert_equal(i, XML.default_compression = i)
|
44
|
-
assert_equal(0, XML.default_compression)
|
43
|
+
assert_equal(i, LibXML::XML.default_compression = i)
|
44
|
+
assert_equal(0, LibXML::XML.default_compression)
|
45
45
|
end
|
46
46
|
|
47
47
|
10.upto(20) do |i|
|
48
|
-
assert_equal(i, XML.default_compression = i)
|
49
|
-
assert_equal(9, XML.default_compression)
|
48
|
+
assert_equal(i, LibXML::XML.default_compression = i)
|
49
|
+
assert_equal(9, LibXML::XML.default_compression)
|
50
50
|
end
|
51
51
|
|
52
|
-
XML.default_compression = original
|
52
|
+
LibXML::XML.default_compression = original
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_default_keep_blanks
|
56
|
-
original = XML.default_keep_blanks
|
56
|
+
original = LibXML::XML.default_keep_blanks
|
57
57
|
|
58
|
-
XML.default_keep_blanks = false
|
59
|
-
refute(XML.default_keep_blanks)
|
60
|
-
assert_equal(XML::Parser::Options::NOBLANKS, XML.default_options)
|
58
|
+
LibXML::XML.default_keep_blanks = false
|
59
|
+
refute(LibXML::XML.default_keep_blanks)
|
60
|
+
assert_equal(LibXML::XML::Parser::Options::NOBLANKS, LibXML::XML.default_options)
|
61
61
|
|
62
|
-
XML.default_keep_blanks = true
|
63
|
-
assert(XML.default_keep_blanks)
|
64
|
-
assert_equal(0, XML.default_options)
|
62
|
+
LibXML::XML.default_keep_blanks = true
|
63
|
+
assert(LibXML::XML.default_keep_blanks)
|
64
|
+
assert_equal(0, LibXML::XML.default_options)
|
65
65
|
|
66
|
-
XML.default_keep_blanks = original
|
66
|
+
LibXML::XML.default_keep_blanks = original
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_default_line_numbers
|
70
|
-
original = XML.default_line_numbers
|
70
|
+
original = LibXML::XML.default_line_numbers
|
71
71
|
|
72
|
-
XML.default_line_numbers = false
|
73
|
-
refute(XML.default_line_numbers)
|
72
|
+
LibXML::XML.default_line_numbers = false
|
73
|
+
refute(LibXML::XML.default_line_numbers)
|
74
74
|
|
75
|
-
XML.default_line_numbers = true
|
76
|
-
assert(XML.default_line_numbers)
|
75
|
+
LibXML::XML.default_line_numbers = true
|
76
|
+
assert(LibXML::XML.default_line_numbers)
|
77
77
|
|
78
|
-
XML.default_line_numbers = false
|
79
|
-
refute(XML.default_line_numbers)
|
78
|
+
LibXML::XML.default_line_numbers = false
|
79
|
+
refute(LibXML::XML.default_line_numbers)
|
80
80
|
|
81
|
-
XML.default_line_numbers = original
|
81
|
+
LibXML::XML.default_line_numbers = original
|
82
82
|
end
|
83
83
|
|
84
84
|
def test_default_substitute_entities
|
85
|
-
original = XML.default_substitute_entities
|
85
|
+
original = LibXML::XML.default_substitute_entities
|
86
86
|
|
87
|
-
XML.default_substitute_entities = false
|
88
|
-
refute(XML.default_substitute_entities)
|
89
|
-
assert_equal(0, XML.default_options)
|
87
|
+
LibXML::XML.default_substitute_entities = false
|
88
|
+
refute(LibXML::XML.default_substitute_entities)
|
89
|
+
assert_equal(0, LibXML::XML.default_options)
|
90
90
|
|
91
|
-
XML.default_substitute_entities = true
|
92
|
-
assert(XML.default_substitute_entities)
|
93
|
-
assert_equal(XML::Parser::Options::NOENT, XML.default_options)
|
91
|
+
LibXML::XML.default_substitute_entities = true
|
92
|
+
assert(LibXML::XML.default_substitute_entities)
|
93
|
+
assert_equal(LibXML::XML::Parser::Options::NOENT, LibXML::XML.default_options)
|
94
94
|
|
95
|
-
XML.default_substitute_entities = false
|
96
|
-
refute(XML.default_substitute_entities)
|
95
|
+
LibXML::XML.default_substitute_entities = false
|
96
|
+
refute(LibXML::XML.default_substitute_entities)
|
97
97
|
|
98
|
-
XML.default_substitute_entities = original
|
98
|
+
LibXML::XML.default_substitute_entities = original
|
99
99
|
end
|
100
100
|
|
101
101
|
def test_default_tree_indent_string
|
102
|
-
original = XML.default_tree_indent_string
|
102
|
+
original = LibXML::XML.default_tree_indent_string
|
103
103
|
|
104
|
-
s = XML.default_tree_indent_string
|
104
|
+
s = LibXML::XML.default_tree_indent_string
|
105
105
|
assert_instance_of(String, s)
|
106
106
|
assert_equal(' ', s)
|
107
|
-
XML.default_tree_indent_string = 'uga'
|
108
|
-
s = XML.default_tree_indent_string
|
107
|
+
LibXML::XML.default_tree_indent_string = 'uga'
|
108
|
+
s = LibXML::XML.default_tree_indent_string
|
109
109
|
assert_instance_of(String, s)
|
110
110
|
assert_equal('uga', s)
|
111
|
-
XML.default_tree_indent_string = ' '
|
112
|
-
s = XML.default_tree_indent_string
|
111
|
+
LibXML::XML.default_tree_indent_string = ' '
|
112
|
+
s = LibXML::XML.default_tree_indent_string
|
113
113
|
assert_instance_of(String, s)
|
114
114
|
assert_equal(' ', s)
|
115
115
|
|
116
|
-
XML.default_tree_indent_string = original
|
116
|
+
LibXML::XML.default_tree_indent_string = original
|
117
117
|
end
|
118
118
|
|
119
119
|
def test_default_validity_checking
|
120
|
-
original = XML.default_validity_checking
|
120
|
+
original = LibXML::XML.default_validity_checking
|
121
121
|
|
122
|
-
XML.default_validity_checking = false
|
123
|
-
refute(XML.default_validity_checking)
|
124
|
-
assert_equal(0, XML.default_options)
|
122
|
+
LibXML::XML.default_validity_checking = false
|
123
|
+
refute(LibXML::XML.default_validity_checking)
|
124
|
+
assert_equal(0, LibXML::XML.default_options)
|
125
125
|
|
126
|
-
XML.default_validity_checking = true
|
127
|
-
assert(XML.default_validity_checking)
|
128
|
-
assert_equal(XML::Parser::Options::DTDVALID, XML.default_options)
|
126
|
+
LibXML::XML.default_validity_checking = true
|
127
|
+
assert(LibXML::XML.default_validity_checking)
|
128
|
+
assert_equal(LibXML::XML::Parser::Options::DTDVALID, LibXML::XML.default_options)
|
129
129
|
|
130
|
-
XML.default_validity_checking = false
|
131
|
-
refute(XML.default_validity_checking)
|
130
|
+
LibXML::XML.default_validity_checking = false
|
131
|
+
refute(LibXML::XML.default_validity_checking)
|
132
132
|
|
133
|
-
XML.default_validity_checking = original
|
133
|
+
LibXML::XML.default_validity_checking = original
|
134
134
|
end
|
135
135
|
|
136
136
|
def test_default_warnings
|
137
|
-
original = XML.default_warnings
|
137
|
+
original = LibXML::XML.default_warnings
|
138
138
|
|
139
|
-
XML.default_warnings = false
|
140
|
-
refute(XML.default_warnings)
|
141
|
-
assert_equal(XML::Parser::Options::NOWARNING, XML.default_options)
|
139
|
+
LibXML::XML.default_warnings = false
|
140
|
+
refute(LibXML::XML.default_warnings)
|
141
|
+
assert_equal(LibXML::XML::Parser::Options::NOWARNING, LibXML::XML.default_options)
|
142
142
|
|
143
|
-
XML.default_warnings = true
|
144
|
-
assert(XML.default_warnings)
|
145
|
-
assert_equal(0, XML.default_options)
|
143
|
+
LibXML::XML.default_warnings = true
|
144
|
+
assert(LibXML::XML.default_warnings)
|
145
|
+
assert_equal(0, LibXML::XML.default_options)
|
146
146
|
|
147
|
-
XML.default_warnings = false
|
148
|
-
refute(XML.default_warnings)
|
147
|
+
LibXML::XML.default_warnings = false
|
148
|
+
refute(LibXML::XML.default_warnings)
|
149
149
|
|
150
|
-
XML.default_warnings = original
|
150
|
+
LibXML::XML.default_warnings = original
|
151
151
|
end
|
152
152
|
|
153
153
|
def test_enabled_automata
|
154
|
-
assert(XML.enabled_automata?)
|
154
|
+
assert(LibXML::XML.enabled_automata?)
|
155
155
|
end
|
156
156
|
|
157
157
|
def test_enabled_c14n
|
158
|
-
assert(XML.enabled_c14n?)
|
158
|
+
assert(LibXML::XML.enabled_c14n?)
|
159
159
|
end
|
160
160
|
|
161
161
|
def test_enabled_catalog
|
162
|
-
assert(XML.enabled_catalog?)
|
162
|
+
assert(LibXML::XML.enabled_catalog?)
|
163
163
|
end
|
164
164
|
|
165
165
|
def test_enabled_debug
|
166
|
-
assert(XML.enabled_debug?)
|
166
|
+
assert(LibXML::XML.enabled_debug?)
|
167
167
|
end
|
168
168
|
|
169
169
|
def test_enabled_docbook
|
170
|
-
assert(XML.enabled_docbook?)
|
170
|
+
assert(LibXML::XML.enabled_docbook?)
|
171
171
|
end
|
172
172
|
|
173
173
|
def test_enabled_ftp
|
174
|
-
assert(XML.enabled_ftp?)
|
174
|
+
assert(LibXML::XML.enabled_ftp?)
|
175
175
|
end
|
176
176
|
|
177
177
|
def test_enabled_http
|
178
|
-
assert(XML.enabled_http?)
|
178
|
+
assert(LibXML::XML.enabled_http?)
|
179
179
|
end
|
180
180
|
|
181
181
|
def test_enabled_html
|
182
|
-
assert(XML.enabled_html?)
|
182
|
+
assert(LibXML::XML.enabled_html?)
|
183
183
|
end
|
184
184
|
|
185
185
|
def test_enabled_iconv
|
186
|
-
assert(XML.enabled_iconv?)
|
186
|
+
assert(LibXML::XML.enabled_iconv?)
|
187
187
|
end
|
188
188
|
|
189
189
|
def test_enabled_memory_debug
|
190
|
-
assert_equal(false, XML.enabled_memory_debug?)
|
190
|
+
assert_equal(false, LibXML::XML.enabled_memory_debug?)
|
191
191
|
end
|
192
192
|
|
193
193
|
def test_enabled_regexp
|
194
|
-
assert(XML.enabled_regexp?)
|
194
|
+
assert(LibXML::XML.enabled_regexp?)
|
195
195
|
end
|
196
196
|
|
197
197
|
def test_enabled_schemas
|
198
|
-
assert(XML.enabled_schemas?)
|
198
|
+
assert(LibXML::XML.enabled_schemas?)
|
199
199
|
end
|
200
200
|
|
201
201
|
def test_enabled_thread
|
202
|
-
assert(XML.enabled_thread?)
|
202
|
+
assert(LibXML::XML.enabled_thread?)
|
203
203
|
end
|
204
204
|
|
205
205
|
def test_enabled_unicode
|
206
|
-
assert(XML.enabled_unicode?)
|
206
|
+
assert(LibXML::XML.enabled_unicode?)
|
207
207
|
end
|
208
208
|
|
209
209
|
def test_enabled_xinclude
|
210
|
-
assert(XML.enabled_xinclude?)
|
210
|
+
assert(LibXML::XML.enabled_xinclude?)
|
211
211
|
end
|
212
212
|
|
213
213
|
def test_enabled_xpath
|
214
|
-
assert(XML.enabled_xpath?)
|
214
|
+
assert(LibXML::XML.enabled_xpath?)
|
215
215
|
end
|
216
216
|
|
217
217
|
def test_enabled_xpointer
|
218
|
-
assert(XML.enabled_xpointer?)
|
218
|
+
assert(LibXML::XML.enabled_xpointer?)
|
219
219
|
end
|
220
220
|
|
221
221
|
def test_enabled_zlib
|
222
|
-
assert(XML.enabled_zlib?.is_a?(TrueClass) || XML.enabled_zlib?.is_a?(FalseClass))
|
222
|
+
assert(LibXML::XML.enabled_zlib?.is_a?(TrueClass) || LibXML::XML.enabled_zlib?.is_a?(FalseClass))
|
223
223
|
end
|
224
224
|
|
225
225
|
def test_intent_tree_output
|
226
|
-
assert(TrueClass, XML.indent_tree_output)
|
226
|
+
assert(TrueClass, LibXML::XML.indent_tree_output)
|
227
227
|
|
228
|
-
XML.indent_tree_output = false
|
229
|
-
assert(FalseClass, XML.indent_tree_output)
|
228
|
+
LibXML::XML.indent_tree_output = false
|
229
|
+
assert(FalseClass, LibXML::XML.indent_tree_output)
|
230
230
|
|
231
|
-
XML.indent_tree_output = true
|
232
|
-
assert(TrueClass, XML.indent_tree_output)
|
231
|
+
LibXML::XML.indent_tree_output = true
|
232
|
+
assert(TrueClass, LibXML::XML.indent_tree_output)
|
233
233
|
end
|
234
234
|
|
235
235
|
def test_version
|
236
|
-
assert_instance_of(String, XML::VERSION)
|
236
|
+
assert_instance_of(String, LibXML::XML::VERSION)
|
237
237
|
end
|
238
238
|
|
239
239
|
def test_vernum
|
240
|
-
assert_instance_of(Integer, XML::VERNUM)
|
240
|
+
assert_instance_of(Integer, LibXML::XML::VERNUM)
|
241
241
|
end
|
242
242
|
|
243
243
|
def test_libxml_parser_features
|
244
|
-
assert_instance_of(Array, XML.features)
|
244
|
+
assert_instance_of(Array, LibXML::XML.features)
|
245
245
|
end
|
246
246
|
|
247
247
|
def test_default_options
|
248
|
-
assert_equal(0, XML.default_options)
|
248
|
+
assert_equal(0, LibXML::XML.default_options)
|
249
249
|
end
|
250
|
-
|
250
|
+
|
251
|
+
def test_default_save_no_empty_tags
|
252
|
+
original = LibXML::XML.default_save_no_empty_tags
|
253
|
+
|
254
|
+
LibXML::XML.default_save_no_empty_tags = false
|
255
|
+
refute(LibXML::XML.default_save_no_empty_tags)
|
256
|
+
|
257
|
+
LibXML::XML.default_save_no_empty_tags = true
|
258
|
+
assert(LibXML::XML.default_save_no_empty_tags)
|
259
|
+
|
260
|
+
LibXML::XML.default_save_no_empty_tags = original
|
261
|
+
end
|
262
|
+
end
|
data/test/test_xpath.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
require_relative './test_helper'
|
4
4
|
require 'tempfile'
|
5
5
|
|
6
6
|
class TestXPath < Minitest::Test
|
7
7
|
def setup
|
8
|
-
@doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
|
8
|
+
@doc = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
|
9
9
|
end
|
10
10
|
|
11
11
|
def teardown
|
@@ -14,14 +14,14 @@ class TestXPath < Minitest::Test
|
|
14
14
|
|
15
15
|
def test_doc_find
|
16
16
|
nodes = @doc.find('/soap:Envelope')
|
17
|
-
assert_instance_of(XML::XPath::Object, nodes)
|
17
|
+
assert_instance_of(LibXML::XML::XPath::Object, nodes)
|
18
18
|
assert_equal(1, nodes.length)
|
19
|
-
assert_equal(nodes.xpath_type, XML::XPath::NODESET)
|
19
|
+
assert_equal(nodes.xpath_type, LibXML::XML::XPath::NODESET)
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_doc_find_first
|
23
23
|
node = @doc.find_first('/soap:Envelope/soap:Body')
|
24
|
-
assert_instance_of(XML::Node, node)
|
24
|
+
assert_instance_of(LibXML::XML::Node, node)
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_ns
|
@@ -33,7 +33,7 @@ class TestXPath < Minitest::Test
|
|
33
33
|
_stress = GC.stress
|
34
34
|
GC.stress = true
|
35
35
|
|
36
|
-
doc = XML::Document.string('<foo xmlns="http://bar.com" />')
|
36
|
+
doc = LibXML::XML::Document.string('<foo xmlns="http://bar.com" />')
|
37
37
|
node = doc.root
|
38
38
|
# This line segfaults on prior versions of libxml-ruby
|
39
39
|
node.find("namespace::*")
|
@@ -89,7 +89,7 @@ class TestXPath < Minitest::Test
|
|
89
89
|
|
90
90
|
def test_default_ns5
|
91
91
|
# Find all nodes with http://services.somewhere.com namespace
|
92
|
-
XML::Namespace.new(@doc.root, 'ns', 'http://services.somewhere.com')
|
92
|
+
LibXML::XML::Namespace.new(@doc.root, 'ns', 'http://services.somewhere.com')
|
93
93
|
nodes = @doc.find('//ns:*')
|
94
94
|
assert_equal(2, nodes.length)
|
95
95
|
assert_equal('getManufacturerNamesResponse', nodes[0].name)
|
@@ -105,10 +105,10 @@ class TestXPath < Minitest::Test
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_register_default_ns
|
108
|
-
doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/atom.xml'))
|
108
|
+
doc = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'model/atom.xml'))
|
109
109
|
|
110
110
|
# No namespace has been yet defined
|
111
|
-
assert_raises(XML::Error) do
|
111
|
+
assert_raises(LibXML::XML::Error) do
|
112
112
|
doc.find("atom:title")
|
113
113
|
end
|
114
114
|
|
@@ -143,7 +143,7 @@ class TestXPath < Minitest::Test
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def test_node_no_doc
|
146
|
-
node = XML::Node.new('header', 'some content')
|
146
|
+
node = LibXML::XML::Node.new('header', 'some content')
|
147
147
|
assert_raises(TypeError) do
|
148
148
|
node = node.find_first('/header')
|
149
149
|
end
|
@@ -157,11 +157,11 @@ class TestXPath < Minitest::Test
|
|
157
157
|
# to the document's nodes. A segmentation fault then happens.
|
158
158
|
|
159
159
|
1000.times do
|
160
|
-
doc = XML::Document.new('1.0')
|
161
|
-
doc.root = XML::Node.new("header")
|
160
|
+
doc = LibXML::XML::Document.new('1.0')
|
161
|
+
doc.root = LibXML::XML::Node.new("header")
|
162
162
|
|
163
163
|
1000.times do
|
164
|
-
doc.root << XML::Node.new("footer")
|
164
|
+
doc.root << LibXML::XML::Node.new("footer")
|
165
165
|
end
|
166
166
|
|
167
167
|
doc.find('/header/footer')
|
@@ -170,35 +170,35 @@ class TestXPath < Minitest::Test
|
|
170
170
|
|
171
171
|
# Test that document doesn't get freed before nodes
|
172
172
|
def test_xpath_free
|
173
|
-
doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
|
173
|
+
doc = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
|
174
174
|
nodes = doc.find('//*')
|
175
175
|
GC.start
|
176
176
|
assert_equal('Envelope', nodes.first.name)
|
177
177
|
end
|
178
178
|
|
179
179
|
def test_xpath_namespace_nodes
|
180
|
-
doc = XML::Document.string('<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xhtml="http://www.w3.org/1999/xhtml"><entry/></feed>')
|
180
|
+
doc = LibXML::XML::Document.string('<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xhtml="http://www.w3.org/1999/xhtml"><entry/></feed>')
|
181
181
|
nodes = doc.find('//atom:entry|namespace::*', :atom => "http://www.w3.org/2005/Atom")
|
182
182
|
assert_equal(4, nodes.length)
|
183
183
|
|
184
184
|
node = nodes[0]
|
185
|
-
assert_equal(XML::Node::ELEMENT_NODE, node.node_type)
|
185
|
+
assert_equal(LibXML::XML::Node::ELEMENT_NODE, node.node_type)
|
186
186
|
|
187
187
|
node = nodes[1]
|
188
|
-
assert_equal(XML::Node::NAMESPACE_DECL, node.node_type)
|
188
|
+
assert_equal(LibXML::XML::Node::NAMESPACE_DECL, node.node_type)
|
189
189
|
|
190
190
|
node = nodes[2]
|
191
|
-
assert_equal(XML::Node::NAMESPACE_DECL, node.node_type)
|
191
|
+
assert_equal(LibXML::XML::Node::NAMESPACE_DECL, node.node_type)
|
192
192
|
|
193
193
|
node = nodes[3]
|
194
|
-
assert_equal(XML::Node::NAMESPACE_DECL, node.node_type)
|
194
|
+
assert_equal(LibXML::XML::Node::NAMESPACE_DECL, node.node_type)
|
195
195
|
end
|
196
196
|
|
197
197
|
# Test to make sure we don't get nil on empty results.
|
198
198
|
# This is also to test that we don't segfault due to our C code getting a NULL pointer
|
199
199
|
# and not handling it properly.
|
200
200
|
def test_xpath_empty_result
|
201
|
-
doc = XML::Document.string('<html><body><p>Welcome to XHTML land!</p></body></html>')
|
201
|
+
doc = LibXML::XML::Document.string('<html><body><p>Welcome to XHTML land!</p></body></html>')
|
202
202
|
nodes = doc.find("//object/param[translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'wmode']")
|
203
203
|
refute_nil nodes
|
204
204
|
end
|
@@ -207,13 +207,13 @@ class TestXPath < Minitest::Test
|
|
207
207
|
xml = LibXML::XML::Document.string('<a></a>')
|
208
208
|
|
209
209
|
# Using the expression twice used to cause a Segmentation Fault
|
210
|
-
error = assert_raises(XML::Error) do
|
210
|
+
error = assert_raises(LibXML::XML::Error) do
|
211
211
|
xml.find('//a/')
|
212
212
|
end
|
213
213
|
assert_equal("Error: Invalid expression.", error.to_s)
|
214
214
|
|
215
215
|
# Try again - this used to cause a Segmentation Fault
|
216
|
-
error = assert_raises(XML::Error) do
|
216
|
+
error = assert_raises(LibXML::XML::Error) do
|
217
217
|
xml.find('//a/')
|
218
218
|
end
|
219
219
|
assert_equal("Error: Invalid expression.", error.to_s)
|