Skip to content

Commit c641e15

Browse files
committed
Move test case and simplify it
1 parent 81b8818 commit c641e15

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

lib/ruby_indexer/test/constant_test.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff 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

lib/ruby_indexer/test/index_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)