@@ -35,4 +35,32 @@ def test_foreach
3535 assert_send_type "(String path, headers: bool, **untyped) -> Enumerator[CSV::Row, void]" ,
3636 CSV , :foreach , path , headers : true , encoding : 'UTF-8'
3737 end
38+
39+ def test_read
40+ tmpdir = Dir . mktmpdir
41+ path = File . join ( tmpdir , "example.csv" )
42+ File . write ( path , "a,b,c\n 1,2,3\n " )
43+
44+ assert_send_type "(String path, headers: true) -> CSV::Table[CSV::Row]" ,
45+ CSV , :read , path , headers : true
46+ assert_send_type "(IO path, headers: true) -> CSV::Table[CSV::Row]" ,
47+ CSV , :read , File . open ( path ) , headers : true
48+ assert_send_type "(String path, headers: :first_row) -> CSV::Table[CSV::Row]" ,
49+ CSV , :read , path , headers : :first_row
50+ assert_send_type "(IO path, headers: :first_row) -> CSV::Table[CSV::Row]" ,
51+ CSV , :read , File . open ( path ) , headers : :first_row
52+ assert_send_type "(String path, headers: Array[String]) -> CSV::Table[CSV::Row]" ,
53+ CSV , :read , path , headers : %w[ foo bar baz ]
54+ assert_send_type "(IO path, headers: Array[String]) -> CSV::Table[CSV::Row]" ,
55+ CSV , :read , File . open ( path ) , headers : %w[ foo bar baz ]
56+ assert_send_type "(String path, headers: String) -> CSV::Table[CSV::Row]" ,
57+ CSV , :read , path , headers : "foo,bar,baz"
58+ assert_send_type "(IO path, headers: String) -> CSV::Table[CSV::Row]" ,
59+ CSV , :read , File . open ( path ) , headers : "foo,bar,baz"
60+
61+ assert_send_type "(String path) -> Array[Array[String?]]" ,
62+ CSV , :read , path
63+ assert_send_type "(IO path) -> Array[Array[String?]]" ,
64+ CSV , :read , File . open ( path )
65+ end
3866end
0 commit comments