libxml-ruby 0.8.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/CHANGES +18 -0
  2. data/RAKEFILE +15 -39
  3. data/README +48 -47
  4. data/ext/libxml/libxml.c +847 -22
  5. data/ext/libxml/ruby_libxml.h +71 -95
  6. data/ext/libxml/ruby_xml_attr.c +500 -500
  7. data/ext/libxml/ruby_xml_attributes.c +1 -1
  8. data/ext/libxml/ruby_xml_document.c +1144 -1135
  9. data/ext/libxml/ruby_xml_document.h +4 -11
  10. data/ext/libxml/ruby_xml_dtd.c +27 -0
  11. data/ext/libxml/ruby_xml_encoding.c +164 -0
  12. data/ext/libxml/ruby_xml_encoding.h +13 -0
  13. data/ext/libxml/ruby_xml_error.c +941 -0
  14. data/ext/libxml/ruby_xml_error.h +13 -0
  15. data/ext/libxml/ruby_xml_html_parser.c +71 -387
  16. data/ext/libxml/ruby_xml_html_parser.h +1 -17
  17. data/ext/libxml/ruby_xml_input.c +179 -0
  18. data/ext/libxml/ruby_xml_input.h +18 -0
  19. data/ext/libxml/ruby_xml_input_cbg.c +17 -3
  20. data/ext/libxml/ruby_xml_node.c +1566 -1582
  21. data/ext/libxml/ruby_xml_node.h +1 -4
  22. data/ext/libxml/ruby_xml_ns.c +14 -3
  23. data/ext/libxml/ruby_xml_parser.c +164 -1398
  24. data/ext/libxml/ruby_xml_parser.h +5 -17
  25. data/ext/libxml/ruby_xml_parser_context.c +131 -169
  26. data/ext/libxml/ruby_xml_parser_context.h +2 -9
  27. data/ext/libxml/ruby_xml_reader.c +910 -945
  28. data/ext/libxml/ruby_xml_relaxng.c +32 -3
  29. data/ext/libxml/ruby_xml_sax_parser.c +106 -364
  30. data/ext/libxml/ruby_xml_sax_parser.h +1 -37
  31. data/ext/libxml/ruby_xml_schema.c +174 -145
  32. data/ext/libxml/ruby_xml_xinclude.c +9 -5
  33. data/ext/libxml/ruby_xml_xpath.c +25 -6
  34. data/ext/libxml/ruby_xml_xpath.h +1 -2
  35. data/ext/libxml/ruby_xml_xpath_context.c +17 -19
  36. data/ext/libxml/ruby_xml_xpath_object.c +60 -56
  37. data/ext/libxml/ruby_xml_xpointer.c +11 -5
  38. data/ext/libxml/sax_parser_callbacks.inc +42 -37
  39. data/ext/libxml/version.h +3 -3
  40. data/ext/mingw/Rakefile +20 -27
  41. data/ext/mingw/build.rake +41 -0
  42. data/ext/vc/libxml_ruby.vcproj +23 -15
  43. data/lib/libxml.rb +8 -2
  44. data/lib/libxml/document.rb +16 -4
  45. data/lib/libxml/error.rb +84 -0
  46. data/lib/libxml/hpricot.rb +76 -0
  47. data/lib/libxml/html_parser.rb +61 -0
  48. data/lib/libxml/node.rb +36 -25
  49. data/lib/libxml/parser.rb +312 -33
  50. data/lib/libxml/parser_context.rb +17 -0
  51. data/lib/libxml/properties.rb +15 -2
  52. data/lib/libxml/reader.rb +15 -0
  53. data/lib/libxml/sax_callbacks.rb +179 -0
  54. data/lib/libxml/sax_parser.rb +42 -0
  55. data/lib/libxml/tree.rb +1 -2
  56. data/lib/libxml/xpath_object.rb +12 -0
  57. data/test/model/atom.xml +4 -0
  58. data/test/tc_attributes.rb +43 -19
  59. data/test/tc_document.rb +1 -1
  60. data/test/tc_document_write.rb +15 -8
  61. data/test/tc_dtd.rb +36 -20
  62. data/test/tc_encoding.rb +13 -0
  63. data/test/tc_error.rb +136 -0
  64. data/test/tc_node.rb +2 -3
  65. data/test/tc_node_copy.rb +1 -1
  66. data/test/tc_node_edit.rb +6 -0
  67. data/test/tc_ns.rb +18 -0
  68. data/test/tc_parser.rb +113 -228
  69. data/test/tc_parser_context.rb +1 -2
  70. data/test/tc_reader.rb +24 -14
  71. data/test/tc_relaxng.rb +18 -6
  72. data/test/tc_sax_parser.rb +48 -13
  73. data/test/tc_schema.rb +20 -8
  74. data/test/tc_well_formed.rb +2 -1
  75. data/test/tc_xml.rb +212 -0
  76. data/test/tc_xpath.rb +60 -46
  77. data/test/tc_xpointer.rb +7 -11
  78. data/test/test_suite.rb +4 -3
  79. metadata +26 -109
  80. data/doc/rdoc/classes/LibXML.html +0 -241
  81. data/doc/rdoc/classes/LibXML/XML.html +0 -185
  82. data/doc/rdoc/classes/LibXML/XML/Attr.html +0 -1010
  83. data/doc/rdoc/classes/LibXML/XML/Attributes.html +0 -526
  84. data/doc/rdoc/classes/LibXML/XML/Document.html +0 -1489
  85. data/doc/rdoc/classes/LibXML/XML/Dtd.html +0 -213
  86. data/doc/rdoc/classes/LibXML/XML/Error.html +0 -117
  87. data/doc/rdoc/classes/LibXML/XML/HTMLParser.html +0 -348
  88. data/doc/rdoc/classes/LibXML/XML/InputCallbacks.html +0 -160
  89. data/doc/rdoc/classes/LibXML/XML/NS.html +0 -381
  90. data/doc/rdoc/classes/LibXML/XML/Node.html +0 -3396
  91. data/doc/rdoc/classes/LibXML/XML/Node/FailedModify.html +0 -123
  92. data/doc/rdoc/classes/LibXML/XML/Node/Set.html +0 -440
  93. data/doc/rdoc/classes/LibXML/XML/Node/SetNamespace.html +0 -123
  94. data/doc/rdoc/classes/LibXML/XML/Node/UnknownType.html +0 -123
  95. data/doc/rdoc/classes/LibXML/XML/Parser.html +0 -2239
  96. data/doc/rdoc/classes/LibXML/XML/Parser/Context.html +0 -1255
  97. data/doc/rdoc/classes/LibXML/XML/Parser/ParseError.html +0 -123
  98. data/doc/rdoc/classes/LibXML/XML/Reader.html +0 -2264
  99. data/doc/rdoc/classes/LibXML/XML/RelaxNG.html +0 -237
  100. data/doc/rdoc/classes/LibXML/XML/SaxParser.html +0 -415
  101. data/doc/rdoc/classes/LibXML/XML/Schema.html +0 -308
  102. data/doc/rdoc/classes/LibXML/XML/State.html +0 -124
  103. data/doc/rdoc/classes/LibXML/XML/Tree.html +0 -111
  104. data/doc/rdoc/classes/LibXML/XML/XInclude.html +0 -123
  105. data/doc/rdoc/classes/LibXML/XML/XInclude/Error.html +0 -117
  106. data/doc/rdoc/classes/LibXML/XML/XMLParserOptions.html +0 -198
  107. data/doc/rdoc/classes/LibXML/XML/XPath.html +0 -184
  108. data/doc/rdoc/classes/LibXML/XML/XPath/Context.html +0 -404
  109. data/doc/rdoc/classes/LibXML/XML/XPath/InvalidPath.html +0 -172
  110. data/doc/rdoc/classes/LibXML/XML/XPath/Object.html +0 -627
  111. data/doc/rdoc/classes/LibXML/XML/XPointer.html +0 -170
  112. data/doc/rdoc/classes/LibXML/XML/XPointer/Context.html +0 -123
  113. data/doc/rdoc/classes/LibXML/XML/XPointer/Context/InvalidPath.html +0 -117
  114. data/doc/rdoc/classes/LibXML/XML/XPointer/InvalidExpression.html +0 -124
  115. data/doc/rdoc/classes/singleton.html +0 -114
  116. data/doc/rdoc/created.rid +0 -1
  117. data/doc/rdoc/files/CHANGES.html +0 -442
  118. data/doc/rdoc/files/LICENSE.html +0 -133
  119. data/doc/rdoc/files/README.html +0 -388
  120. data/doc/rdoc/files/VERSION.html +0 -107
  121. data/doc/rdoc/files/ext/libxml/cbg_c.html +0 -101
  122. data/doc/rdoc/files/ext/libxml/libxml_c.html +0 -101
  123. data/doc/rdoc/files/ext/libxml/ruby_xml_attr_c.html +0 -101
  124. data/doc/rdoc/files/ext/libxml/ruby_xml_attributes_c.html +0 -101
  125. data/doc/rdoc/files/ext/libxml/ruby_xml_document_c.html +0 -101
  126. data/doc/rdoc/files/ext/libxml/ruby_xml_dtd_c.html +0 -101
  127. data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_c.html +0 -101
  128. data/doc/rdoc/files/ext/libxml/ruby_xml_input_cbg_c.html +0 -101
  129. data/doc/rdoc/files/ext/libxml/ruby_xml_node_c.html +0 -101
  130. data/doc/rdoc/files/ext/libxml/ruby_xml_node_set_c.html +0 -101
  131. data/doc/rdoc/files/ext/libxml/ruby_xml_ns_c.html +0 -101
  132. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_c.html +0 -101
  133. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_context_c.html +0 -101
  134. data/doc/rdoc/files/ext/libxml/ruby_xml_reader_c.html +0 -101
  135. data/doc/rdoc/files/ext/libxml/ruby_xml_relaxng_c.html +0 -101
  136. data/doc/rdoc/files/ext/libxml/ruby_xml_sax_parser_c.html +0 -101
  137. data/doc/rdoc/files/ext/libxml/ruby_xml_schema_c.html +0 -101
  138. data/doc/rdoc/files/ext/libxml/ruby_xml_state_c.html +0 -101
  139. data/doc/rdoc/files/ext/libxml/ruby_xml_xinclude_c.html +0 -101
  140. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_c.html +0 -101
  141. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_context_c.html +0 -101
  142. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_object_c.html +0 -101
  143. data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_c.html +0 -101
  144. data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_context_c.html +0 -101
  145. data/doc/rdoc/files/lib/libxml/attr_rb.html +0 -108
  146. data/doc/rdoc/files/lib/libxml/attributes_rb.html +0 -108
  147. data/doc/rdoc/files/lib/libxml/document_rb.html +0 -108
  148. data/doc/rdoc/files/lib/libxml/node_rb.html +0 -108
  149. data/doc/rdoc/files/lib/libxml/node_set_rb.html +0 -108
  150. data/doc/rdoc/files/lib/libxml/parser_options_rb.html +0 -107
  151. data/doc/rdoc/files/lib/libxml/parser_rb.html +0 -101
  152. data/doc/rdoc/files/lib/libxml/properties_rb.html +0 -108
  153. data/doc/rdoc/files/lib/libxml/tree_rb.html +0 -107
  154. data/doc/rdoc/files/lib/libxml_rb.html +0 -124
  155. data/doc/rdoc/files/lib/xml/libxml_rb.html +0 -124
  156. data/doc/rdoc/files/lib/xml_rb.html +0 -134
  157. data/doc/rdoc/fr_class_index.html +0 -62
  158. data/doc/rdoc/fr_file_index.html +0 -66
  159. data/doc/rdoc/fr_method_index.html +0 -392
  160. data/doc/rdoc/index.html +0 -24
  161. data/doc/rdoc/rdoc-style.css +0 -208
  162. data/ext/libxml/ruby_xml_node_set.c +0 -172
  163. data/ext/libxml/ruby_xml_node_set.h +0 -20
  164. data/ext/libxml/ruby_xml_xpointer_context.c +0 -22
  165. data/ext/libxml/ruby_xml_xpointer_context.h +0 -18
  166. data/lib/libxml/node_set.rb +0 -27
  167. data/test/tc_node_set.rb +0 -24
  168. data/test/tc_node_set2.rb +0 -37
