rdoc 4.3.0 → 5.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (248) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +13 -0
  3. data/.travis.yml +23 -0
  4. data/CONTRIBUTING.rdoc +4 -3
  5. data/Gemfile +3 -0
  6. data/History.rdoc +15 -4
  7. data/LEGAL.rdoc +2 -2
  8. data/README.rdoc +1 -0
  9. data/Rakefile +41 -79
  10. data/bin/console +7 -0
  11. data/bin/setup +6 -0
  12. data/{bin → exe}/rdoc +0 -0
  13. data/{bin → exe}/ri +0 -0
  14. data/lib/rdoc.rb +2 -1
  15. data/lib/rdoc/alias.rb +1 -0
  16. data/lib/rdoc/anon_class.rb +1 -0
  17. data/lib/rdoc/any_method.rb +1 -0
  18. data/lib/rdoc/attr.rb +1 -0
  19. data/lib/rdoc/class_module.rb +1 -0
  20. data/lib/rdoc/code_object.rb +1 -0
  21. data/lib/rdoc/code_objects.rb +1 -0
  22. data/lib/rdoc/comment.rb +1 -0
  23. data/lib/rdoc/constant.rb +1 -0
  24. data/lib/rdoc/context.rb +4 -1
  25. data/lib/rdoc/context/section.rb +7 -0
  26. data/lib/rdoc/cross_reference.rb +1 -0
  27. data/lib/rdoc/encoding.rb +14 -0
  28. data/lib/rdoc/erb_partial.rb +1 -0
  29. data/lib/rdoc/erbio.rb +1 -0
  30. data/lib/rdoc/extend.rb +1 -0
  31. data/lib/rdoc/generator.rb +1 -0
  32. data/lib/rdoc/generator/darkfish.rb +1 -0
  33. data/lib/rdoc/generator/json_index.rb +1 -0
  34. data/lib/rdoc/generator/markup.rb +1 -0
  35. data/lib/rdoc/generator/pot.rb +1 -0
  36. data/lib/rdoc/generator/pot/message_extractor.rb +1 -0
  37. data/lib/rdoc/generator/pot/po.rb +1 -0
  38. data/lib/rdoc/generator/pot/po_entry.rb +1 -0
  39. data/lib/rdoc/generator/ri.rb +1 -0
  40. data/lib/rdoc/generator/template/darkfish/_head.rhtml +2 -1
  41. data/lib/rdoc/generator/template/darkfish/css/fonts.css +6 -6
  42. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -7
  43. data/lib/rdoc/generator/template/json_index/js/searcher.js +1 -0
  44. data/lib/rdoc/ghost_method.rb +1 -0
  45. data/lib/rdoc/i18n.rb +1 -0
  46. data/lib/rdoc/i18n/locale.rb +1 -0
  47. data/lib/rdoc/i18n/text.rb +1 -0
  48. data/lib/rdoc/include.rb +1 -0
  49. data/lib/rdoc/known_classes.rb +1 -0
  50. data/lib/rdoc/markdown.kpeg +2 -6
  51. data/lib/rdoc/markdown.rb +2 -6
  52. data/lib/rdoc/markdown/entities.rb +1 -0
  53. data/lib/rdoc/markdown/{literals_1_9.kpeg → literals.kpeg} +0 -0
  54. data/lib/rdoc/markdown/{literals_1_9.rb → literals.rb} +1 -4
  55. data/lib/rdoc/markup.rb +1 -0
  56. data/lib/rdoc/markup/attr_changer.rb +1 -0
  57. data/lib/rdoc/markup/attr_span.rb +1 -0
  58. data/lib/rdoc/markup/attribute_manager.rb +1 -0
  59. data/lib/rdoc/markup/attributes.rb +1 -0
  60. data/lib/rdoc/markup/blank_line.rb +1 -0
  61. data/lib/rdoc/markup/block_quote.rb +1 -0
  62. data/lib/rdoc/markup/document.rb +1 -0
  63. data/lib/rdoc/markup/formatter.rb +1 -0
  64. data/lib/rdoc/markup/formatter_test_case.rb +1 -4
  65. data/lib/rdoc/markup/hard_break.rb +1 -0
  66. data/lib/rdoc/markup/heading.rb +1 -0
  67. data/lib/rdoc/markup/include.rb +1 -0
  68. data/lib/rdoc/markup/indented_paragraph.rb +1 -0
  69. data/lib/rdoc/markup/inline.rb +1 -0
  70. data/lib/rdoc/markup/list.rb +1 -0
  71. data/lib/rdoc/markup/list_item.rb +1 -0
  72. data/lib/rdoc/markup/paragraph.rb +1 -0
  73. data/lib/rdoc/markup/parser.rb +1 -0
  74. data/lib/rdoc/markup/pre_process.rb +1 -0
  75. data/lib/rdoc/markup/raw.rb +1 -0
  76. data/lib/rdoc/markup/rule.rb +1 -0
  77. data/lib/rdoc/markup/special.rb +1 -0
  78. data/lib/rdoc/markup/text_formatter_test_case.rb +1 -0
  79. data/lib/rdoc/markup/to_ansi.rb +1 -0
  80. data/lib/rdoc/markup/to_bs.rb +1 -0
  81. data/lib/rdoc/markup/to_html.rb +1 -0
  82. data/lib/rdoc/markup/to_html_crossref.rb +1 -0
  83. data/lib/rdoc/markup/to_html_snippet.rb +1 -0
  84. data/lib/rdoc/markup/to_joined_paragraph.rb +1 -0
  85. data/lib/rdoc/markup/to_label.rb +1 -0
  86. data/lib/rdoc/markup/to_markdown.rb +1 -0
  87. data/lib/rdoc/markup/to_rdoc.rb +1 -0
  88. data/lib/rdoc/markup/to_table_of_contents.rb +1 -0
  89. data/lib/rdoc/markup/to_test.rb +1 -0
  90. data/lib/rdoc/markup/to_tt_only.rb +1 -0
  91. data/lib/rdoc/markup/verbatim.rb +1 -0
  92. data/lib/rdoc/meta_method.rb +1 -0
  93. data/lib/rdoc/method_attr.rb +1 -0
  94. data/lib/rdoc/mixin.rb +1 -0
  95. data/lib/rdoc/normal_class.rb +1 -0
  96. data/lib/rdoc/normal_module.rb +1 -0
  97. data/lib/rdoc/options.rb +1 -0
  98. data/lib/rdoc/parser.rb +1 -0
  99. data/lib/rdoc/parser/c.rb +76 -33
  100. data/lib/rdoc/parser/changelog.rb +7 -1
  101. data/lib/rdoc/parser/markdown.rb +1 -0
  102. data/lib/rdoc/parser/rd.rb +1 -0
  103. data/lib/rdoc/parser/ruby.rb +1 -0
  104. data/lib/rdoc/parser/ruby_tools.rb +1 -0
  105. data/lib/rdoc/parser/simple.rb +1 -0
  106. data/lib/rdoc/parser/text.rb +1 -0
  107. data/lib/rdoc/rd.rb +1 -0
  108. data/lib/rdoc/rd/inline.rb +1 -0
  109. data/lib/rdoc/rdoc.rb +2 -1
  110. data/lib/rdoc/require.rb +1 -0
  111. data/lib/rdoc/ri.rb +1 -0
  112. data/lib/rdoc/ri/driver.rb +5 -19
  113. data/lib/rdoc/ri/formatter.rb +1 -0
  114. data/lib/rdoc/ri/paths.rb +1 -0
  115. data/lib/rdoc/ri/store.rb +1 -0
  116. data/lib/rdoc/ri/task.rb +72 -0
  117. data/lib/rdoc/ruby_lex.rb +11 -17
  118. data/lib/rdoc/ruby_token.rb +1 -0
  119. data/lib/rdoc/rubygems_hook.rb +1 -0
  120. data/lib/rdoc/servlet.rb +4 -3
  121. data/lib/rdoc/single_class.rb +1 -0
  122. data/lib/rdoc/stats.rb +1 -0
  123. data/lib/rdoc/stats/normal.rb +1 -0
  124. data/lib/rdoc/stats/quiet.rb +1 -0
  125. data/lib/rdoc/stats/verbose.rb +1 -0
  126. data/lib/rdoc/store.rb +3 -9
  127. data/lib/rdoc/task.rb +1 -0
  128. data/lib/rdoc/test_case.rb +1 -10
  129. data/lib/rdoc/text.rb +1 -0
  130. data/lib/rdoc/token_stream.rb +1 -0
  131. data/lib/rdoc/tom_doc.rb +1 -0
  132. data/lib/rdoc/top_level.rb +1 -0
  133. data/rdoc.gemspec +60 -0
  134. metadata +32 -155
  135. data/Manifest.txt +0 -309
  136. data/lib/rdoc/markdown/literals_1_8.kpeg +0 -18
  137. data/lib/rdoc/markdown/literals_1_8.rb +0 -416
  138. data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +0 -21
  139. data/test/MarkdownTest_1.0.3/Auto links.text +0 -13
  140. data/test/MarkdownTest_1.0.3/Backslash escapes.text +0 -120
  141. data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +0 -11
  142. data/test/MarkdownTest_1.0.3/Code Blocks.text +0 -14
  143. data/test/MarkdownTest_1.0.3/Code Spans.text +0 -6
  144. data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +0 -8
  145. data/test/MarkdownTest_1.0.3/Horizontal rules.text +0 -67
  146. data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +0 -15
  147. data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +0 -69
  148. data/test/MarkdownTest_1.0.3/Inline HTML comments.text +0 -13
  149. data/test/MarkdownTest_1.0.3/Links, inline style.text +0 -12
  150. data/test/MarkdownTest_1.0.3/Links, reference style.text +0 -71
  151. data/test/MarkdownTest_1.0.3/Links, shortcut references.text +0 -20
  152. data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +0 -7
  153. data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +0 -306
  154. data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +0 -888
  155. data/test/MarkdownTest_1.0.3/Nested blockquotes.text +0 -5
  156. data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +0 -131
  157. data/test/MarkdownTest_1.0.3/Strong and em together.text +0 -7
  158. data/test/MarkdownTest_1.0.3/Tabs.text +0 -21
  159. data/test/MarkdownTest_1.0.3/Tidyness.text +0 -5
  160. data/test/README +0 -1
  161. data/test/binary.dat +0 -0
  162. data/test/hidden.zip.txt +0 -1
  163. data/test/test.ja.largedoc +0 -3
  164. data/test/test.ja.rdoc +0 -10
  165. data/test/test.ja.txt +0 -8
  166. data/test/test.txt +0 -1
  167. data/test/test_rdoc_alias.rb +0 -13
  168. data/test/test_rdoc_any_method.rb +0 -460
  169. data/test/test_rdoc_attr.rb +0 -190
  170. data/test/test_rdoc_class_module.rb +0 -1492
  171. data/test/test_rdoc_code_object.rb +0 -450
  172. data/test/test_rdoc_comment.rb +0 -504
  173. data/test/test_rdoc_constant.rb +0 -181
  174. data/test/test_rdoc_context.rb +0 -901
  175. data/test/test_rdoc_context_section.rb +0 -130
  176. data/test/test_rdoc_cross_reference.rb +0 -192
  177. data/test/test_rdoc_encoding.rb +0 -227
  178. data/test/test_rdoc_extend.rb +0 -94
  179. data/test/test_rdoc_generator_darkfish.rb +0 -229
  180. data/test/test_rdoc_generator_json_index.rb +0 -324
  181. data/test/test_rdoc_generator_markup.rb +0 -59
  182. data/test/test_rdoc_generator_pot.rb +0 -91
  183. data/test/test_rdoc_generator_pot_po.rb +0 -51
  184. data/test/test_rdoc_generator_pot_po_entry.rb +0 -139
  185. data/test/test_rdoc_generator_ri.rb +0 -78
  186. data/test/test_rdoc_i18n_locale.rb +0 -73
  187. data/test/test_rdoc_i18n_text.rb +0 -123
  188. data/test/test_rdoc_include.rb +0 -108
  189. data/test/test_rdoc_markdown.rb +0 -980
  190. data/test/test_rdoc_markdown_test.rb +0 -1884
  191. data/test/test_rdoc_markup.rb +0 -95
  192. data/test/test_rdoc_markup_attribute_manager.rb +0 -364
  193. data/test/test_rdoc_markup_attributes.rb +0 -39
  194. data/test/test_rdoc_markup_document.rb +0 -207
  195. data/test/test_rdoc_markup_formatter.rb +0 -175
  196. data/test/test_rdoc_markup_hard_break.rb +0 -31
  197. data/test/test_rdoc_markup_heading.rb +0 -29
  198. data/test/test_rdoc_markup_include.rb +0 -19
  199. data/test/test_rdoc_markup_indented_paragraph.rb +0 -53
  200. data/test/test_rdoc_markup_paragraph.rb +0 -32
  201. data/test/test_rdoc_markup_parser.rb +0 -1680
  202. data/test/test_rdoc_markup_pre_process.rb +0 -473
  203. data/test/test_rdoc_markup_raw.rb +0 -22
  204. data/test/test_rdoc_markup_to_ansi.rb +0 -369
  205. data/test/test_rdoc_markup_to_bs.rb +0 -366
  206. data/test/test_rdoc_markup_to_html.rb +0 -662
  207. data/test/test_rdoc_markup_to_html_crossref.rb +0 -225
  208. data/test/test_rdoc_markup_to_html_snippet.rb +0 -711
  209. data/test/test_rdoc_markup_to_joined_paragraph.rb +0 -32
  210. data/test/test_rdoc_markup_to_label.rb +0 -112
  211. data/test/test_rdoc_markup_to_markdown.rb +0 -389
  212. data/test/test_rdoc_markup_to_rdoc.rb +0 -377
  213. data/test/test_rdoc_markup_to_table_of_contents.rb +0 -126
  214. data/test/test_rdoc_markup_to_tt_only.rb +0 -246
  215. data/test/test_rdoc_markup_verbatim.rb +0 -29
  216. data/test/test_rdoc_method_attr.rb +0 -193
  217. data/test/test_rdoc_normal_class.rb +0 -47
  218. data/test/test_rdoc_normal_module.rb +0 -42
  219. data/test/test_rdoc_options.rb +0 -766
  220. data/test/test_rdoc_parser.rb +0 -327
  221. data/test/test_rdoc_parser_c.rb +0 -1896
  222. data/test/test_rdoc_parser_changelog.rb +0 -315
  223. data/test/test_rdoc_parser_markdown.rb +0 -61
  224. data/test/test_rdoc_parser_rd.rb +0 -55
  225. data/test/test_rdoc_parser_ruby.rb +0 -3322
  226. data/test/test_rdoc_parser_simple.rb +0 -115
  227. data/test/test_rdoc_rd.rb +0 -30
  228. data/test/test_rdoc_rd_block_parser.rb +0 -535
  229. data/test/test_rdoc_rd_inline.rb +0 -63
  230. data/test/test_rdoc_rd_inline_parser.rb +0 -177
  231. data/test/test_rdoc_rdoc.rb +0 -455
  232. data/test/test_rdoc_require.rb +0 -25
  233. data/test/test_rdoc_ri_driver.rb +0 -1436
  234. data/test/test_rdoc_ri_paths.rb +0 -155
  235. data/test/test_rdoc_ruby_lex.rb +0 -421
  236. data/test/test_rdoc_ruby_token.rb +0 -19
  237. data/test/test_rdoc_rubygems_hook.rb +0 -251
  238. data/test/test_rdoc_servlet.rb +0 -534
  239. data/test/test_rdoc_single_class.rb +0 -20
  240. data/test/test_rdoc_stats.rb +0 -722
  241. data/test/test_rdoc_store.rb +0 -993
  242. data/test/test_rdoc_task.rb +0 -173
  243. data/test/test_rdoc_text.rb +0 -557
  244. data/test/test_rdoc_token_stream.rb +0 -42
  245. data/test/test_rdoc_tom_doc.rb +0 -520
  246. data/test/test_rdoc_top_level.rb +0 -287
  247. data/test/xref_data.rb +0 -76
  248. data/test/xref_test_case.rb +0 -67
