libxml-ruby 2.8.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +15 -0
  3. data/README.rdoc +7 -7
  4. data/Rakefile +80 -78
  5. data/ext/libxml/extconf.h +4 -0
  6. data/ext/libxml/extconf.rb +57 -116
  7. data/ext/libxml/libxml.c +4 -0
  8. data/ext/libxml/ruby_xml.c +977 -893
  9. data/ext/libxml/ruby_xml.h +20 -10
  10. data/ext/libxml/ruby_xml_attr.c +333 -333
  11. data/ext/libxml/ruby_xml_attr_decl.c +2 -2
  12. data/ext/libxml/ruby_xml_cbg.c +85 -85
  13. data/ext/libxml/ruby_xml_document.c +1133 -1147
  14. data/ext/libxml/ruby_xml_dtd.c +261 -268
  15. data/ext/libxml/ruby_xml_encoding.c +262 -260
  16. data/ext/libxml/ruby_xml_encoding.h +19 -19
  17. data/ext/libxml/ruby_xml_html_parser_context.c +337 -338
  18. data/ext/libxml/ruby_xml_input_cbg.c +191 -191
  19. data/ext/libxml/ruby_xml_io.c +52 -50
  20. data/ext/libxml/ruby_xml_namespace.c +2 -2
  21. data/ext/libxml/ruby_xml_node.c +1446 -1452
  22. data/ext/libxml/ruby_xml_parser_context.c +999 -1001
  23. data/ext/libxml/ruby_xml_reader.c +1226 -1228
  24. data/ext/libxml/ruby_xml_relaxng.c +110 -111
  25. data/ext/libxml/ruby_xml_sax2_handler.c +326 -328
  26. data/ext/libxml/ruby_xml_schema.c +300 -301
  27. data/ext/libxml/ruby_xml_version.h +3 -3
  28. data/ext/libxml/ruby_xml_writer.c +14 -15
  29. data/ext/libxml/ruby_xml_xpath.c +188 -188
  30. data/ext/libxml/ruby_xml_xpath_context.c +360 -361
  31. data/ext/libxml/ruby_xml_xpath_object.c +335 -335
  32. data/libxml-ruby.gemspec +47 -44
  33. data/test/tc_attr.rb +5 -7
  34. data/test/tc_attr_decl.rb +5 -6
  35. data/test/tc_attributes.rb +1 -2
  36. data/test/tc_canonicalize.rb +1 -2
  37. data/test/tc_deprecated_require.rb +1 -2
  38. data/test/tc_document.rb +4 -5
  39. data/test/tc_document_write.rb +2 -3
  40. data/test/tc_dtd.rb +4 -5
  41. data/test/tc_encoding.rb +126 -126
  42. data/test/tc_encoding_sax.rb +4 -3
  43. data/test/tc_error.rb +14 -15
  44. data/test/tc_html_parser.rb +15 -7
  45. data/test/tc_html_parser_context.rb +1 -2
  46. data/test/tc_namespace.rb +2 -3
  47. data/test/tc_namespaces.rb +5 -6
  48. data/test/tc_node.rb +2 -3
  49. data/test/tc_node_cdata.rb +2 -3
  50. data/test/tc_node_comment.rb +1 -2
  51. data/test/tc_node_copy.rb +1 -2
  52. data/test/tc_node_edit.rb +5 -7
  53. data/test/tc_node_pi.rb +1 -2
  54. data/test/tc_node_text.rb +2 -3
  55. data/test/tc_node_write.rb +2 -3
  56. data/test/tc_node_xlink.rb +1 -2
  57. data/test/tc_parser.rb +18 -24
  58. data/test/tc_parser_context.rb +6 -7
  59. data/test/tc_properties.rb +1 -2
  60. data/test/tc_reader.rb +9 -10
  61. data/test/tc_relaxng.rb +4 -5
  62. data/test/tc_sax_parser.rb +9 -10
  63. data/test/tc_schema.rb +4 -5
  64. data/test/tc_traversal.rb +1 -2
  65. data/test/tc_writer.rb +1 -2
  66. data/test/tc_xinclude.rb +1 -2
  67. data/test/tc_xml.rb +1 -2
  68. data/test/tc_xpath.rb +8 -9
  69. data/test/tc_xpath_context.rb +3 -4
  70. data/test/tc_xpath_expression.rb +3 -4
  71. data/test/tc_xpointer.rb +1 -3
  72. data/test/test_helper.rb +3 -1
  73. data/test/test_suite.rb +0 -1
  74. metadata +47 -11
  75. data/test/etc_doc_to_s.rb +0 -21
  76. data/test/ets_doc_file.rb +0 -17
  77. data/test/ets_doc_to_s.rb +0 -23
  78. data/test/ets_gpx.rb +0 -28
  79. data/test/ets_node_gc.rb +0 -23
  80. data/test/ets_test.xml +0 -2
  81. data/test/ets_tsr.rb +0 -11