@@ -86,7 +86,7 @@ class TestParserContext < Test::Unit::TestCase
86
86
  xp = XML::Parser.new
87
87
  xp.string = '<foo><bar/></foz>'
88
88
 
89
- assert_raise(XML::Parser::ParseError) do
89
+ assert_raise(XML::Error) do
90
90
  xp.parse
91
91
  end
92
92
 
@@ -107,7 +107,6 @@ class TestParserContext < Test::Unit::TestCase
107
107
  assert_equal(0, context.name_depth)
108
108
  assert_equal(10, context.name_depth_max)
109
109
  assert_equal(17, context.num_chars)
110
- assert_equal(0, context.options)
111
110
  assert_equal(true, context.replace_entities?)
112
111
  assert_equal(1, context.space_depth)
113
112
  assert_equal(10, context.space_depth_max)
@@ -1,7 +1,7 @@
1
1
  require 'xml'
2
2
  require 'test/unit'
3
3
 
4
- class TC_XML_Reader < Test::Unit::TestCase
4
+ class TextReader < Test::Unit::TestCase
5
5
 
6
6
  SIMPLE_XML = File.join(File.dirname(__FILE__), 'model/simple.xml')
7
7
 
@@ -21,26 +21,29 @@ class TC_XML_Reader < Test::Unit::TestCase
21
21
  verify_simple(reader)
