Skip to content

Commit 381324b

Browse files
committed
Add tests for IO.read and IO.write
1 parent 433fa4f commit 381324b

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/stdlib/IO_test.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,31 @@ def test_binwrite
3535
end
3636
end
3737

38+
def test_read
39+
assert_send_type "(String) -> String",
40+
IO, :read, File.expand_path(__FILE__)
41+
assert_send_type "(String, Integer) -> String",
42+
IO, :read, File.expand_path(__FILE__), 3
43+
assert_send_type "(String, Integer, Integer) -> String",
44+
IO, :read, File.expand_path(__FILE__), 3, 0
45+
end
46+
47+
def test_write
48+
Dir.mktmpdir do |dir|
49+
filename = File.join(dir, "some_file")
50+
content = "foo"
51+
52+
assert_send_type "(String, String) -> Integer",
53+
IO, :write, filename, content
54+
assert_send_type "(String, String, Integer) -> Integer",
55+
IO, :write, filename, content, 0
56+
assert_send_type "(String, String, mode: String) -> Integer",
57+
IO, :write, filename, content, mode: "a"
58+
assert_send_type "(String, String, Integer, mode: String) -> Integer",
59+
IO, :write, filename, content, 0, mode: "a"
60+
end
61+
end
62+
3863
def test_open
3964
Dir.mktmpdir do |dir|
4065
assert_send_type "(Integer) -> IO",

0 commit comments

Comments
 (0)