@@ -1,12 +1,13 @@
1
1
  # encoding: UTF-8
2
2
  require './test_helper'
3
- require 'test/unit'
4
3
 
5
4
  class SaxEncodingCallbacks
6
5
  attr_reader :encoding
7
- include Test::Unit::Assertions
6
+ attr_accessor :assertions
7
+ include Minitest::Assertions
8
8
 
9
9
  def initialize
10
+ @assertions = 0
10
11
  @encoding = Encoding::UTF_8
11
12
  end
12
13
 
@@ -90,7 +91,7 @@ class SaxEncodingCallbacks
90
91
  end
91
92
  end
92
93
 
93
- class TestEncodingSax < Test::Unit::TestCase
94
+ class TestEncodingSax < Minitest::Test
94
95
  def setup
95
96
  Encoding.default_internal = nil
96
97
  end
@@ -1,10 +1,9 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require './test_helper'
4
- require 'test/unit'
5
4
  require 'stringio'
6
5
 
7
- class TestError < Test::Unit::TestCase
6
+ class TestError < Minitest::Test
8
7
  def test_error_codes
9
8
  assert_equal(4, XML::Error::DTD)
10
9
  assert_equal(4, XML::Error.const_get('DTD'))
@@ -14,7 +13,7 @@ class TestError < Test::Unit::TestCase
14
13
  end
15
14
 
16
15
  def test_invalid_handler
17
- assert_raise(RuntimeError) do
16
+ assert_raises(RuntimeError) do
18
17
  XML::Error.set_handler
19
18
  end
20
19
  end
@@ -26,13 +25,13 @@ class TestError < Test::Unit::TestCase
26
25
  end
27
26
 
28
27
  # Raise the error
29
- error = assert_raise(XML::Error) do
28
+ error = assert_raises(XML::Error) do
30
29
  XML::Reader.string('<foo').read
31
30
  end
32
31
  assert_equal(exception, error)
33
32
 
34
33
  # Check the handler worked
35
- assert_not_nil(exception)
34
+ refute_nil(exception)
36
35
  assert_kind_of(XML::Error, exception)
37
36
  assert_equal("Fatal error: Couldn't find end of Start Tag foo at :1.", exception.message)
38
37
  assert_equal(XML::Error::PARSER, exception.domain)
@@ -65,7 +64,7 @@ class TestError < Test::Unit::TestCase
65
64
 
66
65
  saved_handler = XML::Error.get_handler
67
66
  XML::Error.set_handler{ puts "New handler" }
68
- assert_not_equal(XML::Error.get_handler, saved_handler)
67
+ refute_equal(XML::Error.get_handler, saved_handler)
69
68
 
70
69
  XML::Error.set_handler(&saved_handler)
71
70
  assert_equal(XML::Error.get_handler, saved_handler)
