File tree Expand file tree Collapse file tree 2 files changed +17
-22
lines changed Expand file tree Collapse file tree 2 files changed +17
-22
lines changed Original file line number Diff line number Diff line change @@ -318,28 +318,6 @@ module A
318318 assert_instance_of ( Entry ::Constant , constant )
319319 end
320320
321- def test_self_referential_constant_alias
322- index ( <<~RUBY )
323- module RealClass
324- CONSTANT = {}
325- end
326-
327- module Foo
328- SomeClass = ::SomeClass
329- RealClass = ::RealClass
330-
331- UNRESOLVED = SomeClass::CONSTANT
332- CONSTANT = RealClass::CONSTANT
333- end
334- RUBY
335-
336- assert_entry ( "RealClass" , Entry ::Module , "/fake/path/foo.rb:0-0:2-3" )
337- assert_no_entry ( "SomeClass" )
338- assert_entry ( "Foo" , Entry ::Module , "/fake/path/foo.rb:4-0:10-3" )
339- assert_entry ( "RealClass::CONSTANT" , Entry ::Constant , "/fake/path/foo.rb:1-2:1-15" )
340- assert_entry ( "Foo::UNRESOLVED" , Entry ::UnresolvedConstantAlias , "/fake/path/foo.rb:8-2:8-34" )
341- end
342-
343321 def test_indexing_or_and_operator_nodes
344322 index ( <<~RUBY )
345323 A ||= 1
Original file line number Diff line number Diff line change @@ -1175,6 +1175,23 @@ module D
11751175 assert_equal ( "A::B::C" , entry . target )
11761176 end
11771177
1178+ def test_resolving_non_existing_self_referential_constant_alias
1179+ index ( <<~RUBY )
1180+ module Foo
1181+ SomeClass = ::SomeClass
1182+ UNRESOLVED = SomeClass::CONSTANT
1183+ end
1184+ RUBY
1185+
1186+ entry = @index . resolve ( "Foo::UNRESOLVED" , [ ] ) &.first #: as !nil
1187+ assert_kind_of ( Entry ::UnresolvedConstantAlias , entry )
1188+ assert_equal ( 3 , entry . location . start_line )
1189+ assert_equal ( "SomeClass::CONSTANT" , entry . target )
1190+
1191+ entry = @index . resolve ( "SomeClass::CONSTANT" , [ "Foo" ] )
1192+ refute ( entry )
1193+ end
1194+
11781195 def test_resolving_qualified_references
11791196 index ( <<~RUBY )
11801197 module Namespace
You can’t perform that action at this time.
0 commit comments