22
22
  end
23
23
 
24
- def test_reader_error
25
- reader = XML::Reader.new('<foo/>')
26
- assert_raises(RuntimeError) { reader.set_error_handler }
24
+ def test_deprecated_error_handler
27
25
  called = false
28
- reader.set_error_handler { |*a| called = true }
29
- while reader.read > 0; end
30
- assert(!called)
31
26
  reader = XML::Reader.new('<foo blah')
32
- reader.set_error_handler do |*a|
33
- assert_equal(5, a.size)
34
- assert_equal(reader, a[0])
35
- assert_equal(XML::Reader::SEVERITY_ERROR, a[2])
36
- assert_nil(a[3])
37
- assert_equal(1, a[4])
27
+ reader.set_error_handler do |error|
38
28
  called = true
39
29
  end
40
- while reader.read > 0; end
30
+
31
+ reader.read
41
32
  assert(called)
42
33
  end
43
34
 
35
+ def test_deprecated_reset_error_handler
36
+ called = false
37
+ reader = XML::Reader.new('<foo blah')
38
+ reader.set_error_handler do |error|
39
+ called = true
40
+ end
41
+ reader.reset_error_handler
42
+
43
+ reader.read
44
+ assert(!called)
45
+ end
46
+
44
47
  def test_attr
