@@ -218,6 +218,41 @@ class Baz
218218
219219 include_examples 'sibling scopes' , 'class'
220220 end
221+
222+ describe 'mixed (class and module)' do
223+ let ( :scope_parser ) do
224+ RubyLanguageServer ::ScopeParser . new ( <<-RUBY )
225+ module Foo
226+ class Bar
227+ end
228+ module Baz
229+ end
230+ end
231+ RUBY
232+ end
233+
234+ it 'should place sibling class and module at the same level' do
235+ foo = scope_parser . root_scope . children . first
236+ assert_equal ( 'Foo' , foo . name )
237+
238+ # Both Bar (class) and Baz (module) should be children of Foo
239+ children = foo . children
240+ assert_equal ( 2 , children . size , "Foo should have 2 children, but has #{ children . size } " )
241+
242+ bar = children . detect { |c | c . name == 'Bar' }
243+ baz = children . detect { |c | c . name == 'Baz' }
244+
245+ assert_not_nil ( bar , "Bar should be a child of Foo" )
246+ assert_not_nil ( baz , "Baz should be a child of Foo" )
247+
248+ # Verify types are different
249+ assert_equal ( :class , bar . type , "Bar should be a class" )
250+ assert_equal ( :module , baz . type , "Baz should be a module" )
251+
252+ # Verify Baz is not a child of Bar
253+ assert_equal ( 0 , bar . children . size , "Bar should have no children, but has #{ bar . children . size } " )
254+ end
255+ end
221256 end
222257 end
223258end
0 commit comments