aboutsummaryrefslogtreecommitdiffstats
path: root/test/rexml
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-18 14:25:03 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-18 14:25:03 +0000
commit6fcd0b37b3cf9b37f3bd2833cef614ae22f3f7ca (patch)
treee1dc52abc9ffab5fb74e932c7b36d0e1d142765d /test/rexml
parentc6e4767068df673200351c23c203c22731e6102a (diff)
downloadruby-6fcd0b37b3cf9b37f3bd2833cef614ae22f3f7ca.tar.gz
* lib/rexml/formatters/pretty.rb (REXML::Formatters::Pretty#wrap):
REXML::Formatters::Pretty#wrap used a recursive method call to format text. This switches it to use an iterative approach. [ruby-core:33245] Patch by Jeremy Evans. Thanks!!! * test/rexml/test_core.rb: add a test for it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rexml')
-rw-r--r--test/rexml/test_core.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/rexml/test_core.rb b/test/rexml/test_core.rb
index 5fae4f54e3..d9280f6aed 100644
--- a/test/rexml/test_core.rb
+++ b/test/rexml/test_core.rb
@@ -1151,6 +1151,22 @@ EOL
assert_not_equal( c, d )
end
+ def test_pretty_format_long_text_finite
+ n = 1_000_000
+ long_text = 'aaaa ' * n
+ xml = "<doc>#{long_text}</doc>"
+ formatter = REXML::Formatters::Pretty.new
+ document = REXML::Document.new(xml)
+ output = ""
+ assert_nothing_raised do
+ formatter.write(document, output)
+ end
+ assert_equal("<doc>\n" +
+ ((" " + (" aaaa" * 15) + "\n") * (n / 15)) +
+ " " + ("aaaa " * (n % 15)) + "\n" +
+ "</doc>",
+ output)
+ end
def test_ticket_58
doc = REXML::Document.new