summaryrefslogtreecommitdiff
path: root/test/rexml/parser/test_ultra_light.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-01-11 21:37:00 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2020-01-12 12:28:29 +0900
commitc3ccf23d5807f2ff20127bf5e42df0977bf672fb (patch)
treed3953c32b61645c7af65d30e626af944f143cf58 /test/rexml/parser/test_ultra_light.rb
parent012f297311817ecb19f78c55854b033bb4b0397c (diff)
Make rexml library to the bundle gems
[Feature #16485][ruby-core:96683]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2832
Diffstat (limited to 'test/rexml/parser/test_ultra_light.rb')
-rw-r--r--test/rexml/parser/test_ultra_light.rb70
1 files changed, 0 insertions, 70 deletions
diff --git a/test/rexml/parser/test_ultra_light.rb b/test/rexml/parser/test_ultra_light.rb
deleted file mode 100644
index 8f4a3980d5..0000000000
--- a/test/rexml/parser/test_ultra_light.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-# frozen_string_literal: false
-require "test/unit"
-require "rexml/parsers/ultralightparser"
-
-module REXMLTests
-class TestUltraLightParser < Test::Unit::TestCase
- class TestDocumentTypeDeclaration < self
- def test_entity_declaration
- assert_equal([
- [
- :start_doctype,
- :parent,
- "root",
- "SYSTEM",
- "urn:x-test",
- nil,
- [:entitydecl, "name", "value"]
- ],
- [:text, "\n"],
- [:start_element, :parent, "root", {}],
- [:text, "\n"],
- ],
- parse(<<-INTERNAL_SUBSET))
-<!ENTITY name "value">
- INTERNAL_SUBSET
- end
-
- private
- def xml(internal_subset)
- <<-XML
-<!DOCTYPE root SYSTEM "urn:x-test" [
-#{internal_subset}
-]>
-<root/>
- XML
- end
-
- def parse(internal_subset)
- parser = REXML::Parsers::UltraLightParser.new(xml(internal_subset))
- normalize(parser.parse)
- end
-
- def normalize(root)
- root.collect do |child|
- normalize_child(child)
- end
- end
-
- def normalize_child(child)
- tag = child.first
- case tag
- when :start_doctype
- normalized_parent = :parent
- normalized_doctype = child.dup
- normalized_doctype[1] = normalized_parent
- normalized_doctype
- when :start_element
- tag, _parent, name, attributes, *children = child
- normalized_parent = :parent
- normalized_children = children.collect do |sub_child|
- normalize_child(sub_child)
- end
- [tag, normalized_parent, name, attributes, *normalized_children]
- else
- child
- end
- end
- end
-end
-end