[前][次][番号順一覧][スレッド一覧]

ruby-changes:30433

From: kou <ko1@a...>
Date: Sun, 11 Aug 2013 17:43:26 +0900 (JST)
Subject: [ruby-changes:30433] kou:r42512 (trunk): * test/rexml/parser/test_sax2.rb: Add SAX2 API test.

kou	2013-08-11 17:43:17 +0900 (Sun, 11 Aug 2013)

  New Revision: 42512

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42512

  Log:
    * test/rexml/parser/test_sax2.rb: Add SAX2 API test.

  Added directories:
    trunk/test/rexml/parser/
  Added files:
    trunk/test/rexml/parser/test_sax2.rb
  Modified files:
    trunk/ChangeLog
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42511)
+++ ChangeLog	(revision 42512)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Aug 11 17:41:41 2013  Kouhei Sutou  <kou@c...>
+
+	* test/rexml/parser/test_sax2.rb: Add SAX2 API test.
+
 Sun Aug 11 15:10:40 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (rb_enc_symname_type): allow ID_ATTRSET for ID_INSTANCE,
Index: test/rexml/parser/test_sax2.rb
===================================================================
--- test/rexml/parser/test_sax2.rb	(revision 0)
+++ test/rexml/parser/test_sax2.rb	(revision 42512)
@@ -0,0 +1,57 @@ https://github.com/ruby/ruby/blob/trunk/test/rexml/parser/test_sax2.rb#L1
+require "test/unit"
+require "rexml/parsers/sax2parser"
+require "rexml/sax2listener"
+
+class TestSAX2Parser < Test::Unit::TestCase
+  class TestDocumentTypeDeclaration < self
+    private
+    def xml(internal_subset)
+      <<-XML
+<!DOCTYPE r SYSTEM "urn:x-henrikmartensson:test" [
+#{internal_subset}
+]>
+<r/>
+      XML
+    end
+
+    class TestEntityDecl < self
+      class Listener
+        include REXML::SAX2Listener
+        attr_reader :entity_declarations
+        def initialize
+          @entity_declarations = []
+        end
+
+        def entitydecl(*args)
+          super
+          @entity_declarations << args
+        end
+      end
+
+      private
+      def parse(internal_subset)
+        listener = Listener.new
+        parser = REXML::Parsers::SAX2Parser.new(xml(internal_subset))
+        parser.listen(listener)
+        parser.parse
+        listener.entity_declarations
+      end
+
+      class TestGeneralEntity < self
+        class TestValue < self
+          def test_double_quote
+            assert_equal([["name", "value"]], parse(<<-INTERNAL_SUBSET))
+<!ENTITY name "value">
+            INTERNAL_SUBSET
+          end
+
+          def test_single_quote
+            assert_equal([["name", "value"]], parse(<<-INTERNAL_SUBSET))
+<!ENTITY name 'value'>
+            INTERNAL_SUBSET
+          end
+        end
+      end
+    end
+  end
+end

Property changes on: test/rexml/parser/test_sax2.rb
___________________________________________________________________
Added: svn:eol-style
   + LF


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]