@@ -78,7 +77,7 @@ class TestError < Test::Unit::TestCase
78
77
 
79
78
  Object.const_set(:STDERR, output)
80
79
  begin
81
- assert_raise(XML::Error) do
80
+ assert_raises(XML::Error) do
82
81
  XML::Parser.string('<foo><bar/></foz>').parse
83
82
  end
84
83
  ensure
@@ -94,7 +93,7 @@ class TestError < Test::Unit::TestCase
94
93
 
95
94
  Object.const_set(:STDERR, output)
96
95
  begin
97
- assert_raise(XML::Error) do
96
+ assert_raises(XML::Error) do
98
97
  XML::Parser.string('<foo><bar/></foz>').parse
99
98
  end
100
99
  ensure
@@ -104,7 +103,7 @@ class TestError < Test::Unit::TestCase
104
103
  end
105
104
 
106
105
  def test_parse_error
107
- exception = assert_raise(XML::Error) do
106
+ exception = assert_raises(XML::Error) do
108
107
  XML::Parser.string('<foo><bar/></foz>').parse
109
108
  end
110
109
 
@@ -120,7 +119,7 @@ class TestError < Test::Unit::TestCase
120
119
  def test_xpath_error
121
120
  doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
122
121
 
123
- exception = assert_raise(XML::Error) do
122
+ exception = assert_raises(XML::Error) do
124
123
  doc.find('/foo[bar=test')
125
124
  end
126
125
 
@@ -138,7 +137,7 @@ class TestError < Test::Unit::TestCase
138
137
  parser = XML::Parser.string("<test>something</test>")
139
138
  parser.parse
140
139
 
141
- error = assert_raise(XML::Error) do
140
+ error = assert_raises(XML::Error) do
142
141
  # Try parsing a second time
143
142
  parser.parse
144
143
  end
@@ -149,19 +148,19 @@ class TestError < Test::Unit::TestCase
149
148
  def test_libxml_parser_empty_string
150
149
  xp = XML::Parser.new
151
150
 
152
- error = assert_raise(TypeError) do
151
+ error = assert_raises(TypeError) do
153
152
  xp.string = nil
154
153
  end
155
154
  assert_equal('wrong argument type nil (expected String)', error.to_s)
156
155
 
157
- error = assert_raise(ArgumentError) do
156
+ error = assert_raises(ArgumentError) do
158
157
  xp.string = ''
159
158
  end
160
159
  assert_equal('Must specify a string with one or more characters', error.to_s)
161
160
  end
162
161
 
163
162
  def test_error_domain_to_s
164
- exception = assert_raise(XML::Error) do
163
+ exception = assert_raises(XML::Error) do
165
164
  XML::Parser.string('<foo href="http://example.org/cgi?k1=v1&k2=v2"></foo>').parse
166
165
  end
167
166
 
@@ -170,7 +169,7 @@ class TestError < Test::Unit::TestCase
170
169
  end
171
170
 
172
171
  def test_error_code_to_s
173
- exception = assert_raise(XML::Error) do
172
+ exception = assert_raises(XML::Error) do
174
173
  XML::Parser.string('<foo href="http://example.org/cgi?k1=v1&k2=v2"></foo>').parse
175
174
  end
176
175
  assert_equal(XML::Error::ENTITYREF_SEMICOL_MISSING, exception.code)
@@ -2,9 +2,8 @@
2
2
 
3
3
  require './test_helper'
4
4
  require 'stringio'
5
- require 'test/unit'
6
5
 
7
- class HTMLParserTest < Test::Unit::TestCase
6
+ class HTMLParserTest < Minitest::Test
8
7
  def html_file
9
8
  File.expand_path(File.join(File.dirname(__FILE__), 'model/ruby-lang.html'))
10
9
  end
@@ -14,11 +13,11 @@ class HTMLParserTest < Test::Unit::TestCase
14
13
  xp = XML::HTMLParser.file(html_file)
