Skip to content

Commit a419a69

Browse files
committed
Add test for IO#each_line
1 parent f6bb8d8 commit a419a69

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/stdlib/IO_test.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,39 @@ def test_autoclose?
231231
end
232232
end
233233

234+
def test_each_line
235+
IO.open(IO.sysopen(File.expand_path(__FILE__)), path: "foo") do |io|
236+
assert_send_type(
237+
"() -> Enumerator[String, IO]",
238+
io, :each_line
239+
)
240+
end
241+
242+
IO.open(IO.sysopen(File.expand_path(__FILE__)), path: "foo") do |io|
243+
assert_send_type(
244+
"() { (String) -> void } -> void",
245+
io, :each_line, &->(_x) { }
246+
)
247+
end
248+
249+
IO.open(IO.sysopen(File.expand_path(__FILE__)), path: "foo") do |io|
250+
with_string("\n") do |sep|
251+
with_int(3) do |limit|
252+
with_boolish() do |chomp|
253+
assert_send_type(
254+
"(string, int, chomp: boolish) -> Enumerator[String, IO]",
255+
io, :each_line, sep, limit, chomp: chomp
256+
)
257+
assert_send_type(
258+
"(string, int, chomp: boolish) { (String) -> void } -> void",
259+
io, :each_line, sep, limit, chomp: chomp, &->(_x) { }
260+
)
261+
end
262+
end
263+
end
264+
end
265+
end
266+
234267
def test_path
235268
IO.open(IO.sysopen(File.expand_path(__FILE__)), path: "foo") do |io|
236269
assert_send_type(

0 commit comments

Comments
 (0)