From 2ef9c50c6e405717d06362787c4549ca4f1c6485 Mon Sep 17 00:00:00 2001 From: drbrain Date: Mon, 20 Dec 2010 03:22:49 +0000 Subject: Import RDoc 3 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rdoc/test_rdoc_text.rb | 110 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 102 insertions(+), 8 deletions(-) (limited to 'test/rdoc/test_rdoc_text.rb') 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 "

\nhi\n

\n", markup('hi') + assert_equal "

hi

", 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 'hi’s', + to_html('hi\'s') + end + + def test_to_html_registered_trademark + assert_equal '®', to_html('(r)') + end + + def test_to_html_tt_tag + assert_equal 'hi\'s', to_html('hi\'s') + assert_equal 'hi\\\'s', to_html('hi\\\\\'s') + end + + def test_to_html_tt_tag_mismatch + _, err = capture_io do + assert_equal 'hi', to_html('hi') + end + + assert_equal "mismatched tag\n", err + end + end -- cgit v1.2.3