libxml-ruby 3.1.0-x64-mingw32 → 3.2.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +8 -0
  3. data/ext/libxml/extconf.h +3 -0
  4. data/ext/libxml/extconf.rb +30 -26
  5. data/ext/libxml/ruby_libxml.h +0 -8
  6. data/ext/libxml/ruby_xml.c +40 -0
  7. data/ext/libxml/ruby_xml_document.c +1 -1
  8. data/ext/libxml/ruby_xml_dtd.c +6 -8
  9. data/ext/libxml/ruby_xml_node.c +1 -1
  10. data/ext/libxml/ruby_xml_parser_context.c +1 -1
  11. data/ext/libxml/ruby_xml_version.h +3 -3
  12. data/lib/2.7/libxml_ruby.so +0 -0
  13. data/lib/libxml-ruby.rb +30 -0
  14. data/lib/libxml.rb +3 -28
  15. data/libxml-ruby.gemspec +2 -2
  16. data/test/test_attr.rb +18 -18
  17. data/test/test_attr_decl.rb +8 -8
  18. data/test/test_attributes.rb +10 -10
  19. data/test/test_canonicalize.rb +16 -24
  20. data/test/test_deprecated_require.rb +3 -3
  21. data/test/test_document.rb +118 -112
  22. data/test/test_document_write.rb +39 -88
  23. data/test/test_dtd.rb +23 -23
  24. data/test/test_encoding.rb +15 -15
  25. data/test/test_encoding_sax.rb +3 -3
  26. data/test/test_error.rb +51 -51
  27. data/test/test_helper.rb +2 -9
  28. data/test/test_html_parser.rb +30 -30
  29. data/test/test_html_parser_context.rb +6 -6
  30. data/test/test_namespace.rb +16 -16
  31. data/test/test_namespaces.rb +25 -25
  32. data/test/test_node.rb +36 -30
  33. data/test/test_node_cdata.rb +10 -10
  34. data/test/test_node_comment.rb +6 -6
  35. data/test/test_node_copy.rb +2 -2
  36. data/test/test_node_edit.rb +16 -16
  37. data/test/test_node_pi.rb +7 -7
  38. data/test/test_node_text.rb +6 -6
  39. data/test/test_node_write.rb +16 -26
  40. data/test/test_node_xlink.rb +6 -6
  41. data/test/test_parser.rb +68 -72
  42. data/test/test_parser_context.rb +28 -28
  43. data/test/test_properties.rb +5 -5
  44. data/test/test_reader.rb +80 -85
  45. data/test/test_relaxng.rb +11 -11
  46. data/test/test_sax_parser.rb +28 -28
  47. data/test/test_schema.rb +24 -24
  48. data/test/test_suite.rb +3 -4
  49. data/test/test_traversal.rb +4 -4
  50. data/test/test_writer.rb +50 -52
  51. data/test/test_xinclude.rb +3 -3
  52. data/test/test_xml.rb +114 -102
  53. data/test/test_xpath.rb +22 -22
  54. data/test/test_xpath_context.rb +5 -5
  55. data/test/test_xpath_expression.rb +6 -6
  56. data/test/test_xpointer.rb +15 -15
  57. metadata +7 -5
@@ -1,46 +1,46 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
  class CDataCommentTest < Minitest::Test
6
6
  def setup
7
- xp = XML::Parser.string('<root></root>')
7
+ xp = LibXML::XML::Parser.string('<root></root>')
8
8
  @doc = xp.parse
9
- assert_instance_of(XML::Document, @doc)
9
+ assert_instance_of(LibXML::XML::Document, @doc)
10
10
  @root = @doc.root
11
11
  end
12
12
 
13
13
  def test_node_type
14
- cnode = XML::Node.new_cdata('test cdata')
15
- assert_equal(XML::Node::CDATA_SECTION_NODE, cnode.node_type)
14
+ cnode = LibXML::XML::Node.new_cdata('test cdata')
15
+ assert_equal(LibXML::XML::Node::CDATA_SECTION_NODE, cnode.node_type)
16
16
  end
17
17
 
18
18
  def test_add_cdata
19
- @root << XML::Node.new_cdata('mycdata')
19
+ @root << LibXML::XML::Node.new_cdata('mycdata')
20
20
  assert_equal '<root><![CDATA[mycdata]]></root>',
21
21
  @root.to_s.gsub(/\n\s*/,'')
22
22
  end
23
23
 
24
24
  def test_add_cdata_2
25
- @root << XML::Node.new_cdata('mycdata')
25
+ @root << LibXML::XML::Node.new_cdata('mycdata')
26
26
  assert_equal 'cdata',
27
27
  @root.child.node_type_name
28
28
  end
29
29
 
30
30
  def test_add_cdata_3
31
- @root << el = XML::Node.new_cdata('mycdata')
31
+ @root << el = LibXML::XML::Node.new_cdata('mycdata')
32
32
  el << "_this_is_added"
33
33
  assert_equal '<root><![CDATA[mycdata_this_is_added]]></root>',
34
34
  @root.to_s.gsub(/\n\s*/,'')
35
35
  end
36
36
 