45
48
  parser = XML::Reader.new("<foo x='1' y='2'/>")
46
49
  assert_equal(1, parser.read)
@@ -109,4 +112,11 @@ class TC_XML_Reader < Test::Unit::TestCase
109
112
  XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
110
113
  XML::Reader::TYPE_END_ELEMENT])
111
114
  end
115
+
116
+ def test_mode
117
+ reader = XML::Reader.string('<xml/>')
118
+ assert_equal(XML::Reader::MODE_INITIAL, reader.read_state)
119
+ reader.read
120
+ assert_equal(XML::Reader::MODE_EOF, reader.read_state)
121
+ end
112
122
  end
@@ -28,12 +28,24 @@ class TestRelaxNG < Test::Unit::TestCase
28
28
  new_node = XML::Node.new('invalid', 'this will mess up validation')
29
29
  @doc.root.child_add(new_node)
30
30
 
31
- messages = Hash.new
32
- assert(!@doc.validate_relaxng(relaxng) do |message, error|
33
- messages[message] = error
34
- end)
31
+ error = assert_raise(XML::Error) do
32
+ @doc.validate_relaxng(relaxng)
33
+ end
35
34
 
36
- expected = {"Did not expect element invalid there\n" => true}
37
- assert_equal(expected, messages)
35
+ assert_not_nil(error)
36
+ assert_kind_of(XML::Error, error)
37
+ assert(error.message.match(/Error: Did not expect element invalid there at/))
38
+ assert_equal(XML::Error::RELAXNGV, error.domain)
39
+ assert_equal(XML::Error::LT_IN_ATTRIBUTE, error.code)
40
+ assert_equal(XML::Error::ERROR, error.level)
41
+ assert(error.file.match(/shiporder\.xml/))
42
+ assert_nil(error.line)
43
+ assert_equal('invalid', error.str1)
44
+ assert_nil(error.str2)
45
+ assert_nil(error.str3)
46
+ assert_equal(0, error.int1)
47
+ assert_equal(0, error.int2)
48
+ assert_not_nil(error.node)
49
+ assert_equal('invalid', error.node.name)
38
50
  end
39
51
  end
