Skip to content

Commit

Permalink
Add test for IO#each_line
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Dec 23, 2024
1 parent f6bb8d8 commit a419a69
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/stdlib/IO_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,39 @@ def test_autoclose?
end
end

def test_each_line
IO.open(IO.sysopen(File.expand_path(__FILE__)), path: "foo") do |io|
assert_send_type(
"() -> Enumerator[String, IO]",
io, :each_line
)
end

IO.open(IO.sysopen(File.expand_path(__FILE__)), path: "foo") do |io|
assert_send_type(
"() { (String) -> void } -> void",
io, :each_line, &->(_x) { }
)
end

IO.open(IO.sysopen(File.expand_path(__FILE__)), path: "foo") do |io|
with_string("\n") do |sep|
with_int(3) do |limit|
with_boolish() do |chomp|
assert_send_type(
"(string, int, chomp: boolish) -> Enumerator[String, IO]",
io, :each_line, sep, limit, chomp: chomp
)
assert_send_type(
"(string, int, chomp: boolish) { (String) -> void } -> void",
io, :each_line, sep, limit, chomp: chomp, &->(_x) { }
)
end
end
end
end
end

def test_path
IO.open(IO.sysopen(File.expand_path(__FILE__)), path: "foo") do |io|
assert_send_type(
Expand Down

0 comments on commit a419a69

Please sign in to comment.