Sha256: 3174452b54cab1c15f31202d925b3952df1796648da549571de060b229500b15
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 KB
Contents
# typed: true # frozen_string_literal: true require_relative "test_case" module RubyIndexer class MethodTest < TestCase def test_method_with_no_parameters index(<<~RUBY) class Foo def bar end end RUBY assert_entry("bar", Entry::InstanceMethod, "/fake/path/foo.rb:1-2:2-5") end def test_singleton_method_using_self_receiver index(<<~RUBY) class Foo def self.bar end end RUBY assert_entry("bar", Entry::SingletonMethod, "/fake/path/foo.rb:1-2:2-5") end def test_singleton_method_using_other_receiver_is_not_indexed index(<<~RUBY) class Foo def String.bar end end RUBY assert_no_entry("bar") end def test_method_with_parameters index(<<~RUBY) class Foo def bar(a) end end RUBY assert_entry("bar", Entry::InstanceMethod, "/fake/path/foo.rb:1-2:2-5") entry = T.must(@index["bar"].first) assert_equal(1, entry.parameters.length) parameter = entry.parameters.first assert_equal(:a, parameter.name) assert_instance_of(Entry::RequiredParameter, parameter) end def test_method_with_destructed_parameters index(<<~RUBY) class Foo def bar((a, (b, ))) end end RUBY assert_entry("bar", Entry::InstanceMethod, "/fake/path/foo.rb:1-2:2-5") entry = T.must(@index["bar"].first) assert_equal(1, entry.parameters.length) parameter = entry.parameters.first assert_equal(:"(a, (b, ))", parameter.name) assert_instance_of(Entry::RequiredParameter, parameter) end def test_keeps_track_of_method_owner index(<<~RUBY) class Foo def bar end end RUBY entry = T.must(@index["bar"].first) owner_name = T.must(entry.owner).name assert_equal("Foo", owner_name) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-lsp-0.12.5 | lib/ruby_indexer/test/method_test.rb |
ruby-lsp-0.12.4 | lib/ruby_indexer/test/method_test.rb |