1require 'rdoc/test_case'
2
3class TestRDocMarkup < RDoc::TestCase
4
5  def test_class_parse
6    expected = @RM::Document.new(
7      @RM::Paragraph.new('hello'))
8
9    assert_equal expected, RDoc::Markup.parse('hello')
10  end
11
12  def test_convert
13    str = <<-STR
14now is
15the time
16
17  hello
18  dave
19
201. l1
212. l2
22    STR
23
24    m = RDoc::Markup.new
25
26    tt = RDoc::Markup::ToTest.new m
27
28    out = m.convert str, tt
29
30    expected = [
31      "now is the time",
32      "\n",
33      "  hello\n  dave\n",
34      "1: ",
35      "l1",
36      "1: ",
37      "l2",
38    ]
39
40    assert_equal expected, out
41  end
42
43  def test_convert_custom_markup
44    str = <<-STR
45{stricken}
46    STR
47
48    m = RDoc::Markup.new
49    m.add_word_pair '{', '}', :STRIKE
50
51    tt = RDoc::Markup::ToTest.new nil, m
52    tt.add_tag :STRIKE, 'STRIKE ', ' STRIKE'
53
54    out = m.convert str, tt
55
56    expected = [
57      "STRIKE stricken STRIKE",
58    ]
59
60    assert_equal expected, out
61  end
62
63  def test_convert_document
64    doc = RDoc::Markup::Parser.parse <<-STR
65now is
66the time
67
68  hello
69  dave
70
711. l1
722. l2
73    STR
74
75    m = RDoc::Markup.new
76
77    tt = RDoc::Markup::ToTest.new m
78
79    out = m.convert doc, tt
80
81    expected = [
82      "now is the time",
83      "\n",
84      "  hello\n  dave\n",
85      "1: ",
86      "l1",
87      "1: ",
88      "l2",
89    ]
90
91    assert_equal expected, out
92  end
93
94end
95
96