@@ -1,7 +1,11 @@
1
1
  require 'xml'
2
2
  require 'test/unit'
3
3
 
4
- # TODO this is woefully inadequate
4
+ class DocTypeCallback
5
+ include XML::SaxParser::Callbacks
6
+ def on_start_element(element, attributes)
7
+ end
8
+ end
5
9
 
6
10
  class TestCaseCallbacks
7
11
  include XML::SaxParser::Callbacks
@@ -56,7 +60,6 @@ class TestSaxParser < Test::Unit::TestCase
56
60
  end
57
61
 
58
62
  def verify
59
- @xp.parse
60
63
  assert_equal [1], @xp.callbacks.test[:startdoc]
61
64
  assert_equal [[2,'test',{'uga'=>'booga','foo'=>'bar'}],[3,'fixnum',{}],[6,'fixnum',{}]],
62
65
  @xp.callbacks.test[:startel]
@@ -75,30 +78,62 @@ class TestSaxParser < Test::Unit::TestCase
75
78
  end
76
79
 
77
80
  def test_file_without_callbacks
78
- @xp.filename = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
81
+ @xp.file = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
79
82
  assert_equal true, @xp.parse
80
83
  end
81
84
 
82
- def test_callbacks_with_string
85
+ def test_string_with_callbacks
83
86
  @xp.callbacks = TestCaseCallbacks.new
84
87
  @xp.string = File.read(File.join(File.dirname(__FILE__), 'model/saxtest.xml'))
88
+ @xp.parse
85
89
  verify
86
90
  end
87
91
 
88
- def test_callbacks_with_file
92
+ def test_file_with_callbacks
89
93
  @xp.callbacks = TestCaseCallbacks.new
90
- @xp.filename = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
94
+ @xp.file = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
95
+ @xp.parse
91
96
  verify
92
97
  end
93
98
 
94
99
  def test_doctype
100
+ @xp.callbacks = DocTypeCallback.new
101
+ @xp.string = <<-EOS
102
+ <?xml version="1.0" encoding="UTF-8"?>
103
+ <!DOCTYPE Results SYSTEM "results.dtd">
104
+ <Results>
105
+ <a>a1</a>
106
+ </Results>
107
+ EOS
108
+ doc = @xp.parse
109
+ assert_not_nil(doc)
110
+ end
111
+
112
+ def test_parse_error
95
113
  @xp.callbacks = TestCaseCallbacks.new
96
114
  @xp.string = <<-EOS
97
- <?xml version="1.0" encoding="UTF-8"?>
98
- <!DOCTYPE ONIXmessage SYSTEM "http://www.editeur.org/onix/2.1/short/onix-international.dtd">
99
- <ONIXmessage release="2.1">
100
- </ONIXmessage>
115
+ <Results>
116
+ <a>a1
117
+ </Results>
101
118
  EOS
102
- @xp.parse
103
- end
104
- end # TC_XML_Sax_Parser
119
+
120
+ error = assert_raise(XML::Error) do
121
+ doc = @xp.parse
122
+ end
123
+
124
+ assert_not_nil(error)
125
+ assert_kind_of(XML::Error, error)
126
+ assert_equal("Fatal error: Premature end of data in tag Results line 1 at :4.", error.message)
127
+ assert_equal(XML::Error::PARSER, error.domain)
128
+ assert_equal(XML::Error::TAG_NOT_FINISHED, error.code)
129
+ assert_equal(XML::Error::FATAL, error.level)
130
+ assert_nil(error.file)
131
+ assert_equal(4, error.line)
132
+ assert_equal('Results', error.str1)
133
+ assert_nil(error.str2)
134
+ assert_nil(error.str3)
135
+ assert_equal(1, error.int1)
136
+ assert_equal(1, error.int2)
137
+ assert_nil(error.node)
138
+ end
139
+ end
@@ -1,4 +1,4 @@
1
- require "xml"
1
+ require 'xml'
2
2
  require 'test/unit'
3
3
 
4
4
  class TestSchema < Test::Unit::TestCase
@@ -27,13 +27,25 @@ class TestSchema < Test::Unit::TestCase
27
27
  def test_invalid
28
28
  new_node = XML::Node.new('invalid', 'this will mess up validation')
29
29
  @doc.root.child_add(new_node)