15
14
  assert_instance_of(XML::HTMLParser, xp)
16
15
  doc = xp.parse
17
- assert_not_nil(doc)
16
+ refute_nil(doc)
18
17
  end
19
18
 
20
19
  def test_noexistent_file
21
- error = assert_raise(XML::Error) do
20
+ error = assert_raises(XML::Error) do
22
21
  XML::HTMLParser.file('i_dont_exist.xml')
23
22
  end
24
23
 
@@ -26,7 +25,7 @@ class HTMLParserTest < Test::Unit::TestCase
26
25
  end
27
26
 
28
27
  def test_nil_file
29
- error = assert_raise(TypeError) do
28
+ error = assert_raises(TypeError) do
30
29
  XML::HTMLParser.file(nil)
31
30
  end
32
31
 
@@ -54,7 +53,7 @@ class HTMLParserTest < Test::Unit::TestCase
54
53
  end
55
54
 
56
55
  def test_nil_io
57
- error = assert_raise(TypeError) do
56
+ error = assert_raises(TypeError) do
58
57
  XML::HTMLParser.io(nil)
59
58
  end
60
59
 
@@ -83,7 +82,7 @@ class HTMLParserTest < Test::Unit::TestCase
83
82
  end
84
83
 
85
84
  def test_nil_string
86
- error = assert_raise(TypeError) do
85
+ error = assert_raises(TypeError) do
87
86
  XML::HTMLParser.string(nil)
88
87
  end
89
88
 
@@ -145,6 +144,15 @@ class HTMLParserTest < Test::Unit::TestCase
145
144
  assert_equal("<p>#{html}</p>", doc.root.to_s)
146
145
  end
147
146
 
147
+ def test_comment
148
+ doc = LibXML::XML::HTMLParser.string('<!-- stuff -->', :options => LibXML::XML::HTMLParser::Options::NOIMPLIED |
149
+ LibXML::XML::HTMLParser::Options::NOERROR |
150
+ LibXML::XML::HTMLParser::Options::NOWARNING |
151
+ LibXML::XML::HTMLParser::Options::RECOVER |
152
+ LibXML::XML::HTMLParser::Options::NONET)
153
+ assert(doc)
154
+ end
155
+
148
156
  def test_open_many_files
149
157
  1000.times do
150
158
  doc = XML::HTMLParser.file('model/ruby-lang.html').parse
@@ -2,9 +2,8 @@
2
2
 
3
3
  require './test_helper'
4
4
 
5
- require 'test/unit'
6
5
 
7
- class TestHtmlParserContext < Test::Unit::TestCase
6
+ class TestHtmlParserContext < Minitest::Test
8
7
  def test_default_options
9
8
  context = XML::HTMLParser::Context.new
10
9
  assert_equal(0, context.options)
@@ -2,9 +2,8 @@
2
2
 
3
3
  require './test_helper'
4
4
 
5
- require 'test/unit'
6
5
 
7
- class TestNS < Test::Unit::TestCase
6
+ class TestNS < Minitest::Test
8
7
  def setup
9
8
  file = File.join(File.dirname(__FILE__), 'model/soap.xml')
10
9
  @doc = XML::Document.file(file)
@@ -29,7 +28,7 @@ class TestNS < Test::Unit::TestCase
29
28
  end
30
29
 
31
30
  def test_create_unbound_ns
32
- error = assert_raise(TypeError) do
31
+ error = assert_raises(TypeError) do
33
32
  XML::Namespace.new(nil, 'my_namepace', 'http://www.mynamespace.com')
34
33
  end
35
34
  assert_equal('wrong argument type nil (expected Data)', error.to_s)
@@ -2,9 +2,8 @@
2
2
 
3
3
  require './test_helper'
4
4
 
5
- require 'test/unit'
6
5
 
7
- class TestNamespaces < Test::Unit::TestCase
6
+ class TestNamespaces < Minitest::Test
8
7
  def setup
