Skip to content

Commit

Permalink
Fix sort error from rbs v3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Oct 29, 2024
1 parent 49e7bd5 commit 9045c27
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/orthoses/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def sort!
require 'rbs/sorter'
sorter = ::RBS::Sorter.new(nil, stdout: nil)
decl = to_decl
sorter.sort_decl!(decl)
decl = sorter.sort_decl(decl)
lines = decl_to_lines(decl)
@body.replace(lines)
end
Expand Down
33 changes: 33 additions & 0 deletions lib/orthoses/sort_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

begin
require 'test_helper'
rescue LoadError
end

module SortTest
def test_sort(t)
store = Orthoses::Builder.new do
use Orthoses::Sort
use Orthoses::Tap do |store|
store["Foo"].header = "class Foo"
store["Foo"] << "def foo: () -> void"
store["Foo"] << "def baz: () -> void"
store["Foo"] << "def bar: () -> void"
end
run -> () {}
end.call

actual = store.map { |n, c| c.to_rbs }.join("\n")
expect = <<~RBS
class Foo
def bar: () -> void
def baz: () -> void
def foo: () -> void
end
RBS
unless expect == actual
t.error("expect=\n```rbs\n#{expect}```\n, but got \n```rbs\n#{actual}```\n")
end
end
end

0 comments on commit 9045c27

Please sign in to comment.