diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rdoc/test_rdoc_c_parser.rb (renamed from test/rdoc/parsers/test_parse_c.rb) | 2 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_markup.rb (renamed from test/rdoc/test_simple_markup.rb) | 61 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_markup_attribute_manager.rb (renamed from test/rdoc/test_simple_markup_attribute_manager.rb) | 12 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_ri_attribute_formatter.rb | 42 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_ri_formatter.rb | 124 |
5 files changed, 182 insertions, 59 deletions
diff --git a/test/rdoc/parsers/test_parse_c.rb b/test/rdoc/test_rdoc_c_parser.rb index 6157a9e1d4..ef686daed4 100644 --- a/test/rdoc/parsers/test_parse_c.rb +++ b/test/rdoc/test_rdoc_c_parser.rb @@ -17,7 +17,7 @@ class TestRdocC_Parser < Test::Unit::TestCase @top_level = RDoc::TopLevel.new filename @fn = filename - @options = Options.instance + @options = RDoc::Options.new Hash.new @stats = RDoc::Stats.new @progress = StringIO.new diff --git a/test/rdoc/test_simple_markup.rb b/test/rdoc/test_rdoc_markup.rb index 89d66c9eb5..3d68511a7b 100644 --- a/test/rdoc/test_simple_markup.rb +++ b/test/rdoc/test_rdoc_markup.rb @@ -1,62 +1,19 @@ require 'test/unit' -require 'rdoc/markup/simple_markup' +require 'rdoc/markup' +require 'rdoc/markup/to_test' -class TestSimpleMarkup < Test::Unit::TestCase - - class MockOutput - - def start_accepting - @res = [] - end - - def end_accepting - @res - end - - def accept_paragraph(am, fragment) - @res << fragment.to_s - end - - def accept_verbatim(am, fragment) - @res << fragment.to_s - end - - def accept_list_start(am, fragment) - @res << fragment.to_s - end - - def accept_list_end(am, fragment) - @res << fragment.to_s - end - - def accept_list_item(am, fragment) - @res << fragment.to_s - end - - def accept_blank_line(am, fragment) - @res << fragment.to_s - end - - def accept_heading(am, fragment) - @res << fragment.to_s - end - - def accept_rule(am, fragment) - @res << fragment.to_s - end - - end +class TestRDocMarkup < Test::Unit::TestCase def basic_conv(str) - sm = SM::SimpleMarkup.new - mock = MockOutput.new + sm = RDoc::Markup.new + mock = RDoc::Markup::ToTest.new sm.convert(str, mock) sm.content end def line_groups(str, expected) - p = SM::SimpleMarkup.new - mock = MockOutput.new + p = RDoc::Markup.new + mock = RDoc::Markup::ToTest.new block = p.convert(str, mock) @@ -72,8 +29,8 @@ class TestSimpleMarkup < Test::Unit::TestCase end def line_types(str, expected) - p = SM::SimpleMarkup.new - mock = MockOutput.new + p = RDoc::Markup.new + mock = RDoc::Markup::ToTest.new p.convert(str, mock) assert_equal(expected, p.get_line_types.map{|type| type.to_s[0,1]}.join('')) end diff --git a/test/rdoc/test_simple_markup_attribute_manager.rb b/test/rdoc/test_rdoc_markup_attribute_manager.rb index c37d821b7d..0f3bb3a449 100644 --- a/test/rdoc/test_simple_markup_attribute_manager.rb +++ b/test/rdoc/test_rdoc_markup_attribute_manager.rb @@ -1,10 +1,10 @@ require "test/unit" -require "rdoc/markup/simple_markup/inline" +require "rdoc/markup/inline" -class TestSimpleMarkupAttributeManager < Test::Unit::TestCase +class TestRDocMarkupAttributeManager < Test::Unit::TestCase def setup - @am = SM::AttributeManager.new + @am = RDoc::Markup::AttributeManager.new @bold_on = @am.changed_attribute_by_name([], [:BOLD]) @bold_off = @am.changed_attribute_by_name([:BOLD], []) @@ -28,11 +28,11 @@ class TestSimpleMarkupAttributeManager < Test::Unit::TestCase end def crossref(text) - crossref_bitmap = SM::Attribute.bitmap_for(:_SPECIAL_) | - SM::Attribute.bitmap_for(:CROSSREF) + crossref_bitmap = RDoc::Markup::Attribute.bitmap_for(:_SPECIAL_) | + RDoc::Markup::Attribute.bitmap_for(:CROSSREF) [ @am.changed_attribute_by_name([], [:CROSSREF] | [:_SPECIAL_]), - SM::Special.new(crossref_bitmap, text), + RDoc::Markup::Special.new(crossref_bitmap, text), @am.changed_attribute_by_name([:CROSSREF] | [:_SPECIAL_], []) ] end diff --git a/test/rdoc/test_rdoc_ri_attribute_formatter.rb b/test/rdoc/test_rdoc_ri_attribute_formatter.rb new file mode 100644 index 0000000000..d61a6f5cbc --- /dev/null +++ b/test/rdoc/test_rdoc_ri_attribute_formatter.rb @@ -0,0 +1,42 @@ +require 'stringio' +require 'test/unit' +require 'rdoc/ri/formatter' + +class TestRDocRIAttributeFormatter < Test::Unit::TestCase + + def setup + @output = StringIO.new + @width = 78 + @indent = ' ' + + @f = RDoc::RI::AttributeFormatter.new @output, @width, @indent + 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 + +end + 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 + |