-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Index all missing global variable nodes (#2699)
feat: handle all kind of global variable nodes in indexer
- Loading branch information
Showing
2 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# typed: true | ||
# frozen_string_literal: true | ||
|
||
require_relative "test_case" | ||
|
||
module RubyIndexer | ||
class GlobalVariableTest < TestCase | ||
def test_global_variable_and_write | ||
index(<<~RUBY) | ||
$foo &&= 1 | ||
RUBY | ||
|
||
assert_entry("$foo", Entry::GlobalVariable, "/fake/path/foo.rb:0-0:0-4") | ||
end | ||
|
||
def test_global_variable_operator_write | ||
index(<<~RUBY) | ||
$foo += 1 | ||
RUBY | ||
|
||
assert_entry("$foo", Entry::GlobalVariable, "/fake/path/foo.rb:0-0:0-4") | ||
end | ||
|
||
def test_global_variable_or_write | ||
index(<<~RUBY) | ||
$foo ||= 1 | ||
RUBY | ||
|
||
assert_entry("$foo", Entry::GlobalVariable, "/fake/path/foo.rb:0-0:0-4") | ||
end | ||
|
||
def test_global_variable_target_node | ||
index(<<~RUBY) | ||
$foo, $bar = 1 | ||
RUBY | ||
|
||
assert_entry("$foo", Entry::GlobalVariable, "/fake/path/foo.rb:0-0:0-4") | ||
assert_entry("$bar", Entry::GlobalVariable, "/fake/path/foo.rb:0-6:0-10") | ||
end | ||
|
||
def test_global_variable_write | ||
index(<<~RUBY) | ||
$foo = 1 | ||
RUBY | ||
|
||
assert_entry("$foo", Entry::GlobalVariable, "/fake/path/foo.rb:0-0:0-4") | ||
end | ||
end | ||
end |