@@ -66,6 +66,10 @@ def setup
66
66
@mod . record_location @top_level
67
67
end
68
68
69
+ def using_prism_ruby_parser?
70
+ RDoc ::Parser ::Ruby . name == 'RDoc::Parser::PrismRuby'
71
+ end
72
+
69
73
def teardown
70
74
super
71
75
@@ -161,13 +165,17 @@ def test_add_file_relative
161
165
162
166
def test_all_classes_and_modules
163
167
expected = %w[
164
- C1 C10 C10::C11 C11 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1 C9 C9::A C9::B
168
+ C1 C10 C10::C11 C11 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C9 C9::A C9::B
165
169
Child
166
170
M1 M1::M2
167
171
Object
168
172
Parent
169
173
]
170
174
175
+ # C8::S1 does not exist. It should not be in the list.
176
+ # class C8; class << something; class S1; end; end; end
177
+ expected = ( expected + [ 'C8::S1' ] ) . sort unless using_prism_ruby_parser?
178
+
171
179
assert_equal expected ,
172
180
@store . all_classes_and_modules . map { |m | m . full_name } . sort
173
181
end
@@ -213,12 +221,16 @@ def test_class_path
213
221
214
222
def test_classes
215
223
expected = %w[
216
- C1 C10 C10::C11 C11 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1 C9 C9::A C9::B
224
+ C1 C10 C10::C11 C11 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C9 C9::A C9::B
217
225
Child
218
226
Object
219
227
Parent
220
228
]
221
229
230
+ # C8::S1 does not exist. It should not be in the list.
231
+ # class C8; class << something; class S1; end; end; end
232
+ expected = ( expected + [ 'C8::S1' ] ) . sort unless using_prism_ruby_parser?
233
+
222
234
assert_equal expected , @store . all_classes . map { |m | m . full_name } . sort
223
235
end
224
236
@@ -550,6 +562,13 @@ def test_load_class
550
562
end
551
563
552
564
def test_load_single_class
565
+ if using_prism_ruby_parser?
566
+ # Class defined inside singleton class is not documentable.
567
+ # @c8_s1 should be nil because C8::S1 does not exist.
568
+ assert_nil @c8_s1
569
+ return
570
+ end
571
+
553
572
@s . save_class @c8_s1
554
573
@s . classes_hash . clear
555
574
0 commit comments