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
@@ -3,9 +3,8 @@
3
3
  # $Id$
4
4
  require './test_helper'
5
5
 
6
- require 'test/unit'
7
6
 
8
- class TC_XML_Node_XLink < Test::Unit::TestCase
7
+ class TC_XML_Node_XLink < Minitest::Test
9
8
  def setup()
10
9
  xp = XML::Parser.string('<ruby_array xmlns:xlink="http://www.w3.org/1999/xlink/namespace/"><fixnum xlink:type="simple">one</fixnum></ruby_array>')
11
10
  doc = xp.parse
@@ -1,20 +1,13 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require './test_helper'
4
- require 'test/unit'
5
4
  require 'stringio'
6
5
 
7
- class TestParser < Test::Unit::TestCase
6
+ class TestParser < Minitest::Test
8
7
  def setup
9
8
  XML::Error.set_handler(&XML::Error::QUIET_HANDLER)
10
9
  end
11
10
 
12
- def teardown
13
- GC.start
14
- GC.start
15
- GC.start
16
- end
17
-
18
11
  # ----- Sources -------
19
12
  def test_document
20
13
  file = File.expand_path(File.join(File.dirname(__FILE__), 'model/bands.utf-8.xml'))
@@ -30,7 +23,7 @@ class TestParser < Test::Unit::TestCase
30
23
  end
31
24
 
32
25
  def test_nil_document
33
- error = assert_raise(TypeError) do
26
+ error = assert_raises(TypeError) do
34
27
  XML::Parser.document(nil)
35
28
  end
36
29
 
@@ -47,7 +40,7 @@ class TestParser < Test::Unit::TestCase
47
40
  end
48
41
 
49
42
  def test_noexistent_file
50
- error = assert_raise(XML::Error) do
43
+ error = assert_raises(XML::Error) do
51
44
  XML::Parser.file('i_dont_exist.xml')
52
45
  end
53
46
 
@@ -55,7 +48,7 @@ class TestParser < Test::Unit::TestCase
55
48
  end
56
49
 
57
50
  def test_nil_file
58
- error = assert_raise(TypeError) do
51
+ error = assert_raises(TypeError) do
59
52
  XML::Parser.file(nil)
60
53
  end
61
54
 
@@ -66,7 +59,7 @@ class TestParser < Test::Unit::TestCase
66
59
  file = File.expand_path(File.join(File.dirname(__FILE__), 'model/bands.utf-8.xml'))
67
60
  parser = XML::Parser.file(file, :encoding => XML::Encoding::ISO_8859_1)
68
61
 
69
- error = assert_raise(XML::Error) do
62
+ error = assert_raises(XML::Error) do
70
63
  doc = parser.parse
71
64
  end
72
65
 
@@ -74,7 +67,7 @@ class TestParser < Test::Unit::TestCase
74
67
 
75
68
  parser = XML::Parser.file(file, :encoding => XML::Encoding::UTF_8)
76
69
  doc = parser.parse
77
- assert_not_nil(doc)
70
+ refute_nil(doc)
78
71
  end
79
72
 
80
73
  def test_file_base_uri
@@ -111,7 +104,7 @@ class TestParser < Test::Unit::TestCase
111
104
  end
112
105
 
113
106
  def test_nil_io
114
- error = assert_raise(TypeError) do
107
+ error = assert_raises(TypeError) do
115
108
  XML::Parser.io(nil)
116
109
  end
117
110
 
@@ -141,8 +134,9 @@ class TestParser < Test::Unit::TestCase
141
134
 
142
135
  thread.join
143
136
  assert(true)
137
+ puts 'Thread completed'
144
138
  end
145
-
139
+
146
140
  def test_string
147
141
  str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
148
142
 
@@ -155,7 +149,7 @@ class TestParser < Test::Unit::TestCase
155
149
  end
156
150
 
157
151
  def test_nil_string
158
- error = assert_raise(TypeError) do
152
+ error = assert_raises(TypeError) do
159
153
  XML::Parser.string(nil)
160
154
  end
161
155
 
@@ -215,7 +209,7 @@ class TestParser < Test::Unit::TestCase
215
209
  # Parse as UTF_8
216
210
  parser = XML::Parser.string(xml, :encoding => XML::Encoding::UTF_8)
217
211
 
218
- error = assert_raise(XML::Error) do
212
+ error = assert_raises(XML::Error) do
219
213
  doc = parser.parse
220
214
  end
221
215
 
@@ -246,7 +240,7 @@ class TestParser < Test::Unit::TestCase
246
240
  max_fd = if RUBY_PLATFORM.match(/mswin32|mingw/i)
247
241
  500
248
242
  else
249
- (`ulimit -n`.chomp.to_i) + 1
243
+ Process.getrlimit(Process::RLIMIT_NOFILE)[0] + 1
250
244
  end