37
37
  def test_attributes
38
- cnode = XML::Node.new_cdata('test cdata')
38
+ cnode = LibXML::XML::Node.new_cdata('test cdata')
39
39
  assert_equal(0, cnode.attributes.length)
40
40
  end
41
41
 
42
42
  def test_set_cdata_attribute
43
- cnode = XML::Node.new_cdata('test cdata')
43
+ cnode = LibXML::XML::Node.new_cdata('test cdata')
44
44
 
45
45
  # Can't create attributes on non-element nodes
46
46
  assert_raises(ArgumentError) do
@@ -1,30 +1,30 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
 
6
6
  class NodeCommentTest < Minitest::Test
7
7
  def setup
8
- xp = XML::Parser.string('<root></root>')
8
+ xp = LibXML::XML::Parser.string('<root></root>')
9
9
  @doc = xp.parse
10
- assert_instance_of(XML::Document, @doc)
10
+ assert_instance_of(LibXML::XML::Document, @doc)
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
14
  def test_libxml_node_add_comment_01
15
- @root << XML::Node.new_comment('mycomment')
15
+ @root << LibXML::XML::Node.new_comment('mycomment')
16
16
  assert_equal '<root><!--mycomment--></root>',
17
17
  @root.to_s.gsub(/\n\s*/,'')
18
18
  end
19
19
 
20
20
  def test_libxml_node_add_comment_02
21
- @root << XML::Node.new_comment('mycomment')
21
+ @root << LibXML::XML::Node.new_comment('mycomment')
22
22
  assert_equal 'comment',
23
23
  @root.child.node_type_name
24
24
  end
25
25
 
26
26
  def test_libxml_node_add_comment_03
27
- @root << el = XML::Node.new_comment('mycomment')
27
+ @root << el = LibXML::XML::Node.new_comment('mycomment')
28
28
  el << "_this_is_added"
29
29
  assert_equal '<root><!--mycomment_this_is_added--></root>',
30
30
  @root.to_s.gsub(/\n\s*/,'')
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
  # see mailing list archive
6
6
  # [libxml-devel] Segmentation fault when add the cloned/copied node
@@ -15,7 +15,7 @@ class TestNodeCopy < Minitest::Test
15
15
  </body></html>
16
16
  STR
17
17
 
18
- doc = XML::Parser.string(str).parse
18
+ doc = LibXML::XML::Parser.string(str).parse
19
19
 
20
20
  xpath = "//div"
21
21
  @div1 = doc.find(xpath).to_a[0]
@@ -1,10 +1,10 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
  class TestNodeEdit < Minitest::Test
6
6
  def setup
7
- xp = XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
7
+ xp = LibXML::XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
8
8
  @doc = xp.parse
9
9
  end
10
10
 
@@ -25,37 +25,37 @@ class TestNodeEdit < Minitest::Test
25
25
  end
26
26
 
27
27
  def test_add_next_01
28
- first_node.next = XML::Node.new('num', 'one-and-a-half')
28
+ first_node.next = LibXML::XML::Node.new('num', 'one-and-a-half')
29
29
  assert_equal('<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
30
30
  @doc.root.to_s.gsub(/\n\s*/,''))
31
31
  end
32
32
 
33
33
  def test_add_next_02
34
- second_node.next = XML::Node.new('num', 'two-and-a-half')
34
+ second_node.next = LibXML::XML::Node.new('num', 'two-and-a-half')
35
35
  assert_equal('<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
36
36
  @doc.root.to_s.gsub(/\n\s*/,''))
37
37
  end
38
38
 
39
39
  def test_add_next_03
40
- third_node.next = XML::Node.new('num', 'four')
40
+ third_node.next = LibXML::XML::Node.new('num', 'four')
41
41
  assert_equal '<test><num>one</num><num>two</num><num>three</num><num>four</num></test>',
42
42
  @doc.root.to_s.gsub(/\n\s*/,'')
43
43
  end
44
44
 
45
45
  def test_add_prev_01
46
- first_node.prev = XML::Node.new('num', 'half')
46
+ first_node.prev = LibXML::XML::Node.new('num', 'half')
47
47
  assert_equal '<test><num>half</num><num>one</num><num>two</num><num>three</num></test>',
48
48
  @doc.root.to_s.gsub(/\n\s*/,'')
49
49
  end
50
50
 
51
51
  def test_add_prev_02
52
- second_node.prev = XML::Node.new('num', 'one-and-a-half')
52
+ second_node.prev = LibXML::XML::Node.new('num', 'one-and-a-half')
53
53
  assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
54
54
  @doc.root.to_s.gsub(/\n\s*/,'')
55
55
  end
56
56
 
57
57
  def test_add_prev_03
58
- third_node.prev = XML::Node.new('num', 'two-and-a-half')
58
+ third_node.prev = LibXML::XML::Node.new('num', 'two-and-a-half')
59
59
  assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
60
60
  @doc.root.to_s.gsub(/\n\s*/,'')
61
61
  end
@@ -67,7 +67,7 @@ class TestNodeEdit < Minitest::Test
67
67
  end
68
68
 
