summaryrefslogtreecommitdiff
path: root/jni/ruby/test/rdoc/test_rdoc_markup_to_table_of_contents.rb
blob: ba17b845a70c8291dd383f2b28f4f1ba21f1d09c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
require 'rdoc/test_case'

class TestRDocMarkupToTableOfContents < RDoc::Markup::FormatterTestCase

  add_visitor_tests

  def setup
    super

    @to = RDoc::Markup::ToTableOfContents.new
  end

  def end_accepting
    assert_equal %w[hi], @to.res
  end

  def empty
    assert_empty @to.res
  end

  def accept_heading
    assert_equal [@RM::Heading.new(5, 'Hello')], @to.res
  end

  def accept_heading_1
    assert_equal [@RM::Heading.new(1, 'Hello')], @to.res
  end

  def accept_heading_2
    assert_equal [@RM::Heading.new(2, 'Hello')], @to.res
  end

  def accept_heading_3
    assert_equal [@RM::Heading.new(3, 'Hello')], @to.res
  end

  def accept_heading_4
    assert_equal [@RM::Heading.new(4, 'Hello')], @to.res
  end

  def accept_heading_b
    assert_equal [@RM::Heading.new(1, '*Hello*')], @to.res
  end

  def accept_heading_suppressed_crossref
    assert_equal [@RM::Heading.new(1, '\\Hello')], @to.res
  end

  alias accept_blank_line                             empty
  alias accept_block_quote                            empty
  alias accept_document                               empty
  alias accept_list_end_bullet                        empty
  alias accept_list_end_label                         empty
  alias accept_list_end_lalpha                        empty
  alias accept_list_end_note                          empty
  alias accept_list_end_number                        empty
  alias accept_list_end_ualpha                        empty
  alias accept_list_item_end_bullet                   empty
  alias accept_list_item_end_label                    empty
  alias accept_list_item_end_lalpha                   empty
  alias accept_list_item_end_note                     empty
  alias accept_list_item_end_number                   empty
  alias accept_list_item_end_ualpha                   empty
  alias accept_list_item_start_bullet                 empty
  alias accept_list_item_start_label                  empty
  alias accept_list_item_start_lalpha                 empty
  alias accept_list_item_start_note                   empty
  alias accept_list_item_start_note_2                 empty
  alias accept_list_item_start_note_multi_description empty
  alias accept_list_item_start_note_multi_label       empty
  alias accept_list_item_start_number                 empty
  alias accept_list_item_start_ualpha                 empty
  alias accept_list_start_bullet                      empty
  alias accept_list_start_label                       empty
  alias accept_list_start_lalpha                      empty
  alias accept_list_start_note                        empty
  alias accept_list_start_number                      empty
  alias accept_list_start_ualpha                      empty
  alias accept_paragraph                              empty
  alias accept_paragraph_b                            empty
  alias accept_paragraph_br                           empty
  alias accept_paragraph_break                        empty
  alias accept_paragraph_i                            empty
  alias accept_paragraph_plus                         empty
  alias accept_paragraph_star                         empty
  alias accept_paragraph_underscore                   empty
  alias accept_raw                                    empty
  alias accept_rule                                   empty
  alias accept_verbatim                               empty
  alias list_nested                                   empty
  alias list_verbatim                                 empty
  alias start_accepting                               empty

  def test_accept_document_omit_headings_below
    document = doc
    document.omit_headings_below = 2

    @to.accept_document document

    assert_equal 2, @to.omit_headings_below
  end

  def test_accept_heading_suppressed
    @to.start_accepting
    @to.omit_headings_below = 4

    suppressed = head 5, 'Hello'

    @to.accept_heading suppressed

    assert_empty @to.res
  end

  def test_suppressed_eh
    @to.omit_headings_below = nil

    refute @to.suppressed? head(1, '')

    @to.omit_headings_below = 1

    refute @to.suppressed? head(1, '')
    assert @to.suppressed? head(2, '')
  end

end