Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Dec 26, 2024
1 parent 1080aba commit 1e3b811
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions test/server/lsp_formatter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,45 +211,48 @@ def foo: () -> Symbol
end

def test_ruby_hover_method_call__special
with_factory do
typing = type_check(<<~RUBY)
[1, nil].compact
RUBY

call = typing.call_of(node: typing.source.node)
with_factory do
typing = type_check(<<~RUBY)
[1, nil].compact
RUBY

content = Services::HoverProvider::Ruby::MethodCallContent.new(
node: nil,
method_call: call,
location: nil
)
call = typing.call_of(node: typing.source.node)

comment = Server::LSPFormatter.format_hover_content(content)
assert_equal <<~MD.chomp, comment
```rbs
::Array[::Integer]
```
content = Services::HoverProvider::Ruby::MethodCallContent.new(
node: nil,
method_call: call,
location: nil
)

----
**💡 Custom typing rule applies**
comment = Server::LSPFormatter.format_hover_content(content)
assert_equal <<~MD, comment
```rbs
::Array[::Integer]
```
----
**Method type**:
```rbs
() -> ::Array[::Integer]
```
----
### 📚 Array#compact
----
**💡 Custom typing rule applies**
Returns a new Array containing all non-`nil` elements from `self`:
----
**Method type**:
```rbs
() -> ::Array[::Integer]
```
----
### 📚 Array#compact
a = [nil, 0, nil, 1, nil, 2, nil]
a.compact # => [0, 1, 2]
Returns a new array containing only the non-`nil` elements from `self`;
element order is preserved:
a = [nil, 0, nil, false, nil, '', nil, [], nil, {}]
a.compact # => [0, false, \"\", [], {}]
MD
end
Related: Array#compact!; see also [Methods for
Deleting](rdoc-ref:Array@Methods+for+Deleting).
MD
end
end


def test_ruby_hover_method_call__error
Expand Down

0 comments on commit 1e3b811

Please sign in to comment.