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_markup_to_ansi.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_markup_to_ansi.rb')
-rw-r--r-- | test/rdoc/test_rdoc_markup_to_ansi.rb | 196 |
1 files changed, 43 insertions, 153 deletions
diff --git a/test/rdoc/test_rdoc_markup_to_ansi.rb b/test/rdoc/test_rdoc_markup_to_ansi.rb index a8fab98d19..1334ac71c4 100644 --- a/test/rdoc/test_rdoc_markup_to_ansi.rb +++ b/test/rdoc/test_rdoc_markup_to_ansi.rb @@ -1,11 +1,12 @@ require 'rubygems' -require 'rdoc/markup/formatter_test_case' +require 'rdoc/markup/text_formatter_test_case' require 'rdoc/markup/to_ansi' require 'minitest/autorun' -class TestRDocMarkupToAnsi < RDoc::Markup::FormatterTestCase +class TestRDocMarkupToAnsi < RDoc::Markup::TextFormatterTestCase add_visitor_tests + add_text_tests def setup super @@ -62,7 +63,7 @@ class TestRDocMarkupToAnsi < RDoc::Markup::FormatterTestCase end def accept_list_item_end_label - assert_equal "\e[0m\n", @to.res.join + assert_equal "\e[0m", @to.res.join assert_equal 0, @to.indent, 'indent' end @@ -72,7 +73,7 @@ class TestRDocMarkupToAnsi < RDoc::Markup::FormatterTestCase end def accept_list_item_end_note - assert_equal "\e[0m\n", @to.res.join + assert_equal "\e[0m", @to.res.join assert_equal 0, @to.indent, 'indent' end @@ -191,8 +192,8 @@ class TestRDocMarkupToAnsi < RDoc::Markup::FormatterTestCase assert_equal "\e[0m#{'-' * 78}\n", @to.res.join end - def accept_verbatim # FormatterTestCase doesn't set indent for ToAnsi - assert_equal "\e[0m hi\n world\n\n", @to.res.join + def accept_verbatim + assert_equal "\e[0m hi\n world\n\n", @to.res.join end def end_accepting @@ -207,214 +208,103 @@ class TestRDocMarkupToAnsi < RDoc::Markup::FormatterTestCase assert_empty @to.list_width end - def test_accept_heading_1 - @to.start_accepting - @to.accept_heading @RM::Heading.new(1, 'Hello') - + def accept_heading_1 assert_equal "\e[0m\e[1;32mHello\e[m\n", @to.end_accepting end - def test_accept_heading_2 - @to.start_accepting - @to.accept_heading @RM::Heading.new(2, 'Hello') - + def accept_heading_2 assert_equal "\e[0m\e[4;32mHello\e[m\n", @to.end_accepting end - def test_accept_heading_3 - @to.start_accepting - @to.accept_heading @RM::Heading.new(3, 'Hello') - + def accept_heading_3 assert_equal "\e[0m\e[32mHello\e[m\n", @to.end_accepting end - def test_accept_heading_4 - @to.start_accepting - @to.accept_heading @RM::Heading.new(4, 'Hello') - + def accept_heading_4 assert_equal "\e[0mHello\n", @to.end_accepting end - def test_accept_heading_indent - @to.start_accepting - @to.indent = 3 - @to.accept_heading @RM::Heading.new(1, 'Hello') - + def accept_heading_indent assert_equal "\e[0m \e[1;32mHello\e[m\n", @to.end_accepting end - def test_accept_heading_b - @to.start_accepting - @to.indent = 3 - @to.accept_heading @RM::Heading.new(1, '*Hello*') - - assert_equal "\e[0m \e[1;32m\e[1mHello\e[m\e[m\n", @to.end_accepting + def accept_heading_b + assert_equal "\e[0m\e[1;32m\e[1mHello\e[m\e[m\n", @to.end_accepting end - def test_accept_list_item_start_note_2 - list = @RM::List.new(:NOTE, - @RM::ListItem.new('<tt>teletype</tt>', - @RM::Paragraph.new('teletype description'))) - - @to.start_accepting - - list.accept @to - - expected = "\e[0m\e[7mteletype\e[m:\n teletype description\n\n" - - assert_equal expected, @to.end_accepting + def accept_heading_suppressed_crossref + assert_equal "\e[0m\e[1;32mHello\e[m\n", @to.end_accepting end - def test_accept_paragraph_b - @to.start_accepting - @to.accept_paragraph @RM::Paragraph.new('reg <b>bold words</b> reg') - - expected = "\e[0mreg \e[1mbold words\e[m reg\n" - - assert_equal expected, @to.end_accepting + def accept_list_item_start_note_2 + assert_equal "\e[0m\e[7mteletype\e[m:\n teletype description\n\n", + @to.res.join end - def test_accept_paragraph_i - @to.start_accepting - @to.accept_paragraph @RM::Paragraph.new('reg <em>italic words</em> reg') - - expected = "\e[0mreg \e[4mitalic words\e[m reg\n" - - assert_equal expected, @to.end_accepting + def accept_paragraph_b + assert_equal "\e[0mreg \e[1mbold words\e[m reg\n", @to.end_accepting end - def test_accept_paragraph_indent - @to.start_accepting - @to.indent = 3 - @to.accept_paragraph @RM::Paragraph.new('words ' * 30) + def accept_paragraph_i + assert_equal "\e[0mreg \e[4mitalic words\e[m reg\n", @to.end_accepting + end + def accept_paragraph_indent expected = <<-EXPECTED \e[0m words words words words words words words words words words words words words words words words words words words words words words words words - words words words words words words + words words words words words words EXPECTED assert_equal expected, @to.end_accepting end - def test_accept_paragraph_plus - @to.start_accepting - @to.accept_paragraph @RM::Paragraph.new('regular +teletype+ regular') - - expected = "\e[0mregular \e[7mteletype\e[m regular\n" - - assert_equal expected, @to.end_accepting + def accept_paragraph_plus + assert_equal "\e[0mreg \e[7mteletype\e[m reg\n", @to.end_accepting end - def test_accept_paragraph_star - @to.start_accepting - @to.accept_paragraph @RM::Paragraph.new('regular *bold* regular') - - expected = "\e[0mregular \e[1mbold\e[m regular\n" - - assert_equal expected, @to.end_accepting + def accept_paragraph_star + assert_equal "\e[0mreg \e[1mbold\e[m reg\n", @to.end_accepting end - def test_accept_paragraph_underscore - @to.start_accepting - @to.accept_paragraph @RM::Paragraph.new('regular _italic_ regular') - - expected = "\e[0mregular \e[4mitalic\e[m regular\n" - - assert_equal expected, @to.end_accepting + def accept_paragraph_underscore + assert_equal "\e[0mreg \e[4mitalic\e[m reg\n", @to.end_accepting end - def test_accept_paragraph_wrap - @to.start_accepting - @to.accept_paragraph @RM::Paragraph.new('words ' * 30) - + def accept_paragraph_wrap expected = <<-EXPECTED \e[0mwords words words words words words words words words words words words words words words words words words words words words words words words words words -words words words words +words words words words EXPECTED assert_equal expected, @to.end_accepting end - def test_accept_rule_indent - @to.start_accepting - @to.indent = 3 - - @to.accept_rule @RM::Rule.new(1) - + def accept_rule_indent assert_equal "\e[0m #{'-' * 75}\n", @to.end_accepting end - def test_accept_verbatim_indent - @to.start_accepting - - @to.indent = 2 - - @to.accept_verbatim @RM::Verbatim.new(' ', 'hi', "\n", - ' ', 'world', "\n") - + def accept_verbatim_indent assert_equal "\e[0m hi\n world\n\n", @to.end_accepting end - def test_accept_verbatim_big_indent - @to.start_accepting - - @to.indent = 2 - - @to.accept_verbatim @RM::Verbatim.new(' ', 'hi', "\n", - ' ', 'world', "\n") - + def accept_verbatim_big_indent assert_equal "\e[0m hi\n world\n\n", @to.end_accepting end - def test_attributes - assert_equal 'Dog', @to.attributes("\\Dog") - end - - def test_list_nested - doc = @RM::Document.new( - @RM::List.new(:BULLET, - @RM::ListItem.new(nil, - @RM::Paragraph.new('l1'), - @RM::List.new(:BULLET, - @RM::ListItem.new(nil, - @RM::Paragraph.new('l1.1')))), - @RM::ListItem.new(nil, - @RM::Paragraph.new('l2')))) - - output = doc.accept @to - + def list_nested expected = <<-EXPECTED \e[0m* l1 * l1.1 * l2 EXPECTED - assert_equal expected, output - end - - def test_list_verbatim # HACK overblown - doc = @RM::Document.new( - @RM::List.new(:BULLET, - @RM::ListItem.new(nil, - @RM::Paragraph.new('list', 'stuff'), - @RM::BlankLine.new(), - @RM::Verbatim.new(' ', '*', ' ', 'list', "\n", - ' ', 'with', "\n", - "\n", - ' ', 'second', "\n", - "\n", - ' ', '1.', ' ', 'indented', "\n", - ' ', '2.', ' ', 'numbered', "\n", - "\n", - ' ', 'third', "\n", - "\n", - ' ', '*', ' ', 'second', "\n")))) - - output = doc.accept @to + assert_equal expected, @to.end_accepting + end - expected = <<-EXPECTED + def list_verbatim + expected = <<-EXPECTED # HACK overblown \e[0m* list stuff * list @@ -431,7 +321,7 @@ words words words words EXPECTED - assert_equal expected, output + assert_equal expected, @to.end_accepting end end |