mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/rexml/test_listener.rb: remove needless codes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
91ed484f92
commit
d357d7279a
2 changed files with 5 additions and 82 deletions
|
@ -1,3 +1,7 @@
|
|||
Fri Sep 17 22:15:15 2010 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* test/rexml/test_listener.rb: remove needless codes.
|
||||
|
||||
Fri Sep 17 22:12:23 2010 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* test/rexml/: import REXML tests from
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# coding: binary
|
||||
require 'test/unit/testcase'
|
||||
|
||||
require 'rexml/document'
|
||||
require 'rexml/streamlistener'
|
||||
|
||||
|
@ -96,76 +96,6 @@ class BaseTester < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
#########################################################
|
||||
# Other parsers commented out because they cause failures
|
||||
# in the unit tests, which aren't REXMLs problems
|
||||
# #######################################################
|
||||
=begin
|
||||
begin
|
||||
require 'xmlparser'
|
||||
class MyXMLParser
|
||||
class Listener < XML::Parser
|
||||
# Dummy handler to get XML::Parser::XML_DECL event.
|
||||
def xmlDecl; end
|
||||
end
|
||||
|
||||
def parse( stringOrReadable )
|
||||
text = ""
|
||||
Listener.new.parse( stringOrReadable ) do | type, name, data |
|
||||
case type
|
||||
when XML::Parser::CDATA
|
||||
text << data
|
||||
end
|
||||
end
|
||||
text
|
||||
end
|
||||
end
|
||||
|
||||
class XMLParserTester < BaseTester
|
||||
def setup
|
||||
@listener = MyXMLParser.new
|
||||
end
|
||||
end
|
||||
rescue LoadError
|
||||
#puts "XMLParser not available"
|
||||
end
|
||||
|
||||
begin
|
||||
require 'nqxml/tokenizer'
|
||||
class MyNQXMLLightWeightListener
|
||||
def parse( stringOrReadable )
|
||||
text = ""
|
||||
isText = false
|
||||
tokenizer = NQXML::Tokenizer.new( stringOrReadable )
|
||||
tokenizer.each do | entity |
|
||||
case entity
|
||||
when NQXML::Tag
|
||||
if !entity.isTagEnd
|
||||
isText = true
|
||||
else
|
||||
isText = false
|
||||
end
|
||||
when NQXML::Text
|
||||
if isText
|
||||
text << entity.text
|
||||
isText = false
|
||||
end
|
||||
end
|
||||
end
|
||||
text
|
||||
end
|
||||
end
|
||||
|
||||
class NQXMLTester < BaseTester
|
||||
def setup
|
||||
@listener = MyNQXMLLightWeightListener.new
|
||||
end
|
||||
end
|
||||
rescue LoadError
|
||||
#puts "NQXML not available"
|
||||
end
|
||||
=end
|
||||
|
||||
class MyREXMLListener
|
||||
include REXML::StreamListener
|
||||
|
||||
|
@ -194,14 +124,3 @@ class REXMLTester < BaseTester
|
|||
assert_equal( t6.strip, REXML::Document.new(t6).to_s )
|
||||
end
|
||||
end
|
||||
|
||||
if __FILE__ == $0
|
||||
case ARGV[0]
|
||||
when 'NQXML'
|
||||
RUNIT::CUI::TestRunner.run( NQXMLTester.suite )
|
||||
when 'XMLParser'
|
||||
RUNIT::CUI::TestRunner.run( XMLParserTester.suite )
|
||||
else
|
||||
RUNIT::CUI::TestRunner.run( REXMLTester.suite )
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue