mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 09:33:59 +02:00

-- * test/rexml/: import REXML tests from http://www.germane-software.com/repos/rexml/trunk/test/. Many tests are failed temporary. I'll fix them quickly. Sorry. -- * test/rexml/test_listener.rb: remove needless codes. -- * test/rexml/: fix fixture data path. All REXML tests are worked. -- * test/rexml/: untabify. -- * test/rexml/test_core.rb: enable. -- * test/rexml/test_sax.rb: don't use thread and sleep to avoid slow test. -- * lib/rexml/xpath_parser.rb, test/rexml/test_xpath.rb: add missing method availability check. [ruby-core:32447] Reported by Wiebe Cazemier. Thanks!!! -- Specify external encoding. When external encoding is not specified, it uses default external encoding. But it depends the environment. So specify as UTF-8 for environments whose locale is not UTF-8. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@29915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
56 lines
1.9 KiB
Ruby
56 lines
1.9 KiB
Ruby
#------------------------------------------------------------------------------
|
|
# file: rexml_test.rb
|
|
# desc: test's REXML's XML/XPath implementation
|
|
# auth: Philip J Grabner <grabner>at<uberdev>dot<org>
|
|
# date: 2006/08/17
|
|
# copy: (C) CopyLoose 2006 Bib Development Team <bib-devel>at<uberdev>dot<org>
|
|
#------------------------------------------------------------------------------
|
|
|
|
require 'test/unit'
|
|
require 'rexml/document'
|
|
|
|
class Ticket80 < Test::Unit::TestCase
|
|
|
|
@@xmlstr = '<?xml version="1.0"?>
|
|
<root xmlns="urn:some-xml-ns" xmlns:other="urn:some-other-xml-ns">
|
|
<l1-foo>
|
|
<l2 value="foo-01"/>
|
|
<l2 value="foo-02"/>
|
|
<l2 value="foo-03"/>
|
|
</l1-foo>
|
|
<other:l1>
|
|
<l2 value="no-show"/>
|
|
</other:l1>
|
|
<l1-bar>
|
|
<l2 value="bar-01"/>
|
|
<l2 value="bar-02"/>
|
|
</l1-bar>
|
|
</root>'
|
|
|
|
#----------------------------------------------------------------------------
|
|
def test_xpathNamespacedChildWildcard
|
|
# tests the "prefix:*" node test syntax
|
|
out = Array.new
|
|
REXML::XPath.each( REXML::Document.new(@@xmlstr),
|
|
'/ns:root/ns:*/ns:l2/@value',
|
|
{ 'ns' => 'urn:some-xml-ns' } ) do |node| out.push node.value ; end
|
|
chk = [ 'foo-01', 'foo-02', 'foo-03', 'bar-01', 'bar-02' ]
|
|
assert_equal chk, out
|
|
end
|
|
|
|
#----------------------------------------------------------------------------
|
|
def test_xpathNamespacedChildWildcardWorkaround
|
|
# tests a workaround for the "prefix:*" node test syntax
|
|
out = Array.new
|
|
REXML::XPath.each( REXML::Document.new(@@xmlstr),
|
|
'/ns:root/*[namespace-uri()="urn:some-xml-ns"]/ns:l2/@value',
|
|
{ 'ns' => 'urn:some-xml-ns' } ) do |node| out.push node.value ; end
|
|
chk = [ 'foo-01', 'foo-02', 'foo-03', 'bar-01', 'bar-02' ]
|
|
assert_equal chk, out
|
|
end
|
|
|
|
end
|
|
|
|
#------------------------------------------------------------------------------
|
|
# end of rexml_test.rb
|
|
#------------------------------------------------------------------------------
|