@@ -11,6 +11,8 @@ class IOSingletonTest < Test::Unit::TestCase
1111 def test_binread
1212 assert_send_type "(String) -> String" ,
1313 IO , :binread , File . expand_path ( __FILE__ )
14+ assert_send_type "(Pathname) -> String" ,
15+ IO , :binread , Pathname ( File . expand_path ( __FILE__ ) )
1416 assert_send_type "(String, Integer) -> String" ,
1517 IO , :binread , File . expand_path ( __FILE__ ) , 3
1618 assert_send_type "(String, Integer, Integer) -> String" ,
@@ -26,6 +28,8 @@ def test_binwrite
2628
2729 assert_send_type "(String, String) -> Integer" ,
2830 IO , :binwrite , filename , content
31+ assert_send_type "(Pathname, String) -> Integer" ,
32+ IO , :binwrite , Pathname ( filename ) , content
2933 assert_send_type "(String, String, Integer) -> Integer" ,
3034 IO , :binwrite , filename , content , 0
3135 assert_send_type "(String, String, mode: String) -> Integer" ,
@@ -35,6 +39,35 @@ def test_binwrite
3539 end
3640 end
3741
42+ def test_read
43+ assert_send_type "(String) -> String" ,
44+ IO , :read , File . expand_path ( __FILE__ )
45+ assert_send_type "(Pathname) -> String" ,
46+ IO , :read , Pathname ( File . expand_path ( __FILE__ ) )
47+ assert_send_type "(String, Integer) -> String" ,
48+ IO , :read , File . expand_path ( __FILE__ ) , 3
49+ assert_send_type "(String, Integer, Integer) -> String" ,
50+ IO , :read , File . expand_path ( __FILE__ ) , 3 , 0
51+ end
52+
53+ def test_write
54+ Dir . mktmpdir do |dir |
55+ filename = File . join ( dir , "some_file" )
56+ content = "foo"
57+
58+ assert_send_type "(String, String) -> Integer" ,
59+ IO , :write , filename , content
60+ assert_send_type "(Pathname, String) -> Integer" ,
61+ IO , :write , Pathname ( filename ) , content
62+ assert_send_type "(String, String, Integer) -> Integer" ,
63+ IO , :write , filename , content , 0
64+ assert_send_type "(String, String, mode: String) -> Integer" ,
65+ IO , :write , filename , content , mode : "a"
66+ assert_send_type "(String, String, Integer, mode: String) -> Integer" ,
67+ IO , :write , filename , content , 0 , mode : "a"
68+ end
69+ end
70+
3871 def test_open
3972 Dir . mktmpdir do |dir |
4073 assert_send_type "(Integer) -> IO" ,
0 commit comments