diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-19 00:06:19 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-19 00:06:19 +0000 |
commit | 8d37cefaf8795fe80d457f101fb9678fc7f6adf6 (patch) | |
tree | de06a2bb9bbbeffa5e12213e875a57fe269a2028 /test/rdoc/test_rdoc_ri_formatter.rb | |
parent | 9872d4d60048cc16cf78d2e8a260b78468e87fc9 (diff) | |
download | ruby-8d37cefaf8795fe80d457f101fb9678fc7f6adf6.tar.gz |
* lib/rdoc/markup: Remove ListBase and Line constants.
* lib/rdoc/ri: Allow output IO to be specified.
* test/rdoc/parser/test_parse_c.rb: Move up one level, fixed.
* test/rdoc/parser/test_rdoc_markup_attribute_manager.rb: Renamed to
match new class name, updated to match new classes.
* test/rdoc/test_rdoc_ri_formatter.rb: Start of RI formatting tests.
* test/rdoc/test_rdoc_ri_attribute_manager.rb: Start of
RDoc::RI::AttributeManager tests.
* test/rdoc/test_simple_markup.rb: Moved to match new class name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc/test_rdoc_ri_formatter.rb')
-rw-r--r-- | test/rdoc/test_rdoc_ri_formatter.rb | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/test/rdoc/test_rdoc_ri_formatter.rb b/test/rdoc/test_rdoc_ri_formatter.rb new file mode 100644 index 0000000000..a92f6cf7b8 --- /dev/null +++ b/test/rdoc/test_rdoc_ri_formatter.rb @@ -0,0 +1,124 @@ +require 'stringio' +require 'test/unit' +require 'rdoc/ri/formatter' +require 'rdoc/markup/to_flow' + +class TestRDocRIFormatter < Test::Unit::TestCase + + def setup + @output = StringIO.new + @width = 78 + @indent = ' ' + + @f = RDoc::RI::Formatter.new @output, @width, @indent + @markup = RDoc::Markup.new + @flow = RDoc::Markup::ToFlow.new + end + + def test_blankline + @f.blankline + + assert_equal "\n", @output.string + end + + def test_bold_print + @f.bold_print 'a b c' + + assert_equal 'a b c', @output.string + end + + def test_break_to_newline + @f.break_to_newline + + assert_equal '', @output.string + end + + def test_conv_html + assert_equal '> < " &', @f.conv_html('> < " &') + end + + def test_conv_markup + text = '<tt>a</tt> <code>b</code> <b>c</b> <em>d</em>' + + expected = '+a+ +b+ *c* _d_' + + assert_equal expected, @f.conv_markup(text) + end + + def test_display_list_bullet + list = util_convert('* a b c').first + + @f.display_list list + + assert_equal " * a b c\n\n", @output.string + end + + def test_display_list_unknown + list = util_convert('* a b c').first + list.instance_variable_set :@type, :UNKNOWN + + e = assert_raise ArgumentError do + @f.display_list list + end + + assert_equal 'unknown list type UNKNOWN', e.message + end + + def test_draw_line + @f.draw_line + + expected = '-' * @width + "\n" + assert_equal expected, @output.string + end + + def test_draw_line_label + @f.draw_line 'label' + + expected = '-' * (@width - 6) + " label\n" + assert_equal expected, @output.string + end + + def test_draw_line_label_long + @f.draw_line 'a' * @width + + expected = '-' * @width + "\n" + ('a' * @width) + "\n" + assert_equal expected, @output.string + end + + def test_raw_print_line + @f.raw_print_line 'a b c' + + assert_equal "a b c\n", @output.string + end + + def test_wrap_empty + @f.wrap '' + assert_equal '', @output.string + end + + def test_wrap_long + @f.wrap 'a ' * (@width / 2) + assert_equal " a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a\n a \n", + @output.string + end + + def test_wrap_markup + @f.wrap 'a <tt>b</tt> c' + assert_equal " a +b+ c\n", @output.string + end + + def test_wrap_nil + @f.wrap nil + assert_equal '', @output.string + end + + def test_wrap_short + @f.wrap 'a b c' + assert_equal " a b c\n", @output.string + end + + def util_convert(text) + @markup.convert text, @flow + end +end + |