summaryrefslogtreecommitdiff
path: root/test/rdoc
diff options
context:
space:
mode:
Diffstat (limited to 'test/rdoc')
-rw-r--r--test/rdoc/test_rdoc_markup.rb200
-rw-r--r--test/rdoc/test_rdoc_markup_attribute_manager.rb51
-rw-r--r--test/rdoc/test_rdoc_ri_formatter.rb8
-rw-r--r--test/rdoc/test_rdoc_ri_overstrike_formatter.rb8
4 files changed, 222 insertions, 45 deletions
diff --git a/test/rdoc/test_rdoc_markup.rb b/test/rdoc/test_rdoc_markup.rb
index 3d68511a7b..e0a1df4a04 100644
--- a/test/rdoc/test_rdoc_markup.rb
+++ b/test/rdoc/test_rdoc_markup.rb
@@ -12,10 +12,10 @@ class TestRDocMarkup < Test::Unit::TestCase
end
def line_groups(str, expected)
- p = RDoc::Markup.new
+ m = RDoc::Markup.new
mock = RDoc::Markup::ToTest.new
- block = p.convert(str, mock)
+ block = m.convert(str, mock)
if block != expected
rows = (0...([expected.size, block.size].max)).collect{|i|
@@ -29,10 +29,10 @@ class TestRDocMarkup < Test::Unit::TestCase
end
def line_types(str, expected)
- p = RDoc::Markup.new
+ m = 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(''))
+ m.convert(str, mock)
+ assert_equal(expected, m.get_line_types.map{|type| type.to_s[0,1]}.join(''))
end
def test_groups
@@ -68,8 +68,8 @@ class TestRDocMarkup < Test::Unit::TestCase
line_groups(str,
[ "L0: Paragraph\nnow is",
"L1: ListStart\n",
- "L1: ListItem\nl1",
- "L1: ListItem\nl2",
+ "L1: BULLET ListItem\nl1",
+ "L1: BULLET ListItem\nl2",
"L1: ListEnd\n",
"L0: Paragraph\nthe time"
])
@@ -83,8 +83,8 @@ class TestRDocMarkup < Test::Unit::TestCase
line_groups(str,
[ "L0: Paragraph\nnow is",
"L1: ListStart\n",
- "L1: ListItem\nl1 l1+",
- "L1: ListItem\nl2",
+ "L1: BULLET ListItem\nl1 l1+",
+ "L1: BULLET ListItem\nl2",
"L1: ListEnd\n",
"L0: Paragraph\nthe time"
])
@@ -98,11 +98,11 @@ class TestRDocMarkup < Test::Unit::TestCase
line_groups(str,
[ "L0: Paragraph\nnow is",
"L1: ListStart\n",
- "L1: ListItem\nl1",
+ "L1: BULLET ListItem\nl1",
"L2: ListStart\n",
- "L2: ListItem\nl1.1",
+ "L2: BULLET ListItem\nl1.1",
"L2: ListEnd\n",
- "L1: ListItem\nl2",
+ "L1: BULLET ListItem\nl2",
"L1: ListEnd\n",
"L0: Paragraph\nthe time"
])
@@ -122,13 +122,13 @@ class TestRDocMarkup < Test::Unit::TestCase
line_groups(str,
[ "L0: Paragraph\nnow is",
"L1: ListStart\n",
- "L1: ListItem\nl1",
+ "L1: BULLET ListItem\nl1",
"L2: ListStart\n",
- "L2: ListItem\nl1.1 text",
+ "L2: BULLET ListItem\nl1.1 text",
"L2: Verbatim\n code\n code\n",
"L2: Paragraph\ntext",
"L2: ListEnd\n",
- "L1: ListItem\nl2",
+ "L1: BULLET ListItem\nl2",
"L1: ListEnd\n",
"L0: Paragraph\nthe time"
])
@@ -143,11 +143,11 @@ class TestRDocMarkup < Test::Unit::TestCase
line_groups(str,
[ "L0: Paragraph\nnow is",
"L1: ListStart\n",
- "L1: ListItem\nl1",
+ "L1: NUMBER ListItem\nl1",
"L2: ListStart\n",
- "L2: ListItem\nl1.1",
+ "L2: BULLET ListItem\nl1.1",
"L2: ListEnd\n",
- "L1: ListItem\nl2",
+ "L1: NUMBER ListItem\nl2",
"L1: ListEnd\n",
"L0: Paragraph\nthe time"
])
@@ -161,11 +161,11 @@ class TestRDocMarkup < Test::Unit::TestCase
line_groups(str,
[ "L0: Paragraph\nnow is",
"L1: ListStart\n",
- "L1: ListItem\nl1",
+ "L1: LABELED ListItem\ncat: l1",
"L2: ListStart\n",
- "L2: ListItem\nl1.1",
+ "L2: BULLET ListItem\nl1.1",
"L2: ListEnd\n",
- "L1: ListItem\nl2",
+ "L1: LABELED ListItem\ndog: l2",
"L1: ListEnd\n",
"L0: Paragraph\nthe time"
])
@@ -179,8 +179,8 @@ class TestRDocMarkup < Test::Unit::TestCase
line_groups(str,
[ "L0: Paragraph\nnow is",
"L1: ListStart\n",
- "L1: ListItem\nl1 continuation",
- "L1: ListItem\nl2",
+ "L1: LABELED ListItem\ncat: l1 continuation",
+ "L1: LABELED ListItem\ndog: l2",
"L1: ListEnd\n",
"L0: Paragraph\nthe time"
])
@@ -218,6 +218,133 @@ class TestRDocMarkup < Test::Unit::TestCase
end
+ def test_list_alpha
+ str = "a. alpha\nb. baker\nB. ALPHA\nA. BAKER"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: LOWERALPHA ListItem\nalpha",
+ "L1: LOWERALPHA ListItem\nbaker",
+ "L1: ListEnd\n",
+ "L1: ListStart\n",
+ "L1: UPPERALPHA ListItem\nALPHA",
+ "L1: UPPERALPHA ListItem\nBAKER",
+ "L1: ListEnd\n" ])
+ end
+
+ def test_list_bullet_dash
+ str = "- one\n- two\n"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: BULLET ListItem\none",
+ "L1: BULLET ListItem\ntwo",
+ "L1: ListEnd\n" ])
+ end
+
+ def test_list_bullet_star
+ str = "* one\n* two\n"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: BULLET ListItem\none",
+ "L1: BULLET ListItem\ntwo",
+ "L1: ListEnd\n" ])
+ end
+
+ def test_list_labeled_bracket
+ str = "[one] item one\n[two] item two"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: LABELED ListItem\none: item one",
+ "L1: LABELED ListItem\ntwo: item two",
+ "L1: ListEnd\n" ])
+ end
+
+ def test_list_labeled_bracket_continued
+ str = "[one]\n item one\n[two]\n item two"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: LABELED ListItem\none: item one",
+ "L1: LABELED ListItem\ntwo: item two",
+ "L1: ListEnd\n" ])
+ end
+
+ def test_list_labeled_colon
+ str = "one:: item one\ntwo:: item two"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: NOTE ListItem\none:: item one",
+ "L1: NOTE ListItem\ntwo:: item two",
+ "L1: ListEnd\n" ])
+ end
+
+ def test_list_labeled_colon_continued
+ str = "one::\n item one\ntwo::\n item two"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: NOTE ListItem\none:: item one",
+ "L1: NOTE ListItem\ntwo:: item two",
+ "L1: ListEnd\n" ])
+ end
+
+ def test_list_nested_bullet_bullet
+ str = "* one\n* two\n * cat\n * dog"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: BULLET ListItem\none",
+ "L1: BULLET ListItem\ntwo",
+ "L2: ListStart\n",
+ "L2: BULLET ListItem\ncat",
+ "L2: BULLET ListItem\ndog",
+ "L2: ListEnd\n",
+ "L1: ListEnd\n" ])
+ end
+
+ def test_list_nested_labeled_bullet
+ str = "[one]\n * cat\n * dog"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: LABELED ListItem\none: ",
+ "L2: ListStart\n",
+ "L2: BULLET ListItem\ncat",
+ "L2: BULLET ListItem\ndog",
+ "L2: ListEnd\n",
+ "L1: ListEnd\n" ])
+ end
+
+ def test_list_nested_labeled_bullet_bullet
+ str = "[one]\n * cat\n * dog"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: LABELED ListItem\none: ",
+ "L2: ListStart\n",
+ "L2: BULLET ListItem\ncat",
+ "L3: ListStart\n",
+ "L3: BULLET ListItem\ndog",
+ "L3: ListEnd\n",
+ "L2: ListEnd\n",
+ "L1: ListEnd\n" ])
+ end
+
+ def test_list_number
+ str = "1. one\n2. two\n1. three"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: NUMBER ListItem\none",
+ "L1: NUMBER ListItem\ntwo",
+ "L1: NUMBER ListItem\nthree",
+ "L1: ListEnd\n" ])
+ end
+
def test_list_split
str = %{\
now is
@@ -229,20 +356,30 @@ class TestRDocMarkup < Test::Unit::TestCase
line_groups(str,
[ "L0: Paragraph\nnow is",
"L1: ListStart\n",
- "L1: ListItem\nl1",
+ "L1: BULLET ListItem\nl1",
"L1: ListEnd\n",
"L1: ListStart\n",
- "L1: ListItem\nn1",
- "L1: ListItem\nn2",
+ "L1: NUMBER ListItem\nn1",
+ "L1: NUMBER ListItem\nn2",
"L1: ListEnd\n",
"L1: ListStart\n",
- "L1: ListItem\nl2",
+ "L1: BULLET ListItem\nl2",
"L1: ListEnd\n",
"L0: Paragraph\nthe time"
])
end
+ def test_paragraph
+ str = "paragraph\n\n*bold* paragraph\n"
+
+ line_groups str, [
+ "L0: Paragraph\nparagraph",
+ "L0: BlankLine\n",
+ "L0: Paragraph\n*bold* paragraph"
+ ]
+ end
+
def test_tabs
str = "hello\n dave"
assert_equal(str, basic_conv(str))
@@ -345,6 +482,15 @@ class TestRDocMarkup < Test::Unit::TestCase
line_types(str, 'PLPLP')
end
+ def test_verbatim
+ str = "paragraph\n *bold* verbatim\n"
+
+ line_groups str, [
+ "L0: Paragraph\nparagraph",
+ "L0: Verbatim\n *bold* verbatim\n"
+ ]
+ end
+
def test_verbatim_merge
str = %{\
now is
diff --git a/test/rdoc/test_rdoc_markup_attribute_manager.rb b/test/rdoc/test_rdoc_markup_attribute_manager.rb
index 0f3bb3a449..7dcce4590a 100644
--- a/test/rdoc/test_rdoc_markup_attribute_manager.rb
+++ b/test/rdoc/test_rdoc_markup_attribute_manager.rb
@@ -31,9 +31,9 @@ class TestRDocMarkupAttributeManager < Test::Unit::TestCase
crossref_bitmap = RDoc::Markup::Attribute.bitmap_for(:_SPECIAL_) |
RDoc::Markup::Attribute.bitmap_for(:CROSSREF)
- [ @am.changed_attribute_by_name([], [:CROSSREF] | [:_SPECIAL_]),
+ [ @am.changed_attribute_by_name([], [:CROSSREF, :_SPECIAL_]),
RDoc::Markup::Special.new(crossref_bitmap, text),
- @am.changed_attribute_by_name([:CROSSREF] | [:_SPECIAL_], [])
+ @am.changed_attribute_by_name([:CROSSREF, :_SPECIAL_], [])
]
end
@@ -90,29 +90,44 @@ class TestRDocMarkupAttributeManager < Test::Unit::TestCase
@am.flow("cat _a__nd_ *dog*"))
end
- def test_html_like
- assert_equal(["cat ", @tt_on, "dog", @tt_off], @am.flow("cat <tt>dog</Tt>"))
+ def test_html_like_em_bold
+ assert_equal ["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
+ @am.flow("cat <i>and </i><b>dog</b>")
+ end
- assert_equal(["cat ", @em_on, "and", @em_off, " ", @bold_on, "dog", @bold_off],
- @am.flow("cat <i>and</i> <B>dog</b>"))
+ def test_html_like_em_bold_SGML
+ assert_equal ["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
+ @am.flow("cat <i>and <b></i>dog</b>")
+ end
- assert_equal(["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off],
- @am.flow("cat <i>and <B>dog</B></I>"))
+ def test_html_like_em_bold_nested_1
+ assert_equal(["cat ", @bold_em_on, "and", @bold_em_off, " dog"],
+ @am.flow("cat <i><b>and</b></i> dog"))
+ end
- assert_equal(["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
- @am.flow("cat <i>and </i><b>dog</b>"))
+ def test_html_like_em_bold_nested_2
+ assert_equal ["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off],
+ @am.flow("cat <i>and <b>dog</b></i>")
+ end
- assert_equal(["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
- @am.flow("cat <i>and <b></i>dog</b>"))
+ def test_html_like_em_bold_nested_mixed_case
+ assert_equal ["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off],
+ @am.flow("cat <i>and <B>dog</B></I>")
+ end
- assert_equal([@tt_on, "cat", @tt_off, " ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
- @am.flow("<tt>cat</tt> <i>and <b></i>dog</b>"))
+ def test_html_like_em_bold_mixed_case
+ assert_equal ["cat ", @em_on, "and", @em_off, " ", @bold_on, "dog", @bold_off],
+ @am.flow("cat <i>and</i> <B>dog</b>")
+ end
- assert_equal(["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off],
- @am.flow("cat <i>and <b>dog</b></i>"))
+ def test_html_like_teletype
+ assert_equal ["cat ", @tt_on, "dog", @tt_off],
+ @am.flow("cat <tt>dog</Tt>")
+ end
- assert_equal(["cat ", @bold_em_on, "and", @bold_em_off, " dog"],
- @am.flow("cat <i><b>and</b></i> dog"))
+ def test_html_like_teletype_em_bold_SGML
+ assert_equal [@tt_on, "cat", @tt_off, " ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
+ @am.flow("<tt>cat</tt> <i>and <b></i>dog</b>")
end
def test_protect
diff --git a/test/rdoc/test_rdoc_ri_formatter.rb b/test/rdoc/test_rdoc_ri_formatter.rb
index 612eeb1a49..b5bc2d3245 100644
--- a/test/rdoc/test_rdoc_ri_formatter.rb
+++ b/test/rdoc/test_rdoc_ri_formatter.rb
@@ -250,6 +250,14 @@ class TestRDocRIFormatter < Test::Unit::TestCase
assert_equal " a b c\n d e f\n\n", @output.string
end
+ def test_display_verbatim_flow_item_bold
+ verbatim = RDoc::Markup::Flow::VERB.new "*a* b c"
+
+ @f.display_verbatim_flow_item verbatim
+
+ assert_equal " *a* b c\n\n", @output.string
+ end
+
def test_draw_line
@f.draw_line
diff --git a/test/rdoc/test_rdoc_ri_overstrike_formatter.rb b/test/rdoc/test_rdoc_ri_overstrike_formatter.rb
index 525c99f2cd..050e92a4fe 100644
--- a/test/rdoc/test_rdoc_ri_overstrike_formatter.rb
+++ b/test/rdoc/test_rdoc_ri_overstrike_formatter.rb
@@ -18,6 +18,14 @@ class TestRDocRIOverstrikeFormatter < Test::Unit::TestCase
@af = RDoc::RI::AttributeFormatter
end
+ def test_display_verbatim_flow_item_bold
+ verbatim = RDoc::Markup::Flow::VERB.new "*a* b c"
+
+ @f.display_verbatim_flow_item verbatim
+
+ assert_equal " *a* b c\n\n", @output.string
+ end
+
def test_write_attribute_text_bold
line = [RDoc::RI::AttributeFormatter::AttrChar.new('b', @af::BOLD)]