diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-20 03:22:49 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-20 03:22:49 +0000 |
commit | 2ef9c50c6e405717d06362787c4549ca4f1c6485 (patch) | |
tree | ee99486567461dd5796f3d6edcc9e204187f2666 /test/rdoc/test_rdoc_text.rb | |
parent | d7effd506f5b91a636f2e6452ef1946b923007c7 (diff) |
Import RDoc 3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc/test_rdoc_text.rb')
-rw-r--r-- | test/rdoc/test_rdoc_text.rb | 110 |
1 files changed, 102 insertions, 8 deletions
diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb index 7e0f2cf0ba..600de30b0b 100644 --- a/test/rdoc/test_rdoc_text.rb +++ b/test/rdoc/test_rdoc_text.rb @@ -1,3 +1,5 @@ +# coding: utf-8 + require 'rubygems' require 'minitest/autorun' require 'rdoc' @@ -9,6 +11,15 @@ class TestRDocText < MiniTest::Unit::TestCase include RDoc::Text + def test_self_encode_fallback + skip "Encoding not implemented" unless Object.const_defined? :Encoding + + assert_equal '…', + RDoc::Text::encode_fallback('…', Encoding::UTF_8, '...') + assert_equal '...', + RDoc::Text::encode_fallback('…', Encoding::US_ASCII, '...') + end + def test_expand_tabs assert_equal("hello\n dave", expand_tabs("hello\n dave"), 'spaces') @@ -46,9 +57,9 @@ class TestRDocText < MiniTest::Unit::TestCase def test_flush_left text = <<-TEXT - + we don't worry too much. - + The comments associated with TEXT @@ -65,7 +76,7 @@ The comments associated with def test_markup def formatter() RDoc::Markup::ToHtml.new end - assert_equal "<p>\nhi\n</p>\n", markup('hi') + assert_equal "<p>hi</p>", markup('hi').gsub("\n", '') end def test_normalize_comment @@ -114,9 +125,9 @@ The comments associated with TEXT expected = <<-EXPECTED - + we don't worry too much. - + The comments associated with EXPECTED @@ -143,15 +154,98 @@ The comments associated with TEXT expected = <<-EXPECTED - + * we don't worry too much. - + The comments associated with - EXPECTED assert_equal expected, strip_stars(text) end + def test_to_html_apostrophe + assert_equal '‘a', to_html("'a") + assert_equal 'a’', to_html("a'") + + assert_equal '‘a’ ‘', to_html("'a' '") + end + + def test_to_html_backslash + assert_equal 'S', to_html('\\S') + end + + def test_to_html_copyright + assert_equal '©', to_html('(c)') + end + + def test_to_html_dash + assert_equal '-', to_html('-') + assert_equal '–', to_html('--') + assert_equal '—', to_html('---') + assert_equal '—-', to_html('----') + end + + def test_to_html_double_backtick + assert_equal '“a', to_html('``a') + assert_equal '“a“', to_html('``a``') + end + + def test_to_html_double_quote + assert_equal '“a', to_html('"a') + assert_equal '“a”', to_html('"a"') + end + + def test_to_html_double_quote_quot + assert_equal '“a', to_html('"a') + assert_equal '“a”', to_html('"a"') + end + + def test_to_html_double_tick + assert_equal '”a', to_html("''a") + assert_equal '”a”', to_html("''a''") + end + + def test_to_html_ellipsis + assert_equal '..', to_html('..') + assert_equal '…', to_html('...') + assert_equal '.…', to_html('....') + end + + def test_to_html_encoding + skip "Encoding not implemented" unless Object.const_defined? :Encoding + + s = '...(c)'.encode Encoding::Shift_JIS + + html = to_html s + + assert_equal Encoding::Shift_JIS, html.encoding + + expected = '…(c)'.encode Encoding::Shift_JIS + + assert_equal expected, html + end + + def test_to_html_html_tag + assert_equal '<a href="http://example">hi’s</a>', + to_html('<a href="http://example">hi\'s</a>') + end + + def test_to_html_registered_trademark + assert_equal '®', to_html('(r)') + end + + def test_to_html_tt_tag + assert_equal '<tt>hi\'s</tt>', to_html('<tt>hi\'s</tt>') + assert_equal '<tt>hi\\\'s</tt>', to_html('<tt>hi\\\\\'s</tt>') + end + + def test_to_html_tt_tag_mismatch + _, err = capture_io do + assert_equal '<tt>hi', to_html('<tt>hi') + end + + assert_equal "mismatched <tt> tag\n", err + end + end |