251
245
 
252
246
  file = File.join(File.dirname(__FILE__), 'model/rubynet.xml')
@@ -264,11 +258,11 @@ class TestParser < Test::Unit::TestCase
264
258
 
265
259
  # ----- Errors ------
266
260
  def test_error
267
- error = assert_raise(XML::Error) do
261
+ error = assert_raises(XML::Error) do
268
262
  XML::Parser.string('<foo><bar/></foz>').parse
269
263
  end
270
264
 
271
- assert_not_nil(error)
265
+ refute_nil(error)
272
266
  assert_kind_of(XML::Error, error)
273
267
  assert_equal("Fatal error: Opening and ending tag mismatch: foo line 1 and foz at :1.", error.message)
274
268
  assert_equal(XML::Error::PARSER, error.domain)
@@ -286,11 +280,11 @@ class TestParser < Test::Unit::TestCase
286
280
 
287
281
  def test_bad_xml
288
282
  parser = XML::Parser.string('<ruby_array uga="booga" foo="bar"<fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
289
- error = assert_raise(XML::Error) do
290
- assert_not_nil(parser.parse)
283
+ error = assert_raises(XML::Error) do
284
+ refute_nil(parser.parse)
291
285
  end
292
286
 
293
- assert_not_nil(error)
287
+ refute_nil(error)
294
288
  assert_kind_of(XML::Error, error)
295
289
  assert_equal("Fatal error: Extra content at the end of the document at :1.", error.message)
296
290
  assert_equal(XML::Error::PARSER, error.domain)
@@ -302,7 +296,7 @@ class TestParser < Test::Unit::TestCase
302
296
  assert_nil(error.str2)
303
297
  assert_nil(error.str3)
304
298
  assert_equal(0, error.int1)
305
- assert_equal(20, error.int2)
299
+ assert_equal(34, error.int2)
306
300
  assert_nil(error.node)
307
301
  end
308
302
 
@@ -2,9 +2,8 @@
2
2
 
3
3
  require './test_helper'
4
4
 
5
- require 'test/unit'
6
5
 
7
- class TestParserContext < Test::Unit::TestCase
6
+ class TestParserContext < Minitest::Test
8
7
  def test_string
9
8
  # UTF8
10
9
  xml = <<-EOS
@@ -44,7 +43,7 @@ class TestParserContext < Test::Unit::TestCase
44
43
 
45
44
  context = XML::Parser::Context.string(xml)
46
45
 
47
- error = assert_raise(ArgumentError) do
46
+ error = assert_raises(ArgumentError) do
48
47
  context.encoding = -999
49
48
  end
50
49
  assert_equal("Unknown encoding: -999", error.to_s)
@@ -66,12 +65,12 @@ class TestParserContext < Test::Unit::TestCase
66
65
  end
67
66
 
68
67
  def test_string_empty
69
- error = assert_raise(TypeError) do
68
+ error = assert_raises(TypeError) do
70
69
  XML::Parser::Context.string(nil)
71
70
  end
72
71
  assert_equal("wrong argument type nil (expected String)", error.to_s)
73
72
 
74
- error = assert_raise(ArgumentError) do
73
+ error = assert_raises(ArgumentError) do
75
74
  XML::Parser::Context.string('')
76
75
  end
77
76
  assert_equal("Must specify a string with one or more characters", error.to_s)
@@ -85,7 +84,7 @@ class TestParserContext < Test::Unit::TestCase
85
84
 
86
85
  def test_not_well_formed
87
86
  parser = XML::Parser.string("<abc>")
88
- assert_raise(XML::Error) do
87
+ assert_raises(XML::Error) do
89
88
  parser.parse
90
89
  end
91
90
  assert(!parser.context.well_formed?)
@@ -166,7 +165,7 @@ class TestParserContext < Test::Unit::TestCase
166
165
  def test_parse_error
167
166
  xp = XML::Parser.string('<foo><bar/></foz>')
168
167
 
169
- assert_raise(XML::Error) do
168
+ assert_raises(XML::Error) do
170
169
  xp.parse
171
170
  end
172
171
 
@@ -2,12 +2,11 @@
2
2
 
3
3
  require './test_helper'
4
4
 
5
- require 'test/unit'
6
5
 
7
6
  # attributes is deprecated - use attributes instead.
8
7
  # Tests for backwards compatibility
9
8
 
10
- class Testattributes < Test::Unit::TestCase
9
+ class Testattributes < Minitest::Test
11
10
  def setup()
12
11
  xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
13
12
  @doc = xp.parse
@@ -2,9 +2,8 @@
2
2
 
3
3
  require './test_helper'
4
4
  require 'stringio'
5
- require 'test/unit'
6
5
 
7
- class TestReader < Test::Unit::TestCase
6
+ class TestReader < Minitest::Test
8
7
  XML_FILE = File.join(File.dirname(__FILE__), 'model/atom.xml')
9
8
 
10
9
  def verify_simple(reader)
@@ -61,7 +60,7 @@ class TestReader < Test::Unit::TestCase
61
60
  end
62
61
 
63
62
  def test_invalid_file
64
- assert_raise(XML::Error) do
63
+ assert_raises(XML::Error) do
65
64
  XML::Reader.file('/does/not/exist')
66
65
  end
67
66
  end
@@ -98,7 +97,7 @@ class TestReader < Test::Unit::TestCase
98
97
  def test_error
99
98
  reader = XML::Reader.string('<foo blah')
100
99
 
101
- error = assert_raise(XML::Error) do
100
+ error = assert_raises(XML::Error) do
102
101
  reader.read
103
102
  end
104
103
  assert_equal("Fatal error: Couldn't find end of Start Tag foo at :1.", error.to_s)
@@ -111,7 +110,7 @@ class TestReader < Test::Unit::TestCase
111
110
  called = true
112
111
  end
113
112
 
114
- assert_raise(XML::Error) do
113
+ assert_raises(XML::Error) do
115
114
  reader.read
116
115
  end
117
116
 
@@ -126,7 +125,7 @@ class TestReader < Test::Unit::TestCase
126
125
  end
127
126
  reader.reset_error_handler
128
127
 
129
- assert_raise(XML::Error) do
128
+ assert_raises(XML::Error) do
130
129
  reader.read
131
130
  end
132
131
 
@@ -224,7 +223,7 @@ class TestReader < Test::Unit::TestCase
224
223
  node = reader.expand
225
224
 
226
225
  # Try to access the document
227
- assert_not_nil(node.doc)
226
+ refute_nil(node.doc)
228
227
  end
229
228
 
230
229
  def test_expand_find
@@ -246,7 +245,7 @@ class TestReader < Test::Unit::TestCase
246
245
  reader = XML::Reader.file(XML_FILE)
247
246
 
248
247
  # Expand a node before one has been read
249
- error = assert_raise(RuntimeError) do
248
+ error = assert_raises(RuntimeError) do
250
249
  reader.expand
251
250
  end
252
251
  assert_equal("The reader does not have a document. Did you forget to call read?", error.to_s)
@@ -267,7 +266,7 @@ class TestReader < Test::Unit::TestCase
267
266
  reader.next
268
267
 
269
268
  # The previous node is now invalid
270
- error = assert_raise(RuntimeError) do
269
+ error = assert_raises(RuntimeError) do
271
270
  assert_equal('feed', node.name)
272
271
  end
273
272
  assert_equal("This node has already been freed.", error.to_s)
@@ -370,7 +369,7 @@ class TestReader < Test::Unit::TestCase
370
369
  xml = "<bands genre=\"metal\">\n <m\366tley_cr\374e country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\366tley_cr\374e>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n</bands>"
371
370
 
372
371
  reader = XML::Reader.string(xml)
373
- error = assert_raise(XML::Error) do
372
+ error = assert_raises(XML::Error) do
374
373
  node = reader.read
375
374
  end
376
375
 
@@ -2,9 +2,8 @@
2
2
 
3
3
  require './test_helper'
4
4
 
5
- require 'test/unit'
6
5
 
7
- class TestRelaxNG < Test::Unit::TestCase
6
+ class TestRelaxNG < Minitest::Test
8
7
  def setup
9
8
  file = File.join(File.dirname(__FILE__), 'model/shiporder.xml')
10
9
  @doc = XML::Document.file(file)
@@ -31,11 +30,11 @@ class TestRelaxNG < Test::Unit::TestCase
31
30
  new_node = XML::Node.new('invalid', 'this will mess up validation')
32
31
  @doc.root << new_node
33
32
 
34
- error = assert_raise(XML::Error) do
33
+ error = assert_raises(XML::Error) do
35
34
  @doc.validate_relaxng(relaxng)
36
35
  end
37
36
 
38
- assert_not_nil(error)
37
+ refute_nil(error)
39
38
  assert_kind_of(XML::Error, error)
40
39
  assert(error.message.match(/Error: Did not expect element invalid there/))
41
40
  assert_equal(XML::Error::RELAXNGV, error.domain)
@@ -48,7 +47,7 @@ class TestRelaxNG < Test::Unit::TestCase
48
47
  assert_nil(error.str3)
49
48
  assert_equal(0, error.int1)
50
49
  assert_equal(0, error.int2)
51
- assert_not_nil(error.node)
50
+ refute_nil(error.node)
52
51
  assert_equal('invalid', error.node.name)
53
52
  end
54
53
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require './test_helper'
4
4
  require 'stringio'
5
- require 'test/unit'
6
5
 
7
6
  class DocTypeCallback
8
7
  include XML::SaxParser::Callbacks
@@ -68,7 +67,7 @@ class TestCaseCallbacks
68
67
  end
69
68
  end
70
69
 
71
- class TestSaxParser < Test::Unit::TestCase
70
+ class TestSaxParser < Minitest::Test
72
71
  def saxtest_file
73
72
  File.join(File.dirname(__FILE__), 'model/atom.xml')
74
73
  end
@@ -132,7 +131,7 @@ class TestSaxParser < Test::Unit::TestCase
132
131
  end
133
132
 
134
133
  def test_noexistent_file
135
- error = assert_raise(XML::Error) do
134
+ error = assert_raises(XML::Error) do
136
135
  XML::SaxParser.file('i_dont_exist.xml')
137
136
  end
138
137
 
@@ -140,7 +139,7 @@ class TestSaxParser < Test::Unit::TestCase
140
139
  end
141
140
 
142
141
  def test_nil_file
143
- error = assert_raise(TypeError) do
142
+ error = assert_raises(TypeError) do
144
143
  XML::SaxParser.file(nil)
145
144
  end
146
145
 
@@ -157,7 +156,7 @@ class TestSaxParser < Test::Unit::TestCase
157
156
  end
158
157
 
159
158
  def test_nil_io
160
- error = assert_raise(TypeError) do
159
+ error = assert_raises(TypeError) do
161
160
  XML::HTMLParser.io(nil)
162
161
  end
163
162
 
@@ -189,7 +188,7 @@ class TestSaxParser < Test::Unit::TestCase
189
188
  end
190
189
 
191
190
  def test_nil_string
192
- error = assert_raise(TypeError) do
191
+ error = assert_raises(TypeError) do
193
192
  XML::SaxParser.string(nil)
194
193
  end
195
194
 
@@ -207,7 +206,7 @@ EOS
207
206
  parser = XML::SaxParser.string(xml)
208
207
  parser.callbacks = DocTypeCallback.new
209
208
  doc = parser.parse
210
- assert_not_nil(doc)
209
+ refute_nil(doc)
211
210
  end
212
211
 
213
212
  def test_parse_warning
@@ -243,7 +242,7 @@ EOS
243
242
  parser = XML::SaxParser.string(xml)
244
243
  parser.callbacks = TestCaseCallbacks.new
245
244
 
246
- error = assert_raise(XML::Error) do
245
+ error = assert_raises(XML::Error) do
247
246
  doc = parser.parse
248
247
  end
249
248
 
@@ -258,7 +257,7 @@ EOS
258
257
  assert_equal("error: Fatal error: Premature end of data in tag Results line 1 at :2.", result[i+=1])
259
258
  assert_equal("end_document", result[i+=1])
260
259
 
261
- assert_not_nil(error)
260
+ refute_nil(error)
262
261
  assert_kind_of(XML::Error, error)
263
262
  assert_equal("Fatal error: Premature end of data in tag Results line 1 at :2.", error.message)
264
263
  assert_equal(XML::Error::PARSER, error.domain)
@@ -309,7 +308,7 @@ EOS
309
308
  parser = XML::SaxParser.string(xml)
310
309
  parser.callbacks = TestCaseCallbacks.new
311
310
 
312
- error = assert_raise(XML::Error) do
311
+ error = assert_raises(XML::Error) do
313
312
  parser.parse
314
313
  end
315
314
  assert_equal("Fatal error: xmlParseEntityRef: no name at :5.", 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 TestSchema < Test::Unit::TestCase
5
+ class TestSchema < Minitest::Test
7
6
  def setup
8
7
  file = File.join(File.dirname(__FILE__), 'model/shiporder.xml')
9
8
  @doc = XML::Document.file(file)
@@ -19,7 +18,7 @@ class TestSchema < Test::Unit::TestCase
19
18
  end
20
19
 
21
20
  def check_error(error)
22
- assert_not_nil(error)
21
+ refute_nil(error)
23
22
  assert(error.message.match(/Error: Element 'invalid': This element is not expected. Expected is \( item \)/))
24
23
  assert_kind_of(XML::Error, error)
25
24
  assert_equal(XML::Error::SCHEMASV, error.domain)
@@ -45,13 +44,13 @@ class TestSchema < Test::Unit::TestCase
45
44
  new_node = XML::Node.new('invalid', 'this will mess up validation')
46
45
  @doc.root << new_node
47
46
 
48
- error = assert_raise(XML::Error) do
47
+ error = assert_raises(XML::Error) do
49
48
  @doc.validate_schema(schema)
50
49
  end
51
50
 
52
51
  check_error(error)
53
52
  assert_nil(error.line)
54
- assert_not_nil(error.node)
53
+ refute_nil(error.node)
55
54
  assert_equal('invalid', error.node.name)
56
55
  end
57
56