@@ -7,37 +7,6 @@ class CGISingletonTest < Test::Unit::TestCase
77 library "cgi"
88 testing "singleton(::CGI)"
99
10- def test_new
11- ARGV . replace ( %w( abc=001 def=002 ) )
12- assert_send_type "() -> void" ,
13- CGI , :new
14- assert_send_type "(?::String options) -> void" ,
15- CGI , :new , 'html3'
16- assert_send_type "(?::String options) ?{ (::String name, ::String value) -> void } -> void" ,
17- CGI , :new , 'html3' do |name , value | name + value end
18- assert_send_type "(::Hash[::Symbol, untyped] options_hash) -> void" ,
19- CGI , :new , { tag_maker : 'html5' , max_multipart_length : 2048 }
20- assert_send_type "(::Hash[::Symbol, untyped] options_hash) ?{ (::String name, ::String value) -> void } -> void" ,
21- CGI , :new , { tag_maker : 'html5' , max_multipart_length : 2048 } do |name , value | name + value end
22- end
23-
24- def test_accept_charset
25- assert_send_type "() -> ::encoding" ,
26- CGI , :accept_charset
27- end
28-
29- def test_accept_charset =
30- assert_send_type "(::String accept_charset) -> ::String" ,
31- CGI , :accept_charset= , 'utf-8'
32- assert_send_type "(::Encoding accept_charset) -> ::Encoding" ,
33- CGI , :accept_charset= , Encoding ::UTF_8
34- end
35-
36- def test_parse
37- assert_send_type "(::String query) -> ::Hash[::String, String | Array[String]]" ,
38- CGI , :parse , 'a=hoge&b=1&c[]=test1&c[]=test2'
39- end
40-
4110 def test_escapeURIComponent
4211 assert_send_type (
4312 "(String) -> String" ,
@@ -59,6 +28,41 @@ def test_unescapeURIComponent
5928 CGI , :unescapeURIComponent , ToStr . new ( "hogehoge" )
6029 )
6130 end
31+
32+ # These methods are removed in Ruby 3.5.
33+ unless RUBY_VERSION >= "3.5"
34+ def test_new
35+ ARGV . replace ( %w( abc=001 def=002 ) )
36+ assert_send_type "() -> void" ,
37+ CGI , :new
38+
39+ assert_send_type "(?::String options) -> void" ,
40+ CGI , :new , 'html3'
41+ assert_send_type "(?::String options) ?{ (::String name, ::String value) -> void } -> void" ,
42+ CGI , :new , 'html3' do |name , value | name + value end
43+ assert_send_type "(::Hash[::Symbol, untyped] options_hash) -> void" ,
44+ CGI , :new , { tag_maker : 'html5' , max_multipart_length : 2048 }
45+ assert_send_type "(::Hash[::Symbol, untyped] options_hash) ?{ (::String name, ::String value) -> void } -> void" ,
46+ CGI , :new , { tag_maker : 'html5' , max_multipart_length : 2048 } do |name , value | name + value end
47+ end
48+
49+ def test_accept_charset
50+ assert_send_type "() -> ::encoding" ,
51+ CGI , :accept_charset
52+ end
53+
54+ def test_accept_charset =
55+ assert_send_type "(::String accept_charset) -> ::String" ,
56+ CGI , :accept_charset= , 'utf-8'
57+ assert_send_type "(::Encoding accept_charset) -> ::Encoding" ,
58+ CGI , :accept_charset= , Encoding ::UTF_8
59+ end
60+
61+ def test_parse
62+ assert_send_type "(::String query) -> ::Hash[::String, String | Array[String]]" ,
63+ CGI , :parse , 'a=hoge&b=1&c[]=test1&c[]=test2'
64+ end
65+ end
6266end
6367
6468class CGITest < Test ::Unit ::TestCase
@@ -77,51 +81,54 @@ def test_print
7781 CGI . new , :print , ''
7882 end
7983
80- def test_http_header
81- assert_send_type "() -> ::String" ,
82- CGI . new , :http_header
83- assert_send_type "(::String options) -> ::String" ,
84- CGI . new , :http_header , 'text/csv'
85- assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String" ,
86- CGI . new , :http_header , { 'type' => 'text/csv' , 'nph' => false , 'length' => 1024 }
87- assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String" ,
88- CGI . new , :http_header , { type : 'text/csv' , nph : false , length : 1024 }
89- end
90-
91- def test_header
92- assert_send_type "() -> ::String" ,
93- CGI . new , :header
94- assert_send_type "(::String options) -> ::String" ,
95- CGI . new , :header , 'text/csv'
96- assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String" ,
97- CGI . new , :header , { 'type' => 'text/csv' , 'nph' => false , 'length' => 1024 }
98- assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String" ,
99- CGI . new , :header , { type : 'text/csv' , nph : false , length : 1024 }
100- end
101-
102- def test_nph?
103- assert_send_type "() -> ::boolish" ,
104- CGI . new , :nph?
105- end
106-
107- def test_out
108- assert_send_type "() { () -> void } -> void" ,
109- CGI . new , :out do '' end
110- assert_send_type "(::String content_type_string) { () -> String } -> void" ,
111- CGI . new , :out , 'text/csv' do '' end
112- assert_send_type "(::Hash[::String, untyped] header_hash) { () -> String } -> void" ,
113- CGI . new , :out , { 'type' => 'text/csv' , 'nph' => false , 'length' => 1024 } do '' end
114- assert_send_type "(::Hash[::String | ::Symbol, untyped] header_hash) { () -> String } -> void" ,
115- CGI . new , :out , { type : 'text/csv' } do '' end
116- end
117-
118- def test_stdinput
119- assert_send_type "() -> ::IO" ,
120- CGI . new , :stdinput
121- end
122-
123- def test_stdoutput
124- assert_send_type "() -> ::IO" ,
125- CGI . new , :stdoutput
84+ # These methods are removed in Ruby 3.5.
85+ unless RUBY_VERSION >= "3.5"
86+ def test_http_header
87+ assert_send_type "() -> ::String" ,
88+ CGI . new , :http_header
89+ assert_send_type "(::String options) -> ::String" ,
90+ CGI . new , :http_header , 'text/csv'
91+ assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String" ,
92+ CGI . new , :http_header , { 'type' => 'text/csv' , 'nph' => false , 'length' => 1024 }
93+ assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String" ,
94+ CGI . new , :http_header , { type : 'text/csv' , nph : false , length : 1024 }
95+ end
96+
97+ def test_header
98+ assert_send_type "() -> ::String" ,
99+ CGI . new , :header
100+ assert_send_type "(::String options) -> ::String" ,
101+ CGI . new , :header , 'text/csv'
102+ assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String" ,
103+ CGI . new , :header , { 'type' => 'text/csv' , 'nph' => false , 'length' => 1024 }
104+ assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String" ,
105+ CGI . new , :header , { type : 'text/csv' , nph : false , length : 1024 }
106+ end
107+
108+ def test_nph?
109+ assert_send_type "() -> ::boolish" ,
110+ CGI . new , :nph?
111+ end
112+
113+ def test_out
114+ assert_send_type "() { () -> void } -> void" ,
115+ CGI . new , :out do '' end
116+ assert_send_type "(::String content_type_string) { () -> String } -> void" ,
117+ CGI . new , :out , 'text/csv' do '' end
118+ assert_send_type "(::Hash[::String, untyped] header_hash) { () -> String } -> void" ,
119+ CGI . new , :out , { 'type' => 'text/csv' , 'nph' => false , 'length' => 1024 } do '' end
120+ assert_send_type "(::Hash[::String | ::Symbol, untyped] header_hash) { () -> String } -> void" ,
121+ CGI . new , :out , { type : 'text/csv' } do '' end
122+ end
123+
124+ def test_stdinput
125+ assert_send_type "() -> ::IO" ,
126+ CGI . new , :stdinput
127+ end
128+
129+ def test_stdoutput
130+ assert_send_type "() -> ::IO" ,
131+ CGI . new , :stdoutput
132+ end
126133 end
127134end
0 commit comments