Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce TestHelper#parse_rbi #345

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions test/rbi/formatter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

module RBI
class FormatterTest < Minitest::Test
include TestHelper

def test_format_add_sig_templates
rbi = <<~RBI
module Foo
Expand All @@ -13,7 +15,7 @@ def foo(a, b); end
RBI

file = File.new
file.root = Parser.parse_string(rbi)
file.root = parse_rbi(rbi)

out = Formatter.new(add_sig_templates: false).print_file(file)
assert_equal(rbi, out)
Expand All @@ -38,7 +40,7 @@ def bar(a, b); end
RBI

file = File.new
file.root = Parser.parse_string(rbi)
file.root = parse_rbi(rbi)

out = Formatter.new(group_nodes: false).print_file(file)
assert_equal(rbi, out)
Expand All @@ -63,7 +65,7 @@ def foo(a, b); end
RBI

file = File.new
file.root = Parser.parse_string(rbi)
file.root = parse_rbi(rbi)

out = Formatter.new(max_line_length: nil).print_file(file)
assert_equal(rbi, out)
Expand All @@ -90,7 +92,7 @@ def self.foo; end
RBI

file = File.new
file.root = Parser.parse_string(rbi)
file.root = parse_rbi(rbi)

out = Formatter.new(nest_singleton_methods: false).print_file(file)
assert_equal(rbi, out)
Expand All @@ -113,7 +115,7 @@ module Foo
RBI

file = File.new
file.root = Parser.parse_string(rbi)
file.root = parse_rbi(rbi)

out = Formatter.new(nest_non_public_methods: false).print_file(file)
assert_equal(rbi, out)
Expand All @@ -137,7 +139,7 @@ def bar(a, b); end
RBI

file = File.new
file.root = Parser.parse_string(rbi)
file.root = parse_rbi(rbi)

out = Formatter.new(sort_nodes: false).print_file(file)
assert_equal(rbi, out)
Expand Down
11 changes: 6 additions & 5 deletions test/rbi/index_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

module RBI
class IndexTest < Minitest::Test
include TestHelper
extend T::Sig

def test_index_empty_trees
Expand All @@ -14,7 +15,7 @@ def test_index_empty_trees
end

def test_index_scopes_and_consts
rbi = Parser.parse_string(<<~RBI)
rbi = parse_rbi(<<~RBI)
class A
module B
module ::C; end
Expand All @@ -38,7 +39,7 @@ class << self; end
end

def test_index_properties
rbi = Parser.parse_string(<<~RBI)
rbi = parse_rbi(<<~RBI)
class A
attr_reader :a, :b
attr_writer :a, :b
Expand Down Expand Up @@ -70,7 +71,7 @@ def foo(a); end
end

def test_index_sorbet_constructs
rbi = Parser.parse_string(<<~RBI)
rbi = parse_rbi(<<~RBI)
class A < T::Struct
const :a, Integer
prop :b, String
Expand Down Expand Up @@ -105,15 +106,15 @@ class B < T::Enum
end

def test_index_multiple_trees
tree1 = Parser.parse_string(<<~RBI)
tree1 = parse_rbi(<<~RBI)
class A
module B
module ::C; end
end
end
RBI

tree2 = Parser.parse_string(<<~RBI)
tree2 = parse_rbi(<<~RBI)
class A
module B
module ::C; end
Expand Down
Loading
Loading