Skip to content

Commit

Permalink
Add tests for T::Struct and T::Enum
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcarbs committed Dec 2, 2021
1 parent 3f3ff27 commit c4f90c9
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions test/rbi/rewriters/flatten_scopes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,70 @@ def m1; end
module A::B::C::D; end
RBI
end

def test_flatten_scopes_with_t_struct
rbi = RBI::Parser.parse_string(<<~RBI)
module A
class B < T::Struct
const :foo, String
class C
module D; end
end
end
end
module E; end
RBI

rbi.flatten_scopes!

assert_equal(<<~RBI, rbi.string)
module A; end
module E; end
class A::B < T::Struct
const :foo, String
end
class A::B::C; end
module A::B::C::D; end
RBI
end

def test_flatten_scopes_with_t_enum
rbi = RBI::Parser.parse_string(<<~RBI)
module A
class B
class C
class D < T::Enum
enums do
Foo = new
Bar = new
end
end
end
end
end
module E; end
RBI

rbi.flatten_scopes!

assert_equal(<<~RBI, rbi.string)
module A; end
module E; end
class A::B; end
class A::B::C; end
class A::B::C::D < T::Enum
enums do
Foo = new
Bar = new
end
end
RBI
end
end
end

0 comments on commit c4f90c9

Please sign in to comment.