30
-
31
- messages = Hash.new
32
- assert(!@doc.validate_schema(schema) do |message, error|
33
- messages[message] = error
34
- end)
35
30
 
36
- expected = {"Element 'invalid': This element is not expected. Expected is ( item ).\n" => true}
37
- assert_equal(expected, messages)
31
+ error = assert_raise(XML::Error) do
32
+ @doc.validate_schema(schema)
33
+ end
34
+
35
+ assert_not_nil(error)
36
+ assert_kind_of(XML::Error, error)
37
+ assert(error.message.match(/Error: Element 'invalid': This element is not expected. Expected is \( item \)\. at/))
38
+ assert_equal(XML::Error::SCHEMASV, error.domain)
39
+ assert_equal(XML::Error::SCHEMAV_ELEMENT_CONTENT, error.code)
40
+ assert_equal(XML::Error::ERROR, error.level)
41
+ assert(error.file.match(/shiporder.xml/))
42
+ assert_nil(error.line)
43
+ assert_nil(error.str1)
44
+ assert_nil(error.str2)
45
+ assert_nil(error.str3)
46
+ assert_equal(0, error.int1)
47
+ assert_equal(0, error.int2)
48
+ assert_not_nil(error.node)
49
+ assert_equal('invalid', error.node.name)
38
50
  end
39
51
  end
@@ -1,10 +1,11 @@
1
- require "libxml"
1
+ require 'xml'
2
2
  require 'test/unit'
3
3
 
4
4
  class TestWellFormed < Test::Unit::TestCase
5
5
  def test_xml_node_doc_get()
6
6
  parser = XML::Parser.new
7
7
  parser.string = "<p>I am well formed</p>"
8
+ parser.parse
8
9
  assert(parser.context.well_formed?)
9
10
  end
10
11
  end
