forked from Shopify/ruby-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrbs_document_test.rb
35 lines (29 loc) · 997 Bytes
/
rbs_document_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# typed: true
# frozen_string_literal: true
require "test_helper"
class RBSDocumentTest < Minitest::Test
def test_parse_result_is_array_of_declarations
document = RubyLsp::RBSDocument.new(source: <<~RBS, version: 1, uri: URI("file:///foo.rbs"))
class Foo
def bar: () -> void
end
RBS
refute_predicate(document, :syntax_error?)
assert_equal(:Foo, T.cast(document.parse_result[0], RBS::AST::Declarations::Class).name.name)
end
def test_parsing_remembers_syntax_errors
# The syntax error is that `-` should be `->`
document = RubyLsp::RBSDocument.new(source: +<<~RBS, version: 1, uri: URI("file:///foo.rbs"))
class Foo
def bar: () - void
end
RBS
assert_predicate(document, :syntax_error?)
document.push_edits(
[{ range: { start: { line: 1, character: 15 }, end: { line: 1, character: 15 } }, text: ">" }],
version: 2,
)
document.parse!
refute_predicate(document, :syntax_error?)
end
end