@@ -1,190 +0,0 @@
1
- require 'rdoc/test_case'
2
-
3
- class TestRDocAttr < RDoc::TestCase
4
-
5
- def setup
6
- super
7
-
8
- @a = RDoc::Attr.new nil, 'attr', 'RW', ''
9
- end
10
-
11
- def test_aref
12
- m = RDoc::Attr.new nil, 'attr', 'RW', nil
13
-
14
- assert_equal 'attribute-i-attr', m.aref
15
- end
16
-
17
- def test_arglists
18
- assert_nil @a.arglists
19
- end
20
-
21
- def test_block_params
22
- assert_nil @a.block_params
23
- end
24
-
25
- def test_call_seq
26
- assert_nil @a.call_seq
27
- end
28
-
29
- def test_definition
30
- assert_equal 'attr_accessor', @a.definition
31
-
32
- @a.rw = 'R'
33
-
34
- assert_equal 'attr_reader', @a.definition
35
-
36
- @a.rw = 'W'
37
-
38
- assert_equal 'attr_writer', @a.definition
39
- end
40
-
41
- def test_full_name
42
- assert_equal '(unknown)#attr', @a.full_name
43
- end
44
-
45
- def test_marshal_dump
46
- tl = @store.add_file 'file.rb'
47
-
48
- @a.comment = 'this is a comment'
49
- @a.record_location tl
50
-
51
- cm = tl.add_class RDoc::NormalClass, 'Klass'
52
- cm.add_attribute @a
53
-
54
- section = cm.sections.first
55
-
56
- loaded = Marshal.load Marshal.dump @a
57
- loaded.store = @store
58
-
59
- assert_equal @a, loaded
60
-
61
- comment = RDoc::Markup::Document.new(
62
- RDoc::Markup::Paragraph.new('this is a comment'))
63
-
64
- assert_equal comment, loaded.comment
65
- assert_equal 'file.rb', loaded.file.relative_name
66
- assert_equal 'Klass#attr', loaded.full_name
67
- assert_equal 'attr', loaded.name
68
- assert_equal 'RW', loaded.rw
69
- assert_equal false, loaded.singleton
70
- assert_equal :public, loaded.visibility
71
- assert_equal tl, loaded.file
72
- assert_equal cm, loaded.parent
73
- assert_equal section, loaded.section
74
- end
75
-
76
- def test_marshal_dump_singleton
77
- tl = @store.add_file 'file.rb'
78
-
79
- @a.comment = 'this is a comment'
80
- @a.record_location tl
81
-
82
- cm = tl.add_class RDoc::NormalClass, 'Klass'
83
- cm.add_attribute @a
84
-
85
- section = cm.sections.first
86
-
87
- @a.rw = 'R'
88
- @a.singleton = true
89
- @a.visibility = :protected
90
-
91
- loaded = Marshal.load Marshal.dump @a
92
- loaded.store = @store
93
-
94
- assert_equal @a, loaded
95
-
96
- comment = RDoc::Markup::Document.new(
97
- RDoc::Markup::Paragraph.new('this is a comment'))
98
-
99
- assert_equal comment, loaded.comment
100
- assert_equal 'Klass::attr', loaded.full_name
101
- assert_equal 'attr', loaded.name
102
- assert_equal 'R', loaded.rw
103
- assert_equal true, loaded.singleton
104
- assert_equal :protected, loaded.visibility
105
- assert_equal tl, loaded.file
106
- assert_equal cm, loaded.parent
107
- assert_equal section, loaded.section
108
- end
109
-
110
- def test_marshal_load_version_1
111
- tl = @store.add_file 'file.rb'
112
- cm = tl.add_class RDoc::NormalClass, 'Klass'
113
- section = cm.sections.first
114
-
115
- data = "\x04\bU:\x0FRDoc::Attr[\fi\x06I\"\tattr\x06:\x06EF" +
116
- "\"\x0FKlass#attrI\"\aRW\x06;\x06F:\vpublic" +
117
- "o:\eRDoc::Markup::Document\x06:\v@parts[\x06" +
118
- "o:\x1CRDoc::Markup::Paragraph\x06;\t[\x06I" +
119
- "\"\x16this is a comment\x06;\x06FF"
120
-
121
- loaded = Marshal.load data
122
- loaded.store = @store
123
-
124
- comment = RDoc::Markup::Document.new(
125
- RDoc::Markup::Paragraph.new('this is a comment'))
126
-
127
- assert_equal comment, loaded.comment
128
- assert_equal 'Klass#attr', loaded.full_name
129
- assert_equal 'attr', loaded.name
130
- assert_equal 'RW', loaded.rw
131
- assert_equal false, loaded.singleton
132
- assert_equal :public, loaded.visibility
133
-
134
- # version 2
135
- assert_nil loaded.file
136
-
137
- # version 3
138
- assert_equal cm, loaded.parent
139
- assert_equal section, loaded.section
140
-
141
- assert loaded.display?
142
- end
143
-
144
- def test_marshal_load_version_2
145
- tl = @store.add_file 'file.rb'
146
- cm = tl.add_class RDoc::NormalClass, 'Klass'
147
- section = cm.sections.first
148
-
149
- loaded = Marshal.load "\x04\bU:\x0FRDoc::Attr[\ri\aI\"\tattr\x06" +
150
- ":\x06ETI\"\x0FKlass#attr\x06;\x06TI\"\aRW\x06" +
151
- ";\x06T:\vpublico:\eRDoc::Markup::Document\a" +
152
- ":\v@parts[\x06o:\x1CRDoc::Markup::Paragraph\x06;" +
153
- "\t[\x06I\"\x16this is a comment\x06;\x06T:\n" +
154
- "@file0FI\"\ffile.rb\x06;\x06T"
155
- loaded.store = @store
156
-
157
- comment = doc(para('this is a comment'))
158
-
159
- assert_equal comment, loaded.comment
160
- assert_equal 'Klass#attr', loaded.full_name
161
- assert_equal 'attr', loaded.name
162
- assert_equal 'RW', loaded.rw
163
- assert_equal false, loaded.singleton
164
- assert_equal :public, loaded.visibility
165
- assert_equal tl, loaded.file
166
-
167
- # version 3
168
- assert_equal cm, loaded.parent
169
- assert_equal section, loaded.section
170
-
171
- assert loaded.display?
172
- end
173
-
174
- def test_params
175
- assert_nil @a.params
176
- end
177
-
178
- def test_singleton
179
- refute @a.singleton
180
- end
181
-
182
- def test_type
183
- assert_equal 'instance', @a.type
184
-
185
- @a.singleton = true
186
- assert_equal 'class', @a.type
187
- end
188
-
189
- end
190
-
@@ -1,1492 +0,0 @@
1
- require File.expand_path '../xref_test_case', __FILE__
2
-
3
- class TestRDocClassModule < XrefTestCase
4
-
5
- def test_add_comment
6
- tl1 = @store.add_file 'one.rb'
7
- tl2 = @store.add_file 'two.rb'
8
- tl3 = @store.add_file 'three.rb'
9
-
10
- cm = RDoc::ClassModule.new 'Klass'
11
- cm.add_comment '# comment 1', tl1
12
-
13
- assert_equal [['comment 1', tl1]], cm.comment_location
14
- assert_equal 'comment 1', cm.comment
15
-
16
- cm.add_comment '# comment 2', tl2
17
-
18
- assert_equal [['comment 1', tl1], ['comment 2', tl2]], cm.comment_location
19
- assert_equal "comment 1\n---\ncomment 2", cm.comment
20
-
21
- cm.add_comment "# * comment 3", tl3
22
-
23
- assert_equal [['comment 1', tl1],
24
- ['comment 2', tl2],
25
- ['* comment 3', tl3]], cm.comment_location
26
- assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment
27
- end
28
-
29
- def test_add_comment_comment
30
- cm = RDoc::ClassModule.new 'Klass'
31
-
32
- cm.add_comment comment('comment'), @top_level
33
-
34
- assert_equal 'comment', cm.comment.text
35
- end
36
-
37
- def test_add_comment_duplicate
38
- tl1 = @store.add_file 'one.rb'
39
-
40
- cm = RDoc::ClassModule.new 'Klass'
41
- cm.add_comment '# comment 1', tl1
42
- cm.add_comment '# comment 2', tl1
43
-
44
- assert_equal [['comment 2', tl1]], cm.comment_location
45
- end
46
-
47
- def test_add_comment_stopdoc
48
- tl = @store.add_file 'file.rb'
49
-
50
- cm = RDoc::ClassModule.new 'Klass'
51
- cm.stop_doc
52
-
53
- cm.add_comment '# comment 1', tl
54
-
55
- assert_empty cm.comment
56
- end
57
-
58
- def test_ancestors
59
- assert_equal [@parent, "Object"], @child.ancestors
60
- end
61
-
62
- def test_comment_equals
63
- cm = RDoc::ClassModule.new 'Klass'
64
- cm.comment = '# comment 1'
65
-
66
- assert_equal 'comment 1', cm.comment
67
-
68
- cm.comment = '# comment 2'
69
-
70
- assert_equal "comment 1\n---\ncomment 2", cm.comment
71
-
72
- cm.comment = "# * comment 3"
73
-
74
- assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment
75
- end
76
-
77
- def test_comment_equals_comment
78
- cm = RDoc::ClassModule.new 'Klass'
79
-
80
- cm.comment = comment 'comment'
81
-
82
- assert_equal 'comment', cm.comment.text
83
- end
84
-
85
- def test_docuent_self_or_methods
86
- assert @c1.document_self_or_methods
87
-
88
- @c1.document_self = false
89
-
90
- assert @c1.document_self_or_methods
91
-
92
- @c1_m.document_self = false
93
-
94
- assert @c1.document_self_or_methods
95
-
96
- @c1__m.document_self = false
97
-
98
- refute @c1.document_self_or_methods
99
- end
100
-
101
- def test_documented_eh
102
- cm = RDoc::ClassModule.new 'C'
103
-
104
- refute cm.documented?, 'no comments, no markers'
105
-
106
- cm.add_comment '', @top_level
107
-
108
- refute cm.documented?, 'empty comment'
109
-
110
- cm.add_comment 'hi', @top_level
111
-
112
- assert cm.documented?, 'commented'
113
-
114
- cm.comment_location.clear
115
-
116
- refute cm.documented?, 'no comment'
117
-
118
- cm.document_self = nil # notify :nodoc:
119
-
120
- assert cm.documented?, ':nodoc:'
121
- end
122
-
123
- def test_each_ancestor
124
- assert_equal [@parent], @child.each_ancestor.to_a
125
- end
126
-
127
- def test_each_ancestor_cycle
128
- m_incl = RDoc::Include.new 'M', nil
129
-
130
- m = @top_level.add_module RDoc::NormalModule, 'M'
131
- m.add_include m_incl
132
-
133
- assert_empty m.each_ancestor.to_a
134
- end
135
-
136
- # handle making a short module alias of yourself
137
-
138
- def test_find_class_named
139
- @c2.classes_hash['C2'] = @c2
140
-
141
- assert_nil @c2.find_class_named('C1')
142
- end
143
-
144
- def test_from_module_comment
145
- tl = @store.add_file 'file.rb'
146
- klass = tl.add_class RDoc::NormalModule, 'Klass'
147
- klass.add_comment 'really a class', tl
148
-
149
- klass = RDoc::ClassModule.from_module RDoc::NormalClass, klass
150
-
151
- assert_equal [['really a class', tl]], klass.comment_location
152
- end
153
-
154
- def test_marshal_dump
155
- @store.path = Dir.tmpdir
156
- tl = @store.add_file 'file.rb'
157
-
158
- ns = tl.add_module RDoc::NormalModule, 'Namespace'
159
-
160
- cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
161
- cm.document_self = true
162
- cm.record_location tl
163
-
164
- a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
165
- a1.record_location tl
166
- a2 = RDoc::Attr.new nil, 'a2', 'RW', '', true
167
- a2.record_location tl
168
-
169
- m1 = RDoc::AnyMethod.new nil, 'm1'
170
- m1.record_location tl
171
-
172
- c1 = RDoc::Constant.new 'C1', nil, ''
173
- c1.record_location tl
174
-
175
- i1 = RDoc::Include.new 'I1', ''
176
- i1.record_location tl
177
-
178
- e1 = RDoc::Extend.new 'E1', ''
179
- e1.record_location tl
180
-
181
- section_comment = RDoc::Comment.new('section comment')
182
- section_comment.location = tl
183
-
184
- assert_equal 1, cm.sections.length, 'sanity, default section only'
185
- s0 = cm.sections.first
186
- s1 = cm.add_section 'section', section_comment
187
-
188
- cm.add_attribute a1
189
- cm.add_attribute a2
190
- cm.add_method m1
191
- cm.add_constant c1
192
- cm.add_include i1
193
- cm.add_extend e1
194
- cm.add_comment 'this is a comment', tl
195
-
196
- loaded = Marshal.load Marshal.dump cm
197
- loaded.store = @store
198
-
199
- assert_equal cm, loaded
200
-
201
- inner = RDoc::Markup::Document.new(
202
- RDoc::Markup::Paragraph.new('this is a comment'))
203
- inner.file = tl
204
-
205
- comment = RDoc::Markup::Document.new inner
206
-
207
- assert_equal [a2, a1], loaded.attributes.sort
208
- assert_equal comment, loaded.comment
209
- assert_equal [c1], loaded.constants
210
- assert_equal 'Namespace::Klass', loaded.full_name
211
- assert_equal [i1], loaded.includes
212
- assert_equal [e1], loaded.extends
213
- assert_equal [m1], loaded.method_list
214
- assert_equal 'Klass', loaded.name
215
- assert_equal 'Super', loaded.superclass
216
- assert_equal [tl], loaded.in_files
217
- assert_equal 'Namespace', loaded.parent.name
218
-
219
- expected = { nil => s0, 'section' => s1 }
220
- assert_equal expected, loaded.sections_hash
221
-
222
- assert_equal tl, loaded.attributes.first.file
223
-
224
- assert_equal tl, loaded.constants.first.file
225
-
226
- assert_equal tl, loaded.includes.first.file
227
-
228
- assert_equal tl, loaded.extends.first.file
229
-
230
- assert_equal tl, loaded.method_list.first.file
231
- end
232
-
233
- def test_marshal_dump_visibilty
234
- @store.path = Dir.tmpdir
235
- tl = @store.add_file 'file.rb'
236
-
237
- ns = tl.add_module RDoc::NormalModule, 'Namespace'
238
-
239
- cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
240
- cm.record_location tl
241
-
242
- a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
243
- a1.record_location tl
244
- a1.document_self = false
245
-
246
- m1 = RDoc::AnyMethod.new nil, 'm1'
247
- m1.record_location tl
248
- m1.document_self = false
249
-
250
- c1 = RDoc::Constant.new 'C1', nil, ''
251
- c1.record_location tl
252
- c1.document_self = false
253
-
254
- i1 = RDoc::Include.new 'I1', ''
255
- i1.record_location tl
256
- i1.document_self = false
257
-
258
- e1 = RDoc::Extend.new 'E1', ''
259
- e1.record_location tl
260
- e1.document_self = false
261
-
262
- section_comment = RDoc::Comment.new('section comment')
263
- section_comment.location = tl
264
-
265
- assert_equal 1, cm.sections.length, 'sanity, default section only'
266
-
267
- cm.add_attribute a1
268
- cm.add_method m1
269
- cm.add_constant c1
270
- cm.add_include i1
271
- cm.add_extend e1
272
- cm.add_comment 'this is a comment', tl
273
-
274
- loaded = Marshal.load Marshal.dump cm
275
- loaded.store = @store
276
-
277
- assert_equal cm, loaded
278
-
279
- assert_empty loaded.attributes
280
- assert_empty loaded.constants
281
- assert_empty loaded.includes
282
- assert_empty loaded.extends
283
- assert_empty loaded.method_list
284
- end
285
-
286
- def test_marshal_load_version_0
287
- tl = @store.add_file 'file.rb'
288
- ns = tl.add_module RDoc::NormalModule, 'Namespace'
289
- cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
290
-
291
- a = RDoc::Attr.new(nil, 'a1', 'RW', '')
292
- m = RDoc::AnyMethod.new(nil, 'm1')
293
- c = RDoc::Constant.new('C1', nil, '')
294
- i = RDoc::Include.new('I1', '')
295
-
296
- s0 = cm.sections.first
297
-
298
- cm.add_attribute a
299
- cm.add_method m
300
- cm.add_constant c
301
- cm.add_include i
302
- cm.add_comment 'this is a comment', tl
303
-
304
- loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x0Ei\x00\"\nKlass" +
305
- "\"\x15Namespace::KlassI\"\nSuper\x06:\x06EF" +
306
- "o:\eRDoc::Markup::Document\x06:\v@parts[\x06" +
307
- "o:\x1CRDoc::Markup::Paragraph\x06;\b[\x06I" +
308
- "\"\x16this is a comment\x06;\x06F[\x06[\aI" +
309
- "\"\aa1\x06;\x06FI\"\aRW\x06;\x06F[\x06[\aI" +
310
- "\"\aC1\x06;\x06Fo;\a\x06;\b[\x00[\x06[\aI" +
311
- "\"\aI1\x06;\x06Fo;\a\x06;\b[\x00[\a[\aI" +
312
- "\"\nclass\x06;\x06F[\b[\a:\vpublic[\x00[\a" +
313
- ":\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" +
314
- "\"\rinstance\x06;\x06F[\b[\a;\n[\x06I" +
315
- "\"\am1\x06;\x06F[\a;\v[\x00[\a;\f[\x00"
316
-
317
- loaded.store = @store
318
-
319
- assert_equal cm, loaded
320
-
321
- comment = RDoc::Markup::Document.new(
322
- RDoc::Markup::Paragraph.new('this is a comment'))
323
-
324
- assert_equal [a], loaded.attributes
325
- assert_equal comment, loaded.comment
326
- assert_equal [c], loaded.constants
327
- assert_equal 'Namespace::Klass', loaded.full_name
328
- assert_equal [i], loaded.includes
329
- assert_equal [m], loaded.method_list
330
- assert_equal 'Klass', loaded.name
331
- assert_equal 'Super', loaded.superclass
332
- assert_nil loaded.file
333
- assert_empty loaded.in_files
334
- assert_nil loaded.parent
335
- assert loaded.current_section
336
-
337
- expected = { nil => s0 }
338
- assert_equal expected, loaded.sections_hash
339
-
340
- assert loaded.display?
341
- end
342
-
343
- def test_marshal_load_version_1
344
- tl = @store.add_file 'file.rb'
345
-
346
- ns = tl.add_module RDoc::NormalModule, 'Namespace'
347
-
348
- cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
349
- cm.record_location tl
350
-
351
- a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
352
- a1.record_location tl
353
- a2 = RDoc::Attr.new nil, 'a2', 'RW', '', true
354
- a2.record_location tl
355
-
356
- m1 = RDoc::AnyMethod.new nil, 'm1'
357
- m1.record_location tl
358
-
359
- c1 = RDoc::Constant.new 'C1', nil, ''
360
- c1.record_location tl
361
-
362
- i1 = RDoc::Include.new 'I1', ''
363
- i1.record_location tl
364
-
365
- s0 = cm.sections.first
366
-
367
- cm.add_attribute a1
368
- cm.add_attribute a2
369
- cm.add_method m1
370
- cm.add_constant c1
371
- cm.add_include i1
372
- cm.add_comment 'this is a comment', tl
373
-
374
- loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x0Ei\x06I\"\nKlass" +
375
- "\x06:\x06EFI\"\x15Namespace::Klass\x06;\x06FI" +
376
- "\"\nSuper\x06;\x06Fo:\eRDoc::Markup::Document\a" +
377
- ":\v@parts[\x06o;\a\a;\b[\x06o" +
378
- ":\x1CRDoc::Markup::Paragraph\x06;\b" +
379
- "[\x06I\"\x16this is a comment\x06;\x06F" +
380
- ":\n@fileI\"\ffile.rb\x06;\x06F;\n0[\a[\nI" +
381
- "\"\aa2\x06;\x06FI\"\aRW\x06;\x06F:\vpublicT@\x11" +
382
- "[\nI\"\aa1\x06;\x06FI\"\aRW\x06;\x06F;\vF@\x11" +
383
- "[\x06[\bI\"\aC1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
384
- "[\x06[\bI\"\aI1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
385
- "[\a[\aI\"\nclass\x06;\x06F[\b[\a;\v[\x00" +
386
- "[\a:\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" +
387
- "\"\rinstance\x06;\x06F[\b[\a;\v[\x06[\aI" +
388
- "\"\am1\x06;\x06F@\x11[\a;\f[\x00[\a;\r[\x00"
389
-
390
- loaded.store = @store
391
-
392
- assert_equal cm, loaded
393
-
394
- inner = RDoc::Markup::Document.new(
395
- RDoc::Markup::Paragraph.new('this is a comment'))
396
- inner.file = tl
397
-
398
- comment = RDoc::Markup::Document.new inner
399
-
400
- assert_equal [a2, a1], loaded.attributes.sort
401
- assert_equal comment, loaded.comment
402
- assert_equal [c1], loaded.constants
403
- assert_equal 'Namespace::Klass', loaded.full_name
404
- assert_equal [i1], loaded.includes
405
- assert_empty loaded.extends
406
- assert_equal [m1], loaded.method_list
407
- assert_equal 'Klass', loaded.name
408
- assert_equal 'Super', loaded.superclass
409
- assert_empty loaded.in_files
410
- assert_nil loaded.parent
411
- assert loaded.current_section
412
-
413
- assert_equal tl, loaded.attributes.first.file
414
- assert_equal tl, loaded.constants.first.file
415
- assert_equal tl, loaded.includes.first.file
416
- assert_equal tl, loaded.method_list.first.file
417
-
418
- expected = { nil => s0 }
419
- assert_equal expected, loaded.sections_hash
420
- end
421
-
422
- def test_marshal_load_version_2
423
- tl = @store.add_file 'file.rb'
424
-
425
- ns = tl.add_module RDoc::NormalModule, 'Namespace'
426
-
427
- cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
428
- cm.record_location tl
429
-
430
- a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
431
- a1.record_location tl
432
- a2 = RDoc::Attr.new nil, 'a2', 'RW', '', true
433
- a2.record_location tl
434
-
435
- m1 = RDoc::AnyMethod.new nil, 'm1'
436
- m1.record_location tl
437
-
438
- c1 = RDoc::Constant.new 'C1', nil, ''
439
- c1.record_location tl
440
-
441
- i1 = RDoc::Include.new 'I1', ''
442
- i1.record_location tl
443
-
444
- e1 = RDoc::Extend.new 'E1', ''
445
- e1.record_location tl
446
-
447
- s0 = cm.sections.first
448
-
449
- cm.add_attribute a1
450
- cm.add_attribute a2
451
- cm.add_method m1
452
- cm.add_constant c1
453
- cm.add_include i1
454
- cm.add_extend e1
455
- cm.add_comment 'this is a comment', tl
456
-
457
- loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x0Fi\aI\"\nKlass" +
458
- "\x06:\x06EFI\"\x15Namespace::Klass\x06;\x06FI" +
459
- "\"\nSuper\x06;\x06Fo:\eRDoc::Markup::Document\a" +
460
- ":\v@parts[\x06o;\a\a;\b[\x06o" +
461
- ":\x1CRDoc::Markup::Paragraph\x06;\b" +
462
- "[\x06I\"\x16this is a comment\x06;\x06F" +
463
- ":\n@fileI\"\ffile.rb\x06;\x06F;\n0[\a[\nI" +
464
- "\"\aa2\x06;\x06FI\"\aRW\x06;\x06F:\vpublicT@\x11" +
465
- "[\nI\"\aa1\x06;\x06FI\"\aRW\x06;\x06F;\vF@\x11" +
466
- "[\x06[\bI\"\aC1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
467
- "[\x06[\bI\"\aI1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
468
- "[\a[\aI\"\nclass\x06;\x06F[\b[\a;\v[\x00" +
469
- "[\a:\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" +
470
- "\"\rinstance\x06;\x06F[\b[\a;\v[\x06[\aI" +
471
- "\"\am1\x06;\x06F@\x11[\a;\f[\x00[\a;\r[\x00" +
472
- "[\x06[\bI\"\aE1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11"
473
-
474
- loaded.store = @store
475
-
476
- assert_equal cm, loaded
477
-
478
- inner = RDoc::Markup::Document.new(
479
- RDoc::Markup::Paragraph.new('this is a comment'))
480
- inner.file = tl
481
-
482
- comment = RDoc::Markup::Document.new inner
483
-
484
- assert_equal [a2, a1], loaded.attributes.sort
485
- assert_equal comment, loaded.comment
486
- assert_equal [c1], loaded.constants
487
- assert_equal 'Namespace::Klass', loaded.full_name
488
- assert_equal [i1], loaded.includes
489
- assert_equal [e1], loaded.extends
490
- assert_equal [m1], loaded.method_list
491
- assert_equal 'Klass', loaded.name
492
- assert_equal 'Super', loaded.superclass
493
- assert_empty loaded.in_files
494
- assert_nil loaded.parent
495
- assert loaded.current_section
496
-
497
- assert_equal tl, loaded.attributes. first.file
498
- assert_equal tl, loaded.constants. first.file
499
- assert_equal tl, loaded.includes. first.file
500
- assert_equal tl, loaded.extends. first.file
501
- assert_equal tl, loaded.method_list.first.file
502
-
503
- expected = { nil => s0 }
504
- assert_equal expected, loaded.sections_hash
505
- end
506
-
507
- def test_marshal_load_version_3
508
- tl = @store.add_file 'file.rb'
509
-
510
- ns = tl.add_module RDoc::NormalModule, 'Namespace'
511
-
512
- cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
513
- cm.record_location tl
514
-
515
- a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
516
- a1.record_location tl
517
- a2 = RDoc::Attr.new nil, 'a2', 'RW', '', true
518
- a2.record_location tl
519
-
520
- m1 = RDoc::AnyMethod.new nil, 'm1'
521
- m1.record_location tl
522
-
523
- c1 = RDoc::Constant.new 'C1', nil, ''
524
- c1.record_location tl
525
-
526
- i1 = RDoc::Include.new 'I1', ''
527
- i1.record_location tl
528
-
529
- e1 = RDoc::Extend.new 'E1', ''
530
- e1.record_location tl
531
-
532
- section_comment = RDoc::Comment.new('section comment')
533
- section_comment.location = tl
534
-
535
- assert_equal 1, cm.sections.length, 'sanity, default section only'
536
- s0 = cm.sections.first
537
- s1 = cm.add_section 'section', section_comment
538
-
539
- cm.add_attribute a1
540
- cm.add_attribute a2
541
- cm.add_method m1
542
- cm.add_constant c1
543
- cm.add_include i1
544
- cm.add_extend e1
545
- cm.add_comment 'this is a comment', tl
546
-
547
- loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x13i\bI\"\nKlass" +
548
- "\x06:\x06ETI\"\x15Namespace::Klass\x06;\x06TI" +
549
- "\"\nSuper\x06;\x06To:\eRDoc::Markup::Document\a" +
550
- ":\v@parts[\x06o;\a\a;\b[\x06o" +
551
- ":\x1CRDoc::Markup::Paragraph\x06;\b[\x06I" +
552
- "\"\x16this is a comment\x06;\x06T:\n@fileI" +
553
- "\"\ffile.rb\x06;\x06T;\n0[\a[\nI\"\aa2\x06;" +
554
- "\x06TI\"\aRW\x06;\x06T:\vpublicT@\x11[\nI" +
555
- "\"\aa1\x06;\x06TI\"\aRW\x06;\x06T;\vF@\x11" +
556
- "[\x06U:\x13RDoc::Constant[\x0Fi\x00I\"\aC1\x06" +
557
- ";\x06TI\"\x19Namespace::Klass::C1\x06;\x06T00o" +
558
- ";\a\a;\b[\x00;\n0@\x11@\ac\x16RDoc::NormalClass0" +
559
- "[\x06[\bI\"\aI1\x06;\x06To;\a\a;\b[\x00;\n0@\x11" +
560
- "[\a[\aI\"\nclass\x06;\x06T[\b[\a;\v[\x00[\a" +
561
- ":\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" +
562
- "\"\rinstance\x06;\x06T[\b[\a;\v[\x06[\aI" +
563
- "\"\am1\x06;\x06T@\x11[\a;\r[\x00[\a;\x0E[\x00" +
564
- "[\x06[\bI\"\aE1\x06;\x06To;\a\a;\b[\x00;\n0@\x11" +
565
- "[\aU:\eRDoc::Context::Section[\bi\x000o;\a\a;\b" +
566
- "[\x00;\n0U;\x0F[\bi\x00I\"\fsection\x06;\x06To" +
567
- ";\a\a;\b[\x06o;\a\a;\b[\x06o;\t\x06;\b[\x06I" +
568
- "\"\x14section comment\x06;\x06T;\n@\x11;\n0" +
569
- "[\x06@\x11I\"\x0ENamespace\x06" +
570
- ";\x06Tc\x17RDoc::NormalModule"
571
-
572
- loaded.store = @store
573
-
574
- assert_equal cm, loaded
575
-
576
- inner = RDoc::Markup::Document.new(
577
- RDoc::Markup::Paragraph.new('this is a comment'))
578
- inner.file = tl
579
-
580
- comment = RDoc::Markup::Document.new inner
581
-
582
- assert_equal [a2, a1], loaded.attributes.sort
583
- assert_equal comment, loaded.comment
584
- assert_equal [c1], loaded.constants
585
- assert_equal 'Namespace::Klass', loaded.full_name
586
- assert_equal [i1], loaded.includes
587
- assert_equal [e1], loaded.extends
588
- assert_equal [m1], loaded.method_list
589
- assert_equal 'Klass', loaded.name
590
- assert_equal 'Super', loaded.superclass
591
- assert_equal 'Namespace', loaded.parent.name
592
- assert loaded.current_section
593
-
594
- expected = {
595
- nil => s0,
596
- 'section' => s1,
597
- }
598
-
599
- assert_equal expected, loaded.sections_hash
600
- assert_equal [tl], loaded.in_files
601
-
602
- assert_equal tl, loaded.attributes. first.file
603
- assert_equal tl, loaded.constants. first.file
604
- assert_equal tl, loaded.includes. first.file
605
- assert_equal tl, loaded.extends. first.file
606
- assert_equal tl, loaded.method_list.first.file
607
- end
608
-
609
- def test_merge
610
- tl = @store.add_file 'one.rb'
611
- p1 = tl.add_class RDoc::NormalClass, 'Parent'
612
- c1 = p1.add_class RDoc::NormalClass, 'Klass'
613
-
614
- c2 = RDoc::NormalClass.new 'Klass'
615
-
616
- c2.merge c1
617
-
618
- assert_equal 'Parent', c1.parent_name, 'original parent name'
619
- assert_equal 'Parent', c2.parent_name, 'merged parent name'
620
-
621
- assert c1.current_section, 'original current_section'
622
- assert c2.current_section, 'merged current_section'
623
- end
624
-
625
- def test_merge_attributes
626
- tl1 = @store.add_file 'one.rb'
627
- tl2 = @store.add_file 'two.rb'
628
-
629
- cm1 = RDoc::ClassModule.new 'Klass'
630
-
631
- attr = cm1.add_attribute RDoc::Attr.new(nil, 'a1', 'RW', '')
632
- attr.record_location tl1
633
- attr = cm1.add_attribute RDoc::Attr.new(nil, 'a3', 'R', '')
634
- attr.record_location tl1
635
- attr = cm1.add_attribute RDoc::Attr.new(nil, 'a4', 'R', '')
636
- attr.record_location tl1
637
-
638
- cm2 = RDoc::ClassModule.new 'Klass'
639
- # TODO allow merging when comment == ''
640
- cm2.instance_variable_set :@comment, @RM::Document.new
641
-
642
- attr = cm2.add_attribute RDoc::Attr.new(nil, 'a2', 'RW', '')
643
- attr.record_location tl2
644
- attr = cm2.add_attribute RDoc::Attr.new(nil, 'a3', 'W', '')
645
- attr.record_location tl1
646
- attr = cm2.add_attribute RDoc::Attr.new(nil, 'a4', 'W', '')
647
- attr.record_location tl1
648
-
649
- cm1.merge cm2
650
-
651
- expected = [
652
- RDoc::Attr.new(nil, 'a2', 'RW', ''),
653
- RDoc::Attr.new(nil, 'a3', 'W', ''),
654
- RDoc::Attr.new(nil, 'a4', 'W', ''),
655
- ]
656
-
657
- expected.each do |a| a.parent = cm1 end
658
- assert_equal expected, cm1.attributes.sort
659
- end
660
-
661
- def test_merge_attributes_version_0
662
- tl1 = @store.add_file 'one.rb'
663
-
664
- cm1 = RDoc::ClassModule.new 'Klass'
665
-
666
- attr = cm1.add_attribute RDoc::Attr.new(nil, 'a1', 'RW', '')
667
- attr.record_location tl1
668
- attr = cm1.add_attribute RDoc::Attr.new(nil, 'a3', 'R', '')
669
- attr.record_location tl1
670
- attr = cm1.add_attribute RDoc::Attr.new(nil, 'a4', 'R', '')
671
- attr.record_location tl1
672
-
673
- cm2 = RDoc::ClassModule.new 'Klass'
674
- # TODO allow merging when comment == ''
675
- cm2.instance_variable_set :@comment, @RM::Document.new
676
-
677
- attr = cm2.add_attribute RDoc::Attr.new(nil, 'a2', 'RW', '')
678
- attr = cm2.add_attribute RDoc::Attr.new(nil, 'a3', 'W', '')
679
- attr = cm2.add_attribute RDoc::Attr.new(nil, 'a4', 'W', '')
680
-
681
- cm1.merge cm2
682
-
683
- expected = [
684
- RDoc::Attr.new(nil, 'a1', 'RW', ''),
685
- RDoc::Attr.new(nil, 'a2', 'RW', ''),
686
- RDoc::Attr.new(nil, 'a3', 'RW', ''),
687
- RDoc::Attr.new(nil, 'a4', 'RW', ''),
688
- ]
689
-
690
- expected.each do |a| a.parent = cm1 end
691
- assert_equal expected, cm1.attributes.sort
692
- end
693
-
694
- def test_merge_collections_drop
695
- tl = @store.add_file 'file'
696
-
697
- cm1 = RDoc::ClassModule.new 'C'
698
- cm1.record_location tl
699
-
700
- const = cm1.add_constant RDoc::Constant.new('CONST', nil, nil)
701
- const.record_location tl
702
-
703
- cm2 = RDoc::ClassModule.new 'C'
704
- cm2.record_location tl
705
-
706
- added = []
707
- removed = []
708
-
709
- cm1.merge_collections cm1.constants, cm2.constants, cm2.in_files do |add, c|
710
- if add then
711
- added << c
712
- else
713
- removed << c
714
- end
715
- end
716
-
717
- assert_empty added
718
- assert_equal [const], removed
719
- end
720
-
721
- def test_merge_comment
722
- tl1 = @store.add_file 'one.rb'
723
- tl2 = @store.add_file 'two.rb'
724
-
725
- cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
726
- cm1.add_comment 'klass 1', tl1
727
- cm1.record_location tl1
728
-
729
- cm2 = tl1.add_class RDoc::NormalClass, 'Klass'
730
- cm2.add_comment 'klass 2', tl2
731
- cm2.add_comment 'klass 3', tl1
732
- cm2.record_location tl1
733
- cm2.record_location tl2
734
-
735
- cm2 = Marshal.load Marshal.dump cm2
736
- cm2.store = @store
737
-
738
- cm1.merge cm2
739
-
740
- inner1 = @RM::Document.new @RM::Paragraph.new 'klass 3'
741
- inner1.file = 'one.rb'
742
- inner2 = @RM::Document.new @RM::Paragraph.new 'klass 2'
743
- inner2.file = 'two.rb'
744
-
745
- expected = @RM::Document.new inner2, inner1
746
-
747
- assert_equal expected, cm1.comment
748
- end
749
-
750
- def test_merge_comment_version_0
751
- tl = @store.add_file 'file.rb'
752
-
753
- cm1 = RDoc::ClassModule.new 'Klass'
754
- cm1.add_comment 'klass 1', tl
755
-
756
- cm2 = RDoc::ClassModule.new 'Klass'
757
-
758
- cm2.instance_variable_set(:@comment,
759
- @RM::Document.new(
760
- @RM::Paragraph.new('klass 2')))
761
- cm2.instance_variable_set :@comment_location, @RM::Document.new(cm2.comment)
762
-
763
- cm1.merge cm2
764
-
765
- inner = @RM::Document.new @RM::Paragraph.new 'klass 1'
766
- inner.file = 'file.rb'
767
-
768
- expected = @RM::Document.new \
769
- inner,
770
- @RM::Document.new(@RM::Paragraph.new('klass 2'))
771
-
772
- assert_equal expected, cm1.comment
773
- end
774
-
775
- def test_merge_constants
776
- tl1 = @store.add_file 'one.rb'
777
- tl2 = @store.add_file 'two.rb'
778
-
779
- cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
780
-
781
- const = cm1.add_constant RDoc::Constant.new('C1', nil, 'one')
782
- const.record_location tl1
783
- const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
784
- const.record_location tl1
785
-
786
- store = RDoc::Store.new
787
- tl = store.add_file 'one.rb'
788
- cm2 = tl.add_class RDoc::ClassModule, 'Klass'
789
- cm2.instance_variable_set :@comment, @RM::Document.new
790
-
791
- const = cm2.add_constant RDoc::Constant.new('C2', nil, 'two')
792
- const.record_location tl2
793
- const = cm2.add_constant RDoc::Constant.new('C3', nil, 'one')
794
- const.record_location tl1
795
- const = cm2.add_constant RDoc::Constant.new('C4', nil, 'one')
796
- const.record_location tl1
797
-
798
- cm1.merge cm2
799
-
800
- expected = [
801
- RDoc::Constant.new('C2', nil, 'two'),
802
- RDoc::Constant.new('C3', nil, 'one'),
803
- RDoc::Constant.new('C4', nil, 'one'),
804
- ]
805
-
806
- expected.each do |a| a.parent = cm1 end
807
-
808
- assert_equal expected, cm1.constants.sort
809
- end
810
-
811
- def test_merge_constants_version_0
812
- tl1 = @store.add_file 'one.rb'
813
-
814
- cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
815
-
816
- const = cm1.add_constant RDoc::Constant.new('C1', nil, 'one')
817
- const.record_location tl1
818
- const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
819
- const.record_location tl1
820
-
821
- store = RDoc::Store.new
822
- tl = store.add_file 'one.rb'
823
- cm2 = tl.add_class RDoc::ClassModule, 'Klass'
824
- cm2.instance_variable_set :@comment, @RM::Document.new
825
-
826
- const = cm2.add_constant RDoc::Constant.new('C2', nil, 'two')
827
- const = cm2.add_constant RDoc::Constant.new('C3', nil, 'two')
828
- const = cm2.add_constant RDoc::Constant.new('C4', nil, 'two')
829
-
830
- cm1.merge cm2
831
-
832
- expected = [
833
- RDoc::Constant.new('C1', nil, 'one'),
834
- RDoc::Constant.new('C2', nil, 'two'),
835
- RDoc::Constant.new('C3', nil, 'one'),
836
- RDoc::Constant.new('C4', nil, 'two'),
837
- ]
838
-
839
- expected.each do |a| a.parent = cm1 end
840
-
841
- assert_equal expected, cm1.constants.sort
842
- end
843
-
844
- def test_merge_extends
845
- tl1 = @store.add_file 'one.rb'
846
- cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
847
-
848
- ext = cm1.add_extend RDoc::Extend.new('I1', 'one')
849
- ext.record_location tl1
850
- ext = cm1.add_extend RDoc::Extend.new('I3', 'one')
851
- ext.record_location tl1
852
-
853
- tl2 = @store.add_file 'two.rb'
854
- tl2.store = RDoc::Store.new
855
-
856
- cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
857
- cm2.instance_variable_set :@comment, @RM::Document.new
858
-
859
- ext = cm2.add_extend RDoc::Extend.new('I2', 'two')
860
- ext.record_location tl2
861
- ext = cm2.add_extend RDoc::Extend.new('I3', 'one')
862
- ext.record_location tl1
863
- ext = cm2.add_extend RDoc::Extend.new('I4', 'one')
864
- ext.record_location tl1
865
-
866
- cm1.merge cm2
867
-
868
- expected = [
869
- RDoc::Extend.new('I2', 'two'),
870
- RDoc::Extend.new('I3', 'one'),
871
- RDoc::Extend.new('I4', 'one'),
872
- ]
873
-
874
- expected.each do |a| a.parent = cm1 end
875
-
876
- assert_equal expected, cm1.extends.sort
877
- end
878
-
879
- def test_merge_includes
880
- tl1 = @store.add_file 'one.rb'
881
-
882
- cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
883
-
884
- incl = cm1.add_include RDoc::Include.new('I1', 'one')
885
- incl.record_location tl1
886
- incl = cm1.add_include RDoc::Include.new('I3', 'one')
887
- incl.record_location tl1
888
-
889
- tl2 = @store.add_file 'two.rb'
890
- tl2.store = RDoc::Store.new
891
-
892
- cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
893
- cm2.instance_variable_set :@comment, @RM::Document.new
894
-
895
- incl = cm2.add_include RDoc::Include.new('I2', 'two')
896
- incl.record_location tl2
897
- incl = cm2.add_include RDoc::Include.new('I3', 'one')
898
- incl.record_location tl1
899
- incl = cm2.add_include RDoc::Include.new('I4', 'one')
900
- incl.record_location tl1
901
-
902
- cm1.merge cm2
903
-
904
- expected = [
905
- RDoc::Include.new('I2', 'two'),
906
- RDoc::Include.new('I3', 'one'),
907
- RDoc::Include.new('I4', 'one'),
908
- ]
909
-
910
- expected.each do |a| a.parent = cm1 end
911
-
912
- assert_equal expected, cm1.includes.sort
913
- end
914
-
915
- def test_merge_includes_version_0
916
- tl1 = @store.add_file 'one.rb'
917
-
918
- cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
919
-
920
- incl = cm1.add_include RDoc::Include.new('I1', 'one')
921
- incl.record_location tl1
922
- incl = cm1.add_include RDoc::Include.new('I3', 'one')
923
- incl.record_location tl1
924
-
925
- tl2 = @store.add_file 'one.rb'
926
- tl2.store = RDoc::Store.new
927
-
928
- cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
929
- cm2.instance_variable_set :@comment, @RM::Document.new
930
-
931
- incl = cm2.add_include RDoc::Include.new('I2', 'two')
932
- incl = cm2.add_include RDoc::Include.new('I3', 'two')
933
- incl = cm2.add_include RDoc::Include.new('I4', 'two')
934
-
935
- cm1.merge cm2
936
-
937
- expected = [
938
- RDoc::Include.new('I1', 'one'),
939
- RDoc::Include.new('I2', 'two'),
940
- RDoc::Include.new('I3', 'one'),
941
- RDoc::Include.new('I4', 'two'),
942
- ]
943
-
944
- expected.each do |a| a.parent = cm1 end
945
-
946
- assert_equal expected, cm1.includes.sort
947
- end
948
-
949
- def test_merge_methods
950
- tl1 = @store.add_file 'one.rb'
951
- tl2 = @store.add_file 'two.rb'
952
-
953
- cm1 = tl1.add_class RDoc::NormalClass, 'Klass'
954
-
955
- meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm1')
956
- meth.record_location tl1
957
- meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm3')
958
- meth.record_location tl1
959
-
960
- cm2 = RDoc::ClassModule.new 'Klass'
961
- cm2.store = @store
962
- cm2.instance_variable_set :@comment, @RM::Document.new
963
-
964
- meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm2')
965
- meth.record_location tl2
966
- meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm3')
967
- meth.record_location tl1
968
- meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm4')
969
- meth.record_location tl1
970
-
971
- cm1.merge cm2
972
-
973
- expected = [
974
- RDoc::AnyMethod.new(nil, 'm2'),
975
- RDoc::AnyMethod.new(nil, 'm3'),
976
- RDoc::AnyMethod.new(nil, 'm4'),
977
- ]
978
-
979
- expected.each do |a| a.parent = cm1 end
980
-
981
- assert_equal expected, cm1.method_list.sort
982
- end
983
-
984
- def test_merge_methods_version_0
985
- tl1 = @store.add_file 'one.rb'
986
-
987
- cm1 = tl1.add_class RDoc::NormalClass, 'Klass'
988
-
989
- meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm1')
990
- meth.record_location tl1
991
- meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm3')
992
- meth.record_location tl1
993
-
994
- cm2 = RDoc::ClassModule.new 'Klass'
995
- cm2.store = @store
996
- cm2.instance_variable_set :@comment, @RM::Document.new
997
-
998
- meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm2')
999
- meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm3')
1000
- meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm4')
1001
-
1002
- cm1.merge cm2
1003
-
1004
- expected = [
1005
- RDoc::AnyMethod.new(nil, 'm1'),
1006
- RDoc::AnyMethod.new(nil, 'm2'),
1007
- RDoc::AnyMethod.new(nil, 'm3'),
1008
- RDoc::AnyMethod.new(nil, 'm4'),
1009
- ]
1010
-
1011
- expected.each do |a| a.parent = cm1 end
1012
-
1013
- assert_equal expected, cm1.method_list.sort
1014
- end
1015
-
1016
- def test_merge_sections
1017
- store1 = @store
1018
-
1019
- tl1_1 = store1.add_file 'one.rb'
1020
-
1021
- cm1 = tl1_1.add_class RDoc::ClassModule, 'Klass'
1022
- cm1.record_location tl1_1
1023
-
1024
- s1_0 = cm1.sections.first
1025
- s1_1 = cm1.add_section 'section 1', comment('comment 1', tl1_1)
1026
- cm1.add_section 'section 2', comment('comment 2 a', tl1_1)
1027
- cm1.add_section 'section 4', comment('comment 4 a', tl1_1)
1028
-
1029
- store2 = RDoc::Store.new
1030
- tl2_1 = store2.add_file 'one.rb'
1031
- tl2_2 = store2.add_file 'two.rb'
1032
-
1033
- cm2 = tl2_1.add_class RDoc::ClassModule, 'Klass'
1034
- cm2.record_location tl2_1
1035
- cm2.record_location tl2_2
1036
-
1037
- cm2.sections.first
1038
- s2_2 = cm2.add_section 'section 2', comment('comment 2 b', tl2_1)
1039
- s2_3 = cm2.add_section 'section 3', comment('comment 3', tl2_2)
1040
- cm2.add_section 'section 4', comment('comment 4 b', tl2_2)
1041
-
1042
- cm1.merge cm2
1043
-
1044
- expected = [
1045
- s1_0,
1046
- s1_1,
1047
- s2_2,
1048
- s2_3,
1049
- RDoc::Context::Section.new(cm1, 'section 4', nil)
1050
- ]
1051
-
1052
- merged_sections = cm1.sections.sort_by do |s|
1053
- s.title || ''
1054
- end
1055
-
1056
- assert_equal expected, merged_sections
1057
-
1058
- assert_equal [comment('comment 2 b', tl2_1)],
1059
- cm1.sections_hash['section 2'].comments
1060
-
1061
- expected_s4_comments = [
1062
- comment('comment 4 a', tl2_1),
1063
- comment('comment 4 b', tl2_2),
1064
- ]
1065
-
1066
- assert_equal expected_s4_comments, cm1.sections_hash['section 4'].comments
1067
- end
1068
-
1069
- def test_merge_sections_overlap
1070
- store1 = @store
1071
-
1072
- tl1_1 = store1.add_file 'one.rb'
1073
- tl1_3 = store1.add_file 'three.rb'
1074
-
1075
- cm1 = tl1_1.add_class RDoc::ClassModule, 'Klass'
1076
- cm1.record_location tl1_1
1077
-
1078
- cm1.add_section 'section', comment('comment 1 a', tl1_1)
1079
- cm1.add_section 'section', comment('comment 3', tl1_3)
1080
-
1081
- store2 = RDoc::Store.new
1082
- tl2_1 = store2.add_file 'one.rb'
1083
- tl2_2 = store2.add_file 'two.rb'
1084
- tl2_3 = store2.add_file 'three.rb'
1085
-
1086
- cm2 = tl2_1.add_class RDoc::ClassModule, 'Klass'
1087
- cm2.record_location tl2_1
1088
- cm2.record_location tl2_2
1089
-
1090
- s2_0 = cm2.sections.first
1091
- s2_1 = cm2.add_section 'section', comment('comment 1 b', tl1_1)
1092
- cm2.add_section 'section', comment('comment 2', tl2_2)
1093
-
1094
- cm1.merge_sections cm2
1095
-
1096
- expected = [
1097
- s2_0,
1098
- s2_1,
1099
- ]
1100
-
1101
- merged_sections = cm1.sections.sort_by do |s|
1102
- s.title || ''
1103
- end
1104
-
1105
- assert_equal expected, merged_sections
1106
-
1107
- expected = [
1108
- comment('comment 1 b', tl2_1),
1109
- comment('comment 3', tl2_3),
1110
- comment('comment 2', tl2_2),
1111
- ]
1112
-
1113
- comments = cm1.sections_hash['section'].comments
1114
-
1115
- assert_equal expected, comments.sort_by { |c| c.file.name }
1116
- end
1117
-
1118
- def test_parse
1119
- tl1 = @store.add_file 'one.rb'
1120
- tl2 = @store.add_file 'two.rb'
1121
-
1122
- cm = RDoc::ClassModule.new 'Klass'
1123
- cm.add_comment 'comment 1', tl1
1124
- cm.add_comment 'comment 2', tl2
1125
-
1126
- doc1 = @RM::Document.new @RM::Paragraph.new 'comment 1'
1127
- doc1.file = tl1
1128
- doc2 = @RM::Document.new @RM::Paragraph.new 'comment 2'
1129
- doc2.file = tl2
1130
-
1131
- expected = @RM::Document.new doc1, doc2
1132
-
1133
- assert_equal expected, cm.parse(cm.comment_location)
1134
- end
1135
-
1136
- def test_parse_comment
1137
- tl1 = @store.add_file 'one.rb'
1138
-
1139
- cm = RDoc::ClassModule.new 'Klass'
1140
- cm.comment = comment 'comment 1', tl1
1141
-
1142
- doc = @RM::Document.new @RM::Paragraph.new 'comment 1'
1143
- doc.file = tl1
1144
-
1145
- assert_equal doc, cm.parse(cm.comment)
1146
- end
1147
-
1148
- def test_parse_comment_format
1149
- tl1 = @store.add_file 'one.rb'
1150
-
1151
- cm = RDoc::ClassModule.new 'Klass'
1152
- cm.comment = comment 'comment ((*1*))', tl1
1153
- cm.comment.format = 'rd'
1154
-
1155
- doc = @RM::Document.new @RM::Paragraph.new 'comment <em>1</em>'
1156
- doc.file = tl1
1157
-
1158
- assert_equal doc, cm.parse(cm.comment)
1159
- end
1160
-
1161
- def test_parse_comment_location
1162
- tl1 = @store.add_file 'one.rb'
1163
- tl2 = @store.add_file 'two.rb'
1164
-
1165
- cm = tl1.add_class RDoc::NormalClass, 'Klass'
1166
- cm.add_comment 'comment 1', tl1
1167
- cm.add_comment 'comment 2', tl2
1168
-
1169
- cm = Marshal.load Marshal.dump cm
1170
-
1171
- doc1 = @RM::Document.new @RM::Paragraph.new 'comment 1'
1172
- doc1.file = tl1
1173
- doc2 = @RM::Document.new @RM::Paragraph.new 'comment 2'
1174
- doc2.file = tl2
1175
-
1176
- assert_same cm.comment_location, cm.parse(cm.comment_location)
1177
- end
1178
-
1179
- def test_remove_nodoc_children
1180
- parent = @top_level.add_class RDoc::ClassModule, 'A'
1181
- parent.modules_hash.replace 'B' => true, 'C' => true
1182
- @store.modules_hash.replace 'A::B' => true
1183
-
1184
- parent.classes_hash.replace 'D' => true, 'E' => true
1185
- @store.classes_hash.replace 'A::D' => true
1186
-
1187
- parent.remove_nodoc_children
1188
-
1189
- assert_equal %w[B], parent.modules_hash.keys
1190
- assert_equal %w[D], parent.classes_hash.keys
1191
- end
1192
-
1193
- def test_search_record
1194
- @c2_c3.add_comment 'This is a comment.', @xref_data
1195
-
1196
- expected = [
1197
- 'C3',
1198
- 'C2::C3',
1199
- 'C2::C3',
1200
- '',
1201
- 'C2/C3.html',
1202
- '',
1203
- "<p>This is a comment.\n"
1204
- ]
1205
-
1206
- assert_equal expected, @c2_c3.search_record
1207
- end
1208
-
1209
- def test_search_record_merged
1210
- @c2_c3.add_comment 'comment A', @store.add_file('a.rb')
1211
- @c2_c3.add_comment 'comment B', @store.add_file('b.rb')
1212
-
1213
- expected = [
1214
- 'C3',
1215
- 'C2::C3',
1216
- 'C2::C3',
1217
- '',
1218
- 'C2/C3.html',
1219
- '',
1220
- "<p>comment A\n<p>comment B\n"
1221
- ]
1222
-
1223
- assert_equal expected, @c2_c3.search_record
1224
- end
1225
-
1226
- def test_store_equals
1227
- # version 2
1228
- loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x0Fi\aI\"\nKlass" +
1229
- "\x06:\x06EFI\"\x15Namespace::Klass\x06;\x06FI" +
1230
- "\"\nSuper\x06;\x06Fo:\eRDoc::Markup::Document\a" +
1231
- ":\v@parts[\x06o;\a\a;\b[\x06o" +
1232
- ":\x1CRDoc::Markup::Paragraph\x06;\b" +
1233
- "[\x06I\"\x16this is a comment\x06;\x06F" +
1234
- ":\n@fileI\"\ffile.rb\x06;\x06F;\n0[\a[\nI" +
1235
- "\"\aa2\x06;\x06FI\"\aRW\x06;\x06F:\vpublicT@\x11" +
1236
- "[\nI\"\aa1\x06;\x06FI\"\aRW\x06;\x06F;\vF@\x11" +
1237
- "[\x06[\bI\"\aC1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
1238
- "[\x06[\bI\"\aI1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
1239
- "[\a[\aI\"\nclass\x06;\x06F[\b[\a;\v[\x00" +
1240
- "[\a:\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" +
1241
- "\"\rinstance\x06;\x06F[\b[\a;\v[\x06[\aI" +
1242
- "\"\am1\x06;\x06F@\x11[\a;\f[\x00[\a;\r[\x00" +
1243
- "[\x06[\bI\"\aE1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11"
1244
-
1245
- loaded.store = @store
1246
-
1247
- assert_same @store, loaded.store
1248
-
1249
- a = loaded.attributes.first
1250
- assert_same @store, a.store
1251
- assert_same @store, a.file.store
1252
-
1253
- c = loaded.constants.first
1254
- assert_same @store, c.store
1255
- assert_same @store, c.file.store
1256
-
1257
- i = loaded.includes.first
1258
- assert_same @store, i.store
1259
- assert_same @store, i.file.store
1260
-
1261
- e = loaded.extends.first
1262
- assert_same @store, e.store
1263
- assert_same @store, e.file.store
1264
-
1265
- m = loaded.method_list.first
1266
- assert_same @store, m.store
1267
- assert_same @store, m.file.store
1268
- end
1269
-
1270
- def test_superclass
1271
- assert_equal @c3_h1, @c3_h2.superclass
1272
- end
1273
-
1274
- def test_update_aliases_class
1275
- n1 = @xref_data.add_module RDoc::NormalClass, 'N1'
1276
- n1_k2 = n1.add_module RDoc::NormalClass, 'N2'
1277
-
1278
- n1.add_module_alias n1_k2, 'A1', @xref_data
1279
-
1280
- n1_a1_c = n1.constants.find { |c| c.name == 'A1' }
1281
- refute_nil n1_a1_c
1282
- assert_equal n1_k2, n1_a1_c.is_alias_for, 'sanity check'
1283
-
1284
- n1.update_aliases
1285
-
1286
- n1_a1_k = @xref_data.find_class_or_module 'N1::A1'
1287
- refute_nil n1_a1_k
1288
- assert_equal n1_k2, n1_a1_k.is_alias_for
1289
- refute_equal n1_k2, n1_a1_k
1290
-
1291
- assert_equal 1, n1_k2.aliases.length
1292
- assert_equal n1_a1_k, n1_k2.aliases.first
1293
-
1294
- assert_equal 'N1::N2', n1_k2.full_name
1295
- assert_equal 'N1::A1', n1_a1_k.full_name
1296
- end
1297
-
1298
- def test_update_aliases_module
1299
- n1 = @xref_data.add_module RDoc::NormalModule, 'N1'
1300
- n1_n2 = n1.add_module RDoc::NormalModule, 'N2'
1301
-
1302
- n1.add_module_alias n1_n2, 'A1', @xref_data
1303
-
1304
- n1_a1_c = n1.constants.find { |c| c.name == 'A1' }
1305
- refute_nil n1_a1_c
1306
- assert_equal n1_n2, n1_a1_c.is_alias_for, 'sanity check'
1307
-
1308
- n1.update_aliases
1309
-
1310
- n1_a1_m = @xref_data.find_class_or_module 'N1::A1'
1311
- refute_nil n1_a1_m
1312
- assert_equal n1_n2, n1_a1_m.is_alias_for
1313
- refute_equal n1_n2, n1_a1_m
1314
-
1315
- assert_equal 1, n1_n2.aliases.length
1316
- assert_equal n1_a1_m, n1_n2.aliases.first
1317
-
1318
- assert_equal 'N1::N2', n1_n2.full_name
1319
- assert_equal 'N1::A1', n1_a1_m.full_name
1320
- end
1321
-
1322
- def test_update_aliases_reparent
1323
- l1 = @xref_data.add_module RDoc::NormalModule, 'L1'
1324
- l1_l2 = l1.add_module RDoc::NormalModule, 'L2'
1325
- o1 = @xref_data.add_module RDoc::NormalModule, 'O1'
1326
-
1327
- o1.add_module_alias l1_l2, 'A1', @xref_data
1328
-
1329
- o1_a1_c = o1.constants.find { |c| c.name == 'A1' }
1330
- refute_nil o1_a1_c
1331
- assert_equal l1_l2, o1_a1_c.is_alias_for
1332
- refute_equal l1_l2, o1_a1_c
1333
-
1334
- o1.update_aliases
1335
-
1336
- o1_a1_m = @xref_data.find_class_or_module 'O1::A1'
1337
- refute_nil o1_a1_m
1338
- assert_equal l1_l2, o1_a1_m.is_alias_for
1339
-
1340
- assert_equal 1, l1_l2.aliases.length
1341
- assert_equal o1_a1_m, l1_l2.aliases[0]
1342
-
1343
- assert_equal 'L1::L2', l1_l2.full_name
1344
- assert_equal 'O1::A1', o1_a1_m.full_name
1345
- end
1346
-
1347
- def test_update_aliases_reparent_root
1348
- store = RDoc::Store.new
1349
-
1350
- top_level = store.add_file 'file.rb'
1351
-
1352
- klass = top_level.add_class RDoc::NormalClass, 'Klass'
1353
- object = top_level.add_class RDoc::NormalClass, 'Object'
1354
-
1355
- const = RDoc::Constant.new 'A', nil, ''
1356
- const.record_location top_level
1357
- const.is_alias_for = klass
1358
-
1359
- top_level.add_module_alias klass, 'A', top_level
1360
-
1361
- object.add_constant const
1362
-
1363
- object.update_aliases
1364
-
1365
- assert_equal %w[A Klass Object], store.classes_hash.keys.sort
1366
-
1367
- assert_equal 'A', store.classes_hash['A'].full_name
1368
- assert_equal 'Klass', store.classes_hash['Klass'].full_name
1369
- end
1370
-
1371
- def test_update_includes
1372
- a = RDoc::Include.new 'M1', nil
1373
- b = RDoc::Include.new 'M2', nil
1374
- c = RDoc::Include.new 'C', nil
1375
-
1376
- @c1.add_include a
1377
- @c1.add_include b
1378
- @c1.add_include c
1379
- @c1.ancestors # cache included modules
1380
-
1381
- @m1_m2.document_self = nil
1382
- assert @m1_m2.remove_from_documentation?
1383
-
1384
- assert @store.modules_hash.key? @m1_m2.full_name
1385
- refute @store.modules_hash[@m1_m2.full_name].nil?
1386
-
1387
- @store.remove_nodoc @store.modules_hash
1388
- refute @store.modules_hash.key? @m1_m2.full_name
1389
-
1390
- @c1.update_includes
1391
-
1392
- assert_equal [a, c], @c1.includes
1393
- end
1394
-
1395
- def test_update_includes_trim
1396
- a = RDoc::Include.new 'D::M', nil
1397
- b = RDoc::Include.new 'D::M', nil
1398
-
1399
- @c1.add_include a
1400
- @c1.add_include b
1401
- @c1.ancestors # cache included modules
1402
-
1403
- @c1.update_includes
1404
-
1405
- assert_equal [a], @c1.includes
1406
- end
1407
-
1408
- def test_update_includes_with_colons
1409
- a = RDoc::Include.new 'M1', nil
1410
- b = RDoc::Include.new 'M1::M2', nil
1411
- c = RDoc::Include.new 'C', nil
1412
-
1413
- @c1.add_include a
1414
- @c1.add_include b
1415
- @c1.add_include c
1416
- @c1.ancestors # cache included modules
1417
-
1418
- @m1_m2.document_self = nil
1419
- assert @m1_m2.remove_from_documentation?
1420
-
1421
- assert @store.modules_hash.key? @m1_m2.full_name
1422
- refute @store.modules_hash[@m1_m2.full_name].nil?
1423
- @store.remove_nodoc @store.modules_hash
1424
- refute @store.modules_hash.key? @m1_m2.full_name
1425
-
1426
- @c1.update_includes
1427
-
1428
- assert_equal [a, c], @c1.includes
1429
- end
1430
-
1431
- def test_update_extends
1432
- a = RDoc::Extend.new 'M1', nil
1433
- b = RDoc::Extend.new 'M2', nil
1434
- c = RDoc::Extend.new 'C', nil
1435
-
1436
- @c1.add_extend a
1437
- @c1.add_extend b
1438
- @c1.add_extend c
1439
- @c1.each_extend do |extend| extend.module end # cache extended modules
1440
-
1441
- @m1_m2.document_self = nil
1442
- assert @m1_m2.remove_from_documentation?
1443
-
1444
- assert @store.modules_hash.key? @m1_m2.full_name
1445
- refute @store.modules_hash[@m1_m2.full_name].nil?
1446
- @store.remove_nodoc @store.modules_hash
1447
- refute @store.modules_hash.key? @m1_m2.full_name
1448
-
1449
- @c1.update_extends
1450
-
1451
- assert_equal [a, b, c], @c1.extends
1452
- end
1453
-
1454
- def test_update_extends_trim
1455
- a = RDoc::Extend.new 'D::M', nil
1456
- b = RDoc::Extend.new 'D::M', nil
1457
-
1458
- @c1.add_extend a
1459
- @c1.add_extend b
1460
- @c1.each_extend do |extend| extend.module end # cache extended modules
1461
-
1462
- @c1.update_extends
1463
-
1464
- assert_equal [a], @c1.extends
1465
- end
1466
-
1467
- def test_update_extends_with_colons
1468
- a = RDoc::Extend.new 'M1', nil
1469
- b = RDoc::Extend.new 'M1::M2', nil
1470
- c = RDoc::Extend.new 'C', nil
1471
-
1472
- @c1.add_extend a
1473
- @c1.add_extend b
1474
- @c1.add_extend c
1475
- @c1.each_extend do |extend| extend.module end # cache extended modules
1476
-
1477
- @m1_m2.document_self = nil
1478
- assert @m1_m2.remove_from_documentation?
1479
-
1480
- assert @store.modules_hash.key? @m1_m2.full_name
1481
- refute @store.modules_hash[@m1_m2.full_name].nil?
1482
-
1483
- @store.remove_nodoc @store.modules_hash
1484
- refute @store.modules_hash.key? @m1_m2.full_name
1485
-
1486
- @c1.update_extends
1487
-
1488
- assert_equal [a, c], @c1.extends
1489
- end
1490
-
1491
- end
1492
-