@@ -0,0 +1,212 @@
1
+ require 'xml'
2
+ require 'test/unit'
3
+ require 'stringio'
4
+
5
+ class TestXml < Test::Unit::TestCase
6
+ # ----- Constants ------
7
+ def test_lib_versions
8
+ assert(XML.check_lib_versions)
9
+ end
10
+
11
+ def test_debug_entities
12
+ XML.debug_entities = false
13
+ assert(!XML.debug_entities)
14
+
15
+ XML.debug_entities = true
16
+ assert(XML.debug_entities)
17
+
18
+ XML.debug_entities = false
19
+ assert(!XML.debug_entities)
20
+ end
21
+
22
+ def test_default_compression
23
+ return unless XML.default_compression
24
+
25
+ 0.upto(9) do |i|
26
+ XML.default_compression = i
27
+ assert_equal(i, XML.default_compression)
28
+ end
29
+
30
+ 9.downto(0) do |i|
31
+ assert_equal(i, XML.default_compression = i)
32
+ assert_equal(i, XML.default_compression)
33
+ end
34
+
35
+ 0.downto(-10) do |i|
36
+ assert_equal(i, XML.default_compression = i)
37
+ assert_equal(0, XML.default_compression)
38
+ end
39
+
40
+ 10.upto(20) do |i|
41
+ assert_equal(i, XML.default_compression = i)
42
+ assert_equal(9, XML.default_compression)
43
+ end
44
+ end
45
+
46
+ def test_default_keep_blanks
47
+ XML.default_keep_blanks = false
48
+ assert(!XML.default_keep_blanks)
49
+
50
+ XML.default_keep_blanks = true
51
+ assert(XML.default_keep_blanks)
52
+
53
+ XML.default_keep_blanks = false
54
+ assert(!XML.default_keep_blanks)
55
+
56
+ # other tests depend on keeping blanks by default,
57
+ # which is the default default behaviour anyway.
58
+ XML.default_keep_blanks = true
59
+ end
60
+
61
+ def test_default_line_numbers
62
+ XML.default_line_numbers = false
63
+ assert(!XML.default_line_numbers)
64
+
65
+ XML.default_line_numbers = true
66
+ assert(XML.default_line_numbers)
67
+
68
+ XML.default_line_numbers = false
69
+ assert(!XML.default_line_numbers)
70
+ end
71
+
72
+ def test_default_substitute_entities
73
+ XML.default_substitute_entities = false
74
+ assert(!XML.default_substitute_entities)
75
+
76
+ XML.default_substitute_entities = true
77
+ assert(XML.default_substitute_entities)
78
+
79
+ XML.default_substitute_entities = false
80
+ assert(!XML.default_substitute_entities)
81
+ end
82
+
83
+ def test_default_tree_indent_string
84
+ s = XML.default_tree_indent_string
85
+ assert_instance_of(String, s)
86
+ assert_equal(' ', s)
87
+ XML.default_tree_indent_string = 'uga'
88
+ s = XML.default_tree_indent_string
89
+ assert_instance_of(String, s)
90
+ assert_equal('uga', s)
91
+ XML.default_tree_indent_string = ' '
92
+ s = XML.default_tree_indent_string
93
+ assert_instance_of(String, s)
94
+ assert_equal(' ', s)
95
+ end
96
+
97
+ def test_default_validity_checking
98
+ XML.default_validity_checking = false
99
+ assert(!XML.default_validity_checking)
100
+
101
+ XML.default_validity_checking = true
102
+ assert(XML.default_validity_checking)
103
+
104
+ XML.default_validity_checking = false
105
+ assert(!XML.default_validity_checking)
106
+ end
107
+
108
+ def test_default_warnings
109
+ XML.default_warnings = false
110
+ assert(!XML.default_warnings)
111
+
112
+ XML.default_warnings = true
113
+ assert(XML.default_warnings)
114
+
115
+ XML.default_warnings = false
116
+ assert(!XML.default_warnings)
117
+ end
118
+
119
+ def test_enabled_automata
120
+ assert_equal(true, XML.enabled_automata?)
121
+ end
122
+
123
+ def test_enabled_c14n
124
+ assert_equal(true, XML.enabled_c14n?)
125
+ end
126
+
127
+ def test_enabled_catalog
128
+ assert_equal(true, XML.enabled_catalog?)
129
+ end
130
+
131
+ def test_enabled_debug
132
+ assert_equal(true, XML.enabled_debug?)
133
+ end
134
+
135
+ def test_enabled_docbook
136
+ assert_equal(true, XML.enabled_docbook?)
137
+ end
138
+
139
+ def test_enabled_ftp
140
+ assert_equal(true, XML.enabled_ftp?)
141
+ end
142
+
143
+ def test_enabled_http
144
+ assert_equal(true, XML.enabled_http?)
145
+ end
146
+
147
+ def test_enabled_html
148
+ assert_equal(true, XML.enabled_html?)
149
+ end
150
+
151
+ def test_enabled_iconv
152
+ assert_equal(true, XML.enabled_iconv?)
153
+ end
154
+
155
+ def test_enabled_memory_debug
156
+ assert_equal(false, XML.enabled_memory_debug?)
157
+ end
158
+
159
+ def test_enabled_regexp
160
+ assert_equal(true, XML.enabled_regexp?)
161
+ end
162
+
163
+ def test_enabled_schemas
164
+ assert_equal(true, XML.enabled_schemas?)
165
+ end
166
+
167
+ def test_enabled_thread
168
+ assert_equal(true, XML.enabled_thread?)
169
+ end
170
+
171
+ def test_enabled_unicode
172
+ assert_equal(true, XML.enabled_unicode?)
173
+ end
174
+
175
+ def test_enabled_xinclude
176
+ assert_equal(true, XML.enabled_xinclude?)
177
+ end
178
+
179
+ def test_enabled_xpath
180
+ assert_equal(true, XML.enabled_xpath?)
181
+ end
182
+
183
+ def test_enabled_xpointer
184
+ assert_equal(true, XML.enabled_xpointer?)
185
+ end
186
+
187
+ def test_enabled_zlib
188
+ assert_equal(true, XML.enabled_zlib?)
189
+ end
190
+
191
+ def test_intent_tree_output
192
+ assert(TrueClass, XML.indent_tree_output)
193
+
194
+ XML.indent_tree_output = false
195
+ assert(FalseClass, XML.indent_tree_output)
196
+
197
+ XML.indent_tree_output = true
198
+ assert(TrueClass, XML.indent_tree_output)
199
+ end
200
+
201
+ def test_version
202
+ assert_instance_of(String, XML::VERSION)
203
+ end
204
+
205
+ def test_vernum
206
+ assert_instance_of(Fixnum, XML::VERNUM)
207
+ end
208
+
209
+ def test_libxml_parser_features
210
+ assert_instance_of(Array, XML.features)
211
+ end
212
+ end