69
69
  def test_remove_node_gc
70
- xp = XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
70
+ xp = LibXML::XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
71
71
  doc = xp.parse
72
72
  doc.root.child.remove!
73
73
  GC.start
@@ -98,7 +98,7 @@ class TestNodeEdit < Minitest::Test
98
98
  end
99
99
 
100
100
  def test_append_existing_node
101
- doc = XML::Parser.string('<top>a<bottom>b<one>first</one><two>second</two>c</bottom>d</top>').parse
101
+ doc = LibXML::XML::Parser.string('<top>a<bottom>b<one>first</one><two>second</two>c</bottom>d</top>').parse
102
102
  node1 = doc.find_first('//two')
103
103
 
104
104
  doc.root << node1
@@ -107,17 +107,17 @@ class TestNodeEdit < Minitest::Test
107
107
  end
108
108
 
109
109
  def test_wrong_doc
110
- doc1 = XML::Parser.string('<nums><one></one></nums>').parse
111
- doc2 = XML::Parser.string('<nums><two></two></nums>').parse
110
+ doc1 = LibXML::XML::Parser.string('<nums><one></one></nums>').parse
111
+ doc2 = LibXML::XML::Parser.string('<nums><two></two></nums>').parse
112
112
 
113
113
  node = doc1.root.child
114
114
 
115
- error = assert_raises(XML::Error) do
115
+ error = assert_raises(LibXML::XML::Error) do
116
116
  doc2.root << node
117
117
  end
118
118
 
119
119
  GC.start
