-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
49 additions
and
75 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
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,42 @@ | ||
# typed: true | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
module RubyIndexer | ||
class TestCase < Minitest::Test | ||
def setup | ||
@index = Index.new | ||
end | ||
|
||
private | ||
|
||
def index(source) | ||
@index.index_single("/fake/path/foo.rb", source) | ||
end | ||
|
||
def assert_entry(expected_name, type, expected_location) | ||
entries = @index[expected_name] | ||
refute_empty(entries, "Expected #{expected_name} to be indexed") | ||
|
||
entry = entries.first | ||
assert_instance_of(type, entry, "Expected #{expected_name} to be a #{type}") | ||
|
||
location = entry.location | ||
location_string = | ||
"#{entry.file_path}:#{location.start_line - 1}-#{location.start_column}" \ | ||
":#{location.end_line - 1}-#{location.end_column}" | ||
|
||
assert_equal(expected_location, location_string) | ||
end | ||
|
||
def refute_entry(expected_name) | ||
entries = @index[expected_name] | ||
assert_nil(entries, "Expected #{expected_name} to not be indexed") | ||
end | ||
|
||
def assert_no_entry | ||
assert_empty(@index.instance_variable_get(:@entries), "Expected nothing to be indexed") | ||
end | ||
end | ||
end |