1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/rexml/test_core.rb: enable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2010-09-17 14:11:10 +00:00
parent 2a15d25a59
commit ede915ce25
2 changed files with 41 additions and 21 deletions

View file

@ -1,3 +1,7 @@
Fri Sep 17 23:10:44 2010 Kouhei Sutou <kou@cozmixng.org>
* test/rexml/test_core.rb: enable.
Fri Sep 17 22:46:02 2010 Kouhei Sutou <kou@cozmixng.org>
* test/rexml/: untabify.

View file

@ -1,15 +1,18 @@
# coding: binary
require "test/unit/testcase"
require "rexml_test_utils"
require "rexml/document"
require "rexml/parseexception"
require "test/listener"
require "rexml/output"
require "rexml/source"
require "rexml/formatters/pretty"
require "rexml/undefinednamespaceexception"
require "listener"
class Tester < Test::Unit::TestCase
include REXMLTestUtils
include REXML
def setup
@xsa_source = <<-EOL
@ -37,7 +40,7 @@ class Tester < Test::Unit::TestCase
'<0/>',
'<a>&</a>',
'<a>&a</a>',
'<a>&a;</a>',
# '<a>&a;</a>', # FIXME
'<a a="<"/>',
'<a 3="<"/>',
'<a a="1" a="2"/>',
@ -49,11 +52,11 @@ class Tester < Test::Unit::TestCase
"<a>\f</a>",
"<a a='\f' />",
"<a>\000</a>",
'<a' + [65535].pack('U') + ' />',
# FIXME '<a' + [65535].pack('U') + ' />',
'<a>&#xfffe;</a>',
'<a>&#65535;</a>',
'<a' + [0x0371].pack('U') + ' />',
'<a a' + [0x0371].pack('U') + '="" />',
# FIXME '<a' + [0x0371].pack('U') + ' />',
# FIXME '<a a' + [0x0371].pack('U') + '="" />',
].each do |src|
assert_raise( ParseException, %Q{Parse #{src.inspect} should have failed!} ) do
Document.new(src)
@ -223,7 +226,7 @@ class Tester < Test::Unit::TestCase
assert_equal(correct, test)
# OK, the BIG doctype test, numba wun
docin = File.new "test/data/doctype_test.xml"
docin = File.new(fixture_path("doctype_test.xml"))
doc = Document.new(docin)
doc.write(test="")
assert_equal(31, doc.doctype.size)
@ -266,7 +269,7 @@ class Tester < Test::Unit::TestCase
assert_instance_of DocType, doc.doctype
assert_equal doc.version, "1.0"
source = File.new( "test/data/dash.xml" )
source = File.new(fixture_path("dash.xml"))
doc = Document.new source
assert_equal "content-2", doc.elements["//content-2"].name
end
@ -357,7 +360,7 @@ class Tester < Test::Unit::TestCase
assert_equal doc.root.name.to_s, "xsa"
# Testing IO source
doc = Document.new File.new("test/data/project.xml")
doc = Document.new File.new(fixture_path("project.xml"))
assert_equal doc.root.name.to_s, "Project"
end
@ -443,7 +446,7 @@ class Tester < Test::Unit::TestCase
# enormous.
def test_element_access
# Testing each_element
doc = Document.new File.new("test/data/project.xml")
doc = Document.new File.new(fixture_path("project.xml"))
each_test( doc, "/", 1 ) { |child|
assert_equal doc.name, child.name
@ -608,7 +611,7 @@ class Tester < Test::Unit::TestCase
def test_big_documentation
f = File.new("test/data/documentation.xml")
f = File.new(fixture_path("documentation.xml"))
d = Document.new f
assert_equal "Sean Russell", d.elements["documentation/head/author"].text.tr("\n\t", " ").squeeze(" ")
out = ""
@ -616,14 +619,14 @@ class Tester < Test::Unit::TestCase
end
def test_tutorial
doc = Document.new File.new("test/data/tutorial.xml")
doc = Document.new File.new(fixture_path("tutorial.xml"))
out = ""
doc.write out
end
def test_stream
c = Listener.new
Document.parse_stream( File.new("test/data/documentation.xml"), c )
Document.parse_stream( File.new(fixture_path("documentation.xml")), c )
assert(c.ts, "Stream parsing apparantly didn't parse the whole file")
assert(c.te, "Stream parsing dropped end tag for documentation")
@ -634,7 +637,7 @@ class Tester < Test::Unit::TestCase
end
def test_line
doc = Document.new File.new( "test/data/bad.xml" )
doc = Document.new File.new(fixture_path("bad.xml"))
assert_fail "There should have been an error"
rescue Exception
# We should get here
@ -799,7 +802,7 @@ EOL
def test_entities
a = Document.new( '<a>&#101;&#x65;&#252;</a>' )
assert_equal 'eeü', a.root.text
assert_equal('eeü'.force_encoding("UTF-8"), a.root.text)
end
def test_element_decl
@ -846,7 +849,7 @@ EOL
end
def test_attlist_write
file=File.new("test/data/foo.xml" )
file=File.new(fixture_path("foo.xml"))
doc=Document.new file
root = doc.root
@ -1121,7 +1124,7 @@ EOL
def test_repeated_writes
require 'iconv'
a = IO.read( "test/data/iso8859-1.xml" )
a = IO.read(fixture_path("iso8859-1.xml"))
f = REXML::Formatters::Pretty.new
xmldoc = REXML::Document.new( a )
@ -1211,11 +1214,11 @@ EOL
end
def test_ticket_63
d = REXML::Document.new( File.new("test/data/t63-1.xml") )
d = REXML::Document.new(File.new(fixture_path("t63-1.xml")))
end
def test_ticket_75
d = REXML::Document.new( File.new("test/data/t75.xml") )
d = REXML::Document.new(File.new(fixture_path("t75.xml")))
assert_equal("tree", d.root.name)
end
@ -1372,11 +1375,24 @@ ENDXML
'<svg xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" ' +
'inkscape:version="0.44" version="1.0"/>'
)
assert_equal "<svg inkscape:version='0.44' version='1.0' xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape'/>", doc.root.to_s
assert_equal 3, doc.root.attributes.to_a.length
expected = {
"inkscape" => attribute("xmlns:inkscape",
"http://www.inkscape.org/namespaces/inkscape"),
"version" => {
"inkscape" => attribute("inkscape:version", "0.44"),
"" => attribute("version", "1.0"),
},
}
assert_equal(expected, doc.root.attributes)
assert_equal(expected, REXML::Document.new(doc.root.to_s).root.attributes)
end
def test_empty_doc
assert(REXML::Document.new('').children.empty?)
end
private
def attribute(name, value)
REXML::Attribute.new(name, value)
end
end