120
- assert_equal(' Nodes belong to different documents. You must first import the node by calling XML::Document.import.',
120
+ assert_equal(' Nodes belong to different documents. You must first import the node by calling LibXML::XML::Document.import.',
121
121
  error.to_s)
122
122
  end
123
123
 
@@ -127,7 +127,7 @@ class TestNodeEdit < Minitest::Test
127
127
 
128
128
  # Read in 500 documents
129
129
  500.times do
130
- documents << XML::Parser.string(File.read(File.join(File.dirname(__FILE__), 'model', 'merge_bug_data.xml'))).parse
130
+ documents << LibXML::XML::Parser.string(File.read(File.join(File.dirname(__FILE__), 'model', 'merge_bug_data.xml'))).parse
131
131
  end
132
132
 
133
133
  master_doc = documents.shift
@@ -145,7 +145,7 @@ class TestNodeEdit < Minitest::Test
145
145
  end
146
146
 
147
147
  def test_append_chain
148
- node = XML::Node.new('foo') << XML::Node.new('bar') << "bars contents"
148
+ node = LibXML::XML::Node.new('foo') << LibXML::XML::Node.new('bar') << "bars contents"
149
149
  assert_equal('<foo><bar/>bars contents</foo>',
150
150
  node.to_s)
151
151
  end
@@ -1,36 +1,36 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
  class NodePiTest < Minitest::Test
6
6
  def setup
7
- xp = XML::Parser.string('<root></root>')
7
+ xp = LibXML::XML::Parser.string('<root></root>')
8
8
  @doc = xp.parse
9
- assert_instance_of(XML::Document, @doc)
9
+ assert_instance_of(LibXML::XML::Document, @doc)
10
10
  @root = @doc.root
11
11
  end
12
12
 
13
13
  def test_libxml_node_add_pi_01
14
- @root << XML::Node.new_pi('mypi')
14
+ @root << LibXML::XML::Node.new_pi('mypi')
15
15
  assert_equal '<root><?mypi?></root>',
16
16
  @root.to_s.gsub(/\n\s*/,'')
17
17
  end
18
18
 
19
19
  def test_libxml_node_add_pi_02
20
- @root << XML::Node.new_pi('mypi')
20
+ @root << LibXML::XML::Node.new_pi('mypi')
21
21
  assert_equal 'pi',
22
22
  @root.child.node_type_name
23
23
  end
24
24
 
25
25
  def test_libxml_node_add_pi_03
26
- @root << el = XML::Node.new_pi('mypi')
26
+ @root << el = LibXML::XML::Node.new_pi('mypi')
27
27
  el << "_this_is_added"
28
28
  assert_equal '<root><?mypi _this_is_added?></root>',
29
29
  @root.to_s.gsub(/\n\s*/,'')
30
30
  end
31
31
 
32
32
  def test_libxml_node_add_pi_04
33
- @root << XML::Node.new_pi('mypi','mycontent')
33
+ @root << LibXML::XML::Node.new_pi('mypi','mycontent')
34
34
  assert_equal '<root><?mypi mycontent?></root>',
35
35
  @root.to_s.gsub(/\n\s*/,'')
36
36
  end
@@ -1,17 +1,17 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
  class TestTextNode < Minitest::Test
6
6
  def test_content
7
- node = XML::Node.new_text('testdata')
8
- assert_instance_of(XML::Node, node)
7
+ node = LibXML::XML::Node.new_text('testdata')
8
+ assert_instance_of(LibXML::XML::Node, node)
9
9
  assert_equal('testdata', node.content)
10
10
  end
11
11
 
12
12
  def test_invalid_content
13
13
  error = assert_raises(TypeError) do
14
- XML::Node.new_text(nil)
14
+ LibXML::XML::Node.new_text(nil)
15
15
  end
16
16
  assert_equal('wrong argument type nil (expected String)', error.to_s)
17
17
  end
@@ -27,7 +27,7 @@ class TestTextNode < Minitest::Test
27
27
  textnoenc = 'if (a < b || c > d) return "e";'
28
28
  text = "if (a &lt; b || c &gt; d) return \"e\";"
29
29
 
30
- node = XML::Node.new_text(textnoenc)
30
+ node = LibXML::XML::Node.new_text(textnoenc)
31
31
  assert node.output_escaping?
32
32
  assert_equal text, node.to_s
33
33
 
@@ -46,7 +46,7 @@ class TestTextNode < Minitest::Test
46
46
 
47
47
  # Just a sanity check for output escaping.
48
48
  def test_output_escaping_sanity
49
- node = XML::Node.new_text('testdata')
49
+ node = LibXML::XML::Node.new_text('testdata')
50
50
  assert_equal 'text', node.name
51
51
  assert node.output_escaping?
52
52
 
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
  class TestNodeWrite < Minitest::Test
6
6
  def setup
@@ -8,24 +8,24 @@ class TestNodeWrite < Minitest::Test
8
8
  end
9
9
 
10
10
  def teardown
11
- XML.default_keep_blanks = true
11
+ LibXML::XML.default_keep_blanks = true
12
12
  @doc = nil
13
13
  end
14
14
 
15
15
  def load_encoding(name)
16
- @encoding = Encoding.find(name) if defined?(Encoding)
16
+ @encoding = Encoding.find(name)
17
17
  @file_name = "model/bands.#{name.downcase}.xml"
18
18
 
19
19
  # Strip spaces to make testing easier
20
- XML.default_keep_blanks = false
20
+ LibXML::XML.default_keep_blanks = false
21
21
  file = File.join(File.dirname(__FILE__), @file_name)
22
- @doc = XML::Document.file(file)
22
+ @doc = LibXML::XML::Document.file(file)
23
23
  end
24
24
 
25
25
  def test_to_s_default
26
26
  # Default to_s has indentation
27
27
  node = @doc.root
28
- assert_equal(Encoding::UTF_8, node.to_s.encoding) if defined?(Encoding)
28
+ assert_equal(Encoding::UTF_8, node.to_s.encoding)
29
29
  assert_equal("<bands genre=\"metal\">\n <m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>",
30
30
  node.to_s)
31
31
  end
@@ -33,11 +33,11 @@ class TestNodeWrite < Minitest::Test
33
33
  def test_to_s_no_global_indentation
34
34
  # No indentation due to global setting
35
35
  node = @doc.root
36
- XML.indent_tree_output = false
36
+ LibXML::XML.indent_tree_output = false
37
37
  assert_equal("<bands genre=\"metal\">\n<m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n<iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>",
38
38
  node.to_s)
39
39
  ensure
40
- XML.indent_tree_output = true
40
+ LibXML::XML.indent_tree_output = true
41
41
  end
42
42
 
43
43
  def test_to_s_no_indentation
@@ -61,23 +61,18 @@ class TestNodeWrite < Minitest::Test
61
61
  # UTF8:
62
62
  # ö - c3 b6 in hex, \303\266 in octal
63
63
  # ü - c3 bc in hex, \303\274 in octal
64
- value = node.to_s(:encoding => XML::Encoding::UTF_8)
65
- assert_equal(Encoding::UTF_8, node.to_s.encoding) if defined?(Encoding)
64
+ value = node.to_s(:encoding => LibXML::XML::Encoding::UTF_8)
65
+ assert_equal(Encoding::UTF_8, node.to_s.encoding)
66
66
  assert_equal("<bands genre=\"metal\">\n <m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>",
67
67
  value)
68
68
 
69
69
  # ISO_8859_1:
70
70
  # ö - f6 in hex, \366 in octal
71
71
  # ü - fc in hex, \374 in octal
72
- value = node.to_s(:encoding => XML::Encoding::ISO_8859_1)
73
- if defined?(Encoding)
74
- assert_equal(Encoding::ISO8859_1, value.encoding)
75
- assert_equal("<bands genre=\"metal\">\n <m\xF6tley_cr\xFCe country=\"us\">M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\xF6tley_cr\xFCe>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>".force_encoding(Encoding::ISO8859_1),
76
- value)
77
- else
78
- assert_equal("<bands genre=\"metal\">\n <m\xF6tley_cr\xFCe country=\"us\">M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\xF6tley_cr\xFCe>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>",
72
+ value = node.to_s(:encoding => LibXML::XML::Encoding::ISO_8859_1)
73
+ assert_equal(Encoding::ISO8859_1, value.encoding)
74
+ assert_equal("<bands genre=\"metal\">\n <m\xF6tley_cr\xFCe country=\"us\">M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\xF6tley_cr\xFCe>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>".force_encoding(Encoding::ISO8859_1),
79
75
  value)
80
- end
81
76
 
82
77
  # Invalid encoding
83
78
  error = assert_raises(ArgumentError) do
@@ -90,14 +85,9 @@ class TestNodeWrite < Minitest::Test
90
85
  # Default to_s has indentation
91
86
  node = @doc.root
92
87
 
93
- if defined?(Encoding)
94
- assert_equal(Encoding::UTF_8, node.inner_xml.encoding)
95
- assert_equal("<m\u00F6tley_cr\u00FCe country=\"us\">M\u00F6tley Cr\u00FCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\u00F6tley_cr\u00FCe><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>",
96
- node.inner_xml)
97
- else
98
- assert_equal("<m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>",
99
- node.inner_xml)
100
- end
88
+ assert_equal(Encoding::UTF_8, node.inner_xml.encoding)
89
+ assert_equal("<m\u00F6tley_cr\u00FCe country=\"us\">M\u00F6tley Cr\u00FCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\u00F6tley_cr\u00FCe><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>",
90
+ node.inner_xml)
101
91
  end
102
92
 
103
93
  # --- Debug ---
@@ -1,16 +1,16 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  # $Id$
4
- require File.expand_path('../test_helper', __FILE__)
4
+ require_relative './test_helper'
5
5
 
6
6
 
7
7
  class TC_XML_Node_XLink < Minitest::Test
8
8
  def setup()
9
- xp = XML::Parser.string('<ruby_array xmlns:xlink="http://www.w3.org/1999/xlink/namespace/"><fixnum xlink:type="simple">one</fixnum></ruby_array>')
9
+ xp = LibXML::XML::Parser.string('<ruby_array xmlns:xlink="http://www.w3.org/1999/xlink/namespace/"><fixnum xlink:type="simple">one</fixnum></ruby_array>')
10
10
  doc = xp.parse
11
- assert_instance_of(XML::Document, doc)
11
+ assert_instance_of(LibXML::XML::Document, doc)
12
12
  @root = doc.root
13
- assert_instance_of(XML::Node, @root)
13
+ assert_instance_of(LibXML::XML::Node, @root)
14
14
  end
15
15
 
16
16
  def teardown()
@@ -19,10 +19,10 @@ class TC_XML_Node_XLink < Minitest::Test
19
19
 
20
20
  def test_xml_node_xlink()
21
21
  for elem in @root.find('fixnum')
22
- assert_instance_of(XML::Node, elem)
22
+ assert_instance_of(LibXML::XML::Node, elem)
23
23
  assert_instance_of(TrueClass, elem.xlink?)
24
24
  assert_equal("simple", elem.xlink_type_name)
25
- assert_equal(XML::Node::XLINK_TYPE_SIMPLE, elem.xlink_type)
25
+ assert_equal(LibXML::XML::Node::XLINK_TYPE_SIMPLE, elem.xlink_type)
26
26
  end
27
27
  end
28
28
  end
@@ -1,47 +1,47 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
  require 'stringio'
5
5
 
6
6
  class TestParser < Minitest::Test
7
7
  def setup
8
- XML::Error.set_handler(&XML::Error::QUIET_HANDLER)
8
+ LibXML::XML::Error.set_handler(&LibXML::XML::Error::QUIET_HANDLER)
9
9
  end
10
10
 
11
11
  # ----- Sources -------
12
12
  def test_document
13
13
  file = File.expand_path(File.join(File.dirname(__FILE__), 'model/bands.utf-8.xml'))
14
- parser = XML::Parser.file(file)
14
+ parser = LibXML::XML::Parser.file(file)
15
15
  doc = parser.parse
16
16
 
17
- parser = XML::Parser.document(doc)
17
+ parser = LibXML::XML::Parser.document(doc)
18
18
 
19
19
  doc = parser.parse
20
20
 
21
- assert_instance_of(XML::Document, doc)
22
- assert_instance_of(XML::Parser::Context, parser.context)
21
+ assert_instance_of(LibXML::XML::Document, doc)
22
+ assert_instance_of(LibXML::XML::Parser::Context, parser.context)
23
23
  end
24
24
 
25
25
  def test_nil_document
26
26
  error = assert_raises(TypeError) do
27
- XML::Parser.document(nil)
27
+ LibXML::XML::Parser.document(nil)
28
28
  end
29
29
 
30
- assert_equal("Must pass an XML::Document object", error.to_s)
30
+ assert_equal("Must pass an LibXML::XML::Document object", error.to_s)
31
31
  end
32
32
 
33
33
  def test_file
34
34
  file = File.expand_path(File.join(File.dirname(__FILE__), 'model/rubynet.xml'))
35
35
 
36
- parser = XML::Parser.file(file)
36
+ parser = LibXML::XML::Parser.file(file)
37
37
  doc = parser.parse
38
- assert_instance_of(XML::Document, doc)
39
- assert_instance_of(XML::Parser::Context, parser.context)
38
+ assert_instance_of(LibXML::XML::Document, doc)
39
+ assert_instance_of(LibXML::XML::Parser::Context, parser.context)
40
40
  end
41
41
 
42
42
  def test_noexistent_file
43
- error = assert_raises(XML::Error) do
44
- XML::Parser.file('i_dont_exist.xml')
43
+ error = assert_raises(LibXML::XML::Error) do
44
+ LibXML::XML::Parser.file('i_dont_exist.xml')
45
45
  end
46
46
 
47
47
  assert_equal('Warning: failed to load external entity "i_dont_exist.xml".', error.to_s)
@@ -49,7 +49,7 @@ class TestParser < Minitest::Test
49
49
 
50
50
  def test_nil_file
51
51
  error = assert_raises(TypeError) do
52
- XML::Parser.file(nil)
52
+ LibXML::XML::Parser.file(nil)
53
53
  end
54
54
 
55
55
  assert_match(/nil into String/, error.to_s)
@@ -57,15 +57,15 @@ class TestParser < Minitest::Test
57
57
 
58
58
  def test_file_encoding
59
59
  file = File.expand_path(File.join(File.dirname(__FILE__), 'model/bands.utf-8.xml'))
60
- parser = XML::Parser.file(file, :encoding => XML::Encoding::ISO_8859_1)
60
+ parser = LibXML::XML::Parser.file(file, :encoding => LibXML::XML::Encoding::ISO_8859_1)
61
61
 
62
- error = assert_raises(XML::Error) do
62
+ error = assert_raises(LibXML::XML::Error) do
63
63
  parser.parse
64
64
  end
65
65
 
66
66
  assert(error.to_s.match(/Fatal error: Extra content at the end of the document/))
67
67
 
68
- parser = XML::Parser.file(file, :encoding => XML::Encoding::UTF_8)
68
+ parser = LibXML::XML::Parser.file(file, :encoding => LibXML::XML::Encoding::UTF_8)
69
69
  doc = parser.parse
70
70
  refute_nil(doc)
71
71
  end
@@ -73,23 +73,23 @@ class TestParser < Minitest::Test
73
73
  def test_file_base_uri
74
74
  file = File.expand_path(File.join(File.dirname(__FILE__), 'model/bands.utf-8.xml'))
75
75
 
76
- parser = XML::Parser.file(file)
76
+ parser = LibXML::XML::Parser.file(file)
77
77
  doc = parser.parse
78
78
  assert(doc.child.base_uri.match(/test\/model\/bands.utf-8.xml/))
79
79
 
80
- parser = XML::Parser.file(file, :base_uri => "http://libxml.org")
80
+ parser = LibXML::XML::Parser.file(file, :base_uri => "http://libxml.org")
81
81
  doc = parser.parse
82
82
  assert(doc.child.base_uri.match(/test\/model\/bands.utf-8.xml/))
83
83
  end
84
84
 
85
85
  def test_io
86
86
  File.open(File.join(File.dirname(__FILE__), 'model/rubynet.xml')) do |io|
87
- parser = XML::Parser.io(io)
88
- assert_instance_of(XML::Parser, parser)
87
+ parser = LibXML::XML::Parser.io(io)
88
+ assert_instance_of(LibXML::XML::Parser, parser)
89
89
 
90
90
  doc = parser.parse
91
- assert_instance_of(XML::Document, doc)
92
- assert_instance_of(XML::Parser::Context, parser.context)
91
+ assert_instance_of(LibXML::XML::Document, doc)
92
+ assert_instance_of(LibXML::XML::Parser::Context, parser.context)
93
93
  end
94
94
  end
95
95
 
@@ -97,7 +97,7 @@ class TestParser < Minitest::Test
97
97
  # Test that the reader keeps a reference
98
98
  # to the io object
99
99
  file = File.open(File.join(File.dirname(__FILE__), 'model/rubynet.xml'))
100
- parser = XML::Parser.io(file)
100
+ parser = LibXML::XML::Parser.io(file)
101
101
  file = nil
102
102
  GC.start
103
103
  assert(parser.parse)
@@ -105,7 +105,7 @@ class TestParser < Minitest::Test
105
105
 
106
106
  def test_nil_io
107
107
  error = assert_raises(TypeError) do
108
- XML::Parser.io(nil)
108
+ LibXML::XML::Parser.io(nil)
109
109
  end
110
110
 
111
111
  assert_equal("Must pass in an IO object", error.to_s)
@@ -114,22 +114,22 @@ class TestParser < Minitest::Test
114
114
  def test_string_io
115
115
  data = File.read(File.join(File.dirname(__FILE__), 'model/rubynet.xml'))
116
116
  string_io = StringIO.new(data)
117
- parser = XML::Parser.io(string_io)
117
+ parser = LibXML::XML::Parser.io(string_io)
118
118
 
119
119
  doc = parser.parse
120
- assert_instance_of(XML::Document, doc)
121
- assert_instance_of(XML::Parser::Context, parser.context)
120
+ assert_instance_of(LibXML::XML::Document, doc)
121
+ assert_instance_of(LibXML::XML::Parser::Context, parser.context)
122
122
  end
123
123
 
124
124
  def test_string_io_thread
125
125
  thread = Thread.new do
126
126
  data = File.read(File.join(File.dirname(__FILE__), 'model/rubynet.xml'))
127
127
  string_io = StringIO.new(data)
128
- parser = XML::Parser.io(string_io)
128
+ parser = LibXML::XML::Parser.io(string_io)
129
129
 
130
130
  doc = parser.parse
131
- assert_instance_of(XML::Document, doc)
132
- assert_instance_of(XML::Parser::Context, parser.context)
131
+ assert_instance_of(LibXML::XML::Document, doc)
132
+ assert_instance_of(LibXML::XML::Parser::Context, parser.context)
133
133
  end
134
134
 
135
135
  thread.join
@@ -140,17 +140,17 @@ class TestParser < Minitest::Test
140
140
  def test_string
141
141
  str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
142
142
 
143
- parser = XML::Parser.string(str)
144
- assert_instance_of(XML::Parser, parser)
143
+ parser = LibXML::XML::Parser.string(str)
144
+ assert_instance_of(LibXML::XML::Parser, parser)
145
145
 
146
146
  doc = parser.parse
147
- assert_instance_of(XML::Document, doc)
148
- assert_instance_of(XML::Parser::Context, parser.context)
147
+ assert_instance_of(LibXML::XML::Document, doc)
148
+ assert_instance_of(LibXML::XML::Parser::Context, parser.context)
149
149
  end
150
150
 
151
151
  def test_nil_string
152
152
  error = assert_raises(TypeError) do
153
- XML::Parser.string(nil)
153
+ LibXML::XML::Parser.string(nil)
154
154
  end
155
155
 
156
156
  assert_equal("wrong argument type nil (expected String)", error.to_s)
@@ -165,30 +165,30 @@ class TestParser < Minitest::Test
165
165
  </test>
166
166
  EOS
167
167
 
168
- XML::default_substitute_entities = false
168
+ LibXML::XML::default_substitute_entities = false
169
169
 
170
170
  # Parse normally
171
- parser = XML::Parser.string(xml)
171
+ parser = LibXML::XML::Parser.string(xml)
172
172
  doc = parser.parse
173
173
  assert_nil(doc.child.base_uri)
174
174
 
175
175
  # Cdata section should be cdata nodes
176
176
  node = doc.find_first('/test/cdata').child
177
- assert_equal(XML::Node::CDATA_SECTION_NODE, node.node_type)
177
+ assert_equal(LibXML::XML::Node::CDATA_SECTION_NODE, node.node_type)
178
178
 
179
179
  # Entities should not be subtituted
180
180
  node = doc.find_first('/test/entity')
181
181
  assert_equal('&foo;', node.child.to_s)
182
182
 
183
183
  # Parse with options
184
- parser = XML::Parser.string(xml, :base_uri => 'http://libxml.rubyforge.org',
185
- :options => XML::Parser::Options::NOCDATA | XML::Parser::Options::NOENT)
184
+ parser = LibXML::XML::Parser.string(xml, :base_uri => 'http://libxml.rubyforge.org',
185
+ :options => LibXML::XML::Parser::Options::NOCDATA | LibXML::XML::Parser::Options::NOENT)
186
186
  doc = parser.parse
187
187
  assert_equal(doc.child.base_uri, 'http://libxml.rubyforge.org')
188
188
 
189
189
  # Cdata section should be text nodes
190
190
  node = doc.find_first('/test/cdata').child
191
- assert_equal(XML::Node::TEXT_NODE, node.node_type)
191
+ assert_equal(LibXML::XML::Node::TEXT_NODE, node.node_type)
192
192
 
193
193
  # Entities should be subtituted
194
194
  node = doc.find_first('/test/entity')
@@ -207,9 +207,9 @@ class TestParser < Minitest::Test
207
207
  EOS
208
208
 
209
209
  # Parse as UTF_8
210
- parser = XML::Parser.string(xml, :encoding => XML::Encoding::UTF_8)
210
+ parser = LibXML::XML::Parser.string(xml, :encoding => LibXML::XML::Encoding::UTF_8)
211
211
 
212
- error = assert_raises(XML::Error) do
212
+ error = assert_raises(LibXML::XML::Error) do
213
213
  parser.parse
214
214
  end
215
215
 
@@ -217,15 +217,11 @@ class TestParser < Minitest::Test
217
217
  error.to_s)
218
218
 
219
219
  # Parse as ISO_8859_1:
220
- parser = XML::Parser.string(xml, :encoding => XML::Encoding::ISO_8859_1)
220
+ parser = LibXML::XML::Parser.string(xml, :encoding => LibXML::XML::Encoding::ISO_8859_1)
221
221
  doc = parser.parse
222
222
  node = doc.find_first('//metal')
223
- if defined?(Encoding)
224
- assert_equal(Encoding::UTF_8, node.content.encoding)
225
- assert_equal("m\303\266tley_cr\303\274e", node.content)
226
- else
227
- assert_equal("m\303\266tley_cr\303\274e", node.content)
228
- end
223
+ assert_equal(Encoding::UTF_8, node.content.encoding)
224
+ assert_equal("m\303\266tley_cr\303\274e", node.content)
229
225
  end
230
226
 
231
227
  def test_fd_gc
@@ -235,7 +231,7 @@ class TestParser < Minitest::Test
235
231
  # re-open the same doc `limit descriptors` times.
236
232
  # If we make it to the end, then we've succeeded,
237
233
  # otherwise an exception will be thrown.
238
- XML::Error.set_handler {|error|}
234
+ LibXML::XML::Error.set_handler {|error|}
239
235
 
240
236
  max_fd = if RUBY_PLATFORM.match(/mswin32|mswin64|mingw/i)
241
237
  500
@@ -245,30 +241,30 @@ class TestParser < Minitest::Test
245
241
 
246
242
  file = File.join(File.dirname(__FILE__), 'model/rubynet.xml')
247
243
  max_fd.times do
248
- XML::Parser.file(file).parse
244
+ LibXML::XML::Parser.file(file).parse
249
245
  end
250
- XML::Error.reset_handler {|error|}
246
+ LibXML::XML::Error.reset_handler {|error|}
251
247
  end
252
248
 
253
249
  def test_open_many_files
254
250
  file = File.expand_path(File.join(File.dirname(__FILE__), 'model/atom.xml'))
255
251
  1000.times do
256
- XML::Parser.file(file).parse
252
+ LibXML::XML::Parser.file(file).parse
257
253
  end
258
254
  end
259
255
 
260
256
  # ----- Errors ------
261
257
  def test_error
262
- error = assert_raises(XML::Error) do
263
- XML::Parser.string('<foo><bar/></foz>').parse
258
+ error = assert_raises(LibXML::XML::Error) do
259
+ LibXML::XML::Parser.string('<foo><bar/></foz>').parse
264
260
  end
265
261
 
266
262
  refute_nil(error)
267
- assert_kind_of(XML::Error, error)
263
+ assert_kind_of(LibXML::XML::Error, error)
268
264
  assert_equal("Fatal error: Opening and ending tag mismatch: foo line 1 and foz at :1.", error.message)
269
- assert_equal(XML::Error::PARSER, error.domain)
270
- assert_equal(XML::Error::TAG_NAME_MISMATCH, error.code)
271
- assert_equal(XML::Error::FATAL, error.level)
265
+ assert_equal(LibXML::XML::Error::PARSER, error.domain)
266
+ assert_equal(LibXML::XML::Error::TAG_NAME_MISMATCH, error.code)
267
+ assert_equal(LibXML::XML::Error::FATAL, error.level)
272
268
  assert_nil(error.file)
273
269
  assert_equal(1, error.line)
274
270
  assert_equal('foo', error.str1)
@@ -280,24 +276,24 @@ class TestParser < Minitest::Test
280
276
  end
281
277
 
282
278
  def test_bad_xml
283
- parser = XML::Parser.string('<ruby_array uga="booga" foo="bar"<fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
284
- error = assert_raises(XML::Error) do
279
+ parser = LibXML::XML::Parser.string('<ruby_array uga="booga" foo="bar"<fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
280
+ error = assert_raises(LibXML::XML::Error) do
285
281
  refute_nil(parser.parse)
286
282
  end
287
283
 
288
284
  refute_nil(error)
289
- assert_kind_of(XML::Error, error)
285
+ assert_kind_of(LibXML::XML::Error, error)
290
286
  assert_equal("Fatal error: Extra content at the end of the document at :1.", error.message)
291
- assert_equal(XML::Error::PARSER, error.domain)
292
- assert_equal(XML::Error::DOCUMENT_END, error.code)
293
- assert_equal(XML::Error::FATAL, error.level)
287
+ assert_equal(LibXML::XML::Error::PARSER, error.domain)
288
+ assert_equal(LibXML::XML::Error::DOCUMENT_END, error.code)
289
+ assert_equal(LibXML::XML::Error::FATAL, error.level)
294
290
  assert_nil(error.file)
295
291
  assert_equal(1, error.line)
296
292
  assert_nil(error.str1)
297
293
  assert_nil(error.str2)
298
294
  assert_nil(error.str3)
299
295
  assert_equal(0, error.int1)
300
- assert_equal(20, error.int2)
296
+ assert_equal(34, error.int2)
301
297
  assert_nil(error.node)
302
298
  end
303
299
 
@@ -306,20 +302,20 @@ class TestParser < Minitest::Test
306
302
  background_errors = []
307
303
 
308
304
  begin
309
- XML::Error.set_handler do |error|
305
+ LibXML::XML::Error.set_handler do |error|
310
306
  errors << error
311
307
  end
312
- parser = XML::Parser.string("<moo>")
308
+ parser = LibXML::XML::Parser.string("<moo>")
313
309
 
314
310
  thread = Thread.new do
315
- XML::Error.set_handler do |error|
311
+ LibXML::XML::Error.set_handler do |error|
316
312
  background_errors << error
317
313
  end
318
314
  parser.parse rescue nil
319
315
  end
320
316
  thread.join
321
317
  ensure
322
- XML::Error.set_handler(&XML::Error::QUIET_HANDLER)
318
+ LibXML::XML::Error.set_handler(&LibXML::XML::Error::QUIET_HANDLER)
323
319
  end
324
320
 
325
321
  assert_equal(errors.size, 0)