9
8
  file = File.join(File.dirname(__FILE__), 'model/soap.xml')
10
9
  @doc = XML::Document.file(file)
@@ -38,7 +37,7 @@ class TestNamespaces < Test::Unit::TestCase
38
37
 
39
38
  # Now put the node in the soap namespace
40
39
  node.namespaces.namespace = ns
41
- assert_not_nil(node.namespaces.namespace)
40
+ refute_nil(node.namespaces.namespace)
42
41
  assert_equal("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"/>", node.to_s)
43
42
  end
44
43
 
@@ -60,13 +59,13 @@ class TestNamespaces < Test::Unit::TestCase
60
59
 
61
60
  # Now put the node in the soap namespace
62
61
  node.namespaces.namespace = ns
63
- assert_not_nil(node.namespaces.namespace)
62
+ refute_nil(node.namespaces.namespace)
64
63
  assert_equal('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" encodingStyle="http://www.w3.org/2001/12/soap-encoding"/>',
65
64
  node.to_s)
66
65
 
67
66
  # Now put the attribute in the soap namespace
68
67
  attr.namespaces.namespace = ns
69
- assert_not_nil(node.namespaces.namespace)
68
+ refute_nil(node.namespaces.namespace)
70
69
  assert_equal('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"/>',
71
70
  node.to_s)
72
71
  end
@@ -205,6 +204,6 @@ class TestNamespaces < Test::Unit::TestCase
205
204
  doc.root.namespaces.default_prefix = 'soap'
206
205
 
207
206
  node = doc.root.find_first('/soap:Envelope')
208
- assert_not_nil(node)
207
+ refute_nil(node)
209
208
  end
210
209
  end
@@ -1,9 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require './test_helper'
4
- require 'test/unit'
5
4
 
6
- class TestNode < Test::Unit::TestCase
5
+ class TestNode < Minitest::Test
7
6
  def setup
8
7
  @file_name = "model/bands.utf-8.xml"
9
8
 
@@ -112,7 +111,7 @@ class TestNode < Test::Unit::TestCase
112
111
  def test_equality_wrong_type
113
112
  node = @doc.root
114
113
 
115
- assert_raise(TypeError) do
114
+ assert_raises(TypeError) do
116
115
  assert(node != 'abc')
117
116
  end
118
117
  end
@@ -1,9 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require './test_helper'
4
- require 'test/unit'
5
4
 
6
- class CDataCommentTest < Test::Unit::TestCase
5
+ class CDataCommentTest < Minitest::Test
7
6
  def setup
8
7
  xp = XML::Parser.string('<root></root>')
9
8
  @doc = xp.parse
@@ -44,7 +43,7 @@ class CDataCommentTest < Test::Unit::TestCase
44
43
  cnode = XML::Node.new_cdata('test cdata')
45
44
 
46
45
  # Can't create attributes on non-element nodes
47
- assert_raise(ArgumentError) do
46
+ assert_raises(ArgumentError) do
48
47
  cnode['attr'] = '123'
49
48
  end
50
49
  end
@@ -2,9 +2,8 @@
2
2
 
3
3
  require './test_helper'
4
4
 
5
- require 'test/unit'
6
5
 
7
- class NodeCommentTest < Test::Unit::TestCase
6
+ class NodeCommentTest < Minitest::Test
8
7
  def setup
9
8
  xp = XML::Parser.string('<root></root>')
10
9
  @doc = xp.parse
@@ -1,13 +1,12 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require './test_helper'
4
- require 'test/unit'
5
4
 
6
5
  # see mailing list archive
7
6
  # [libxml-devel] Segmentation fault when add the cloned/copied node
8
7
  # 2007/11/27 20:51
9
8
 
10
- class TestNodeCopy < Test::Unit::TestCase
9
+ class TestNodeCopy < Minitest::Test
11
10
  def setup
12
11
  str = <<-STR
13
12
  <html><body>
@@ -1,9 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require './test_helper'
4
- require 'test/unit'
5
4
 
6
- class TestNodeEdit < Test::Unit::TestCase
5
+ class TestNodeEdit < Minitest::Test
7
6
  def setup
8
7
  xp = XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
9
8
  @doc = xp.parse
@@ -76,7 +75,7 @@ class TestNodeEdit < Test::Unit::TestCase
76
75
  a.parent.remove!
77
76
 
78
77
  # Node a has now been freed from under us
79
- error = assert_raise(RuntimeError) do
78
+ error = assert_raises(RuntimeError) do
80
79
  a.to_s
81
80
  end
82
81
  assert_equal('This node has already been freed.', error.to_s)
@@ -88,7 +87,7 @@ class TestNodeEdit < Test::Unit::TestCase
88
87
  node = doc.root.child.remove!
89
88
  node = nil
90
89
  GC.start
91
- assert_not_nil(doc)
90
+ refute_nil(doc)
92
91
  end
93
92
 
94
93
  def test_remove_node_iteration
@@ -105,7 +104,7 @@ class TestNodeEdit < Test::Unit::TestCase
105
104
  def test_reuse_removed_node
106
105
  # Remove the node
107
106
  node = @doc.root.first.remove!
108
- assert_not_nil(node)
107
+ refute_nil(node)
109
108
 
110
109
  # Add it to the end of the document
111
110
  @doc.root.last.next = node
@@ -124,13 +123,12 @@ class TestNodeEdit < Test::Unit::TestCase
124
123
  end
125
124
 
126
125
  def test_wrong_doc
127
- puts 333333
128
126
  doc1 = XML::Parser.string('<nums><one></one></nums>').parse
129
127
  doc2 = XML::Parser.string('<nums><two></two></nums>').parse
130
128
 
131
129
  node = doc1.root.child
132
130
 
133
- error = assert_raise(XML::Error) do
131
+ error = assert_raises(XML::Error) do
134
132
  doc2.root << node
135
133
  end
136
134
 
@@ -2,9 +2,8 @@
2
2
 
3
3
  require './test_helper'
4
4
 
5
- require 'test/unit'
6
5
 
7
- class NodeCommentTest < Test::Unit::TestCase
6
+ class NodeCommentTest < Minitest::Test
8
7
  def setup
9
8
  xp = XML::Parser.string('<root></root>')
10
9
  @doc = xp.parse
@@ -1,9 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require './test_helper'
4
- require 'test/unit'
5
4
 
6
- class TestTextNode < Test::Unit::TestCase
5
+ class TestTextNode < Minitest::Test
7
6
  def test_content
8
7
  node = XML::Node.new_text('testdata')
9
8
  assert_instance_of(XML::Node, node)
@@ -11,7 +10,7 @@ class TestTextNode < Test::Unit::TestCase
11
10
  end
12
11
 
13
12
  def test_invalid_content
14
- error = assert_raise(TypeError) do
13
+ error = assert_raises(TypeError) do
15
14
  node = XML::Node.new_text(nil)
16
15
  end
17
16
  assert_equal('wrong argument type nil (expected String)', error.to_s)
@@ -1,9 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require './test_helper'
4
- require 'test/unit'
5
4
 
6
- class TestNodeWrite < Test::Unit::TestCase
5
+ class TestNodeWrite < Minitest::Test
7
6
  def setup
8
7
  load_encoding("utf-8")
9
8
  end
@@ -81,7 +80,7 @@ class TestNodeWrite < Test::Unit::TestCase
81
80
  end
82
81
 
83
82
  # Invalid encoding
84
- error = assert_raise(ArgumentError) do
83
+ error = assert_raises(ArgumentError) do
85
84
  node.to_s(:encoding => -9999)
86
85
  end
87
86
  assert_equal('Unknown encoding value: -9999', error.to_s)