Skip to content

Commit 328e9ec

Browse files
authored
Merge pull request #2482 from Shopify/update-tests-for-cgi-removal
Skip tests that are obsolete after CGI removal
2 parents a43e90c + 2eac723 commit 328e9ec

File tree

1 file changed

+84
-77
lines changed

1 file changed

+84
-77
lines changed

test/stdlib/CGI_test.rb

Lines changed: 84 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -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
6266
end
6367

6468
class CGITest < Test::Unit::TestCase
@@ -76,51 +80,54 @@ def test_print
7680
CGI.new, :print, ''
7781
end
7882

79-
def test_http_header
80-
assert_send_type "() -> ::String",
81-
CGI.new, :http_header
82-
assert_send_type "(::String options) -> ::String",
83-
CGI.new, :http_header, 'text/csv'
84-
assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String",
85-
CGI.new, :http_header, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 }
86-
assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String",
87-
CGI.new, :http_header, { type: 'text/csv', nph: false, length: 1024 }
88-
end
89-
90-
def test_header
91-
assert_send_type "() -> ::String",
92-
CGI.new, :header
93-
assert_send_type "(::String options) -> ::String",
94-
CGI.new, :header, 'text/csv'
95-
assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String",
96-
CGI.new, :header, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 }
97-
assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String",
98-
CGI.new, :header, { type: 'text/csv', nph: false, length: 1024 }
99-
end
100-
101-
def test_nph?
102-
assert_send_type "() -> ::boolish",
103-
CGI.new, :nph?
104-
end
105-
106-
def test_out
107-
assert_send_type "() { () -> void } -> void",
108-
CGI.new, :out do '' end
109-
assert_send_type "(::String content_type_string) { () -> String } -> void",
110-
CGI.new, :out, 'text/csv' do '' end
111-
assert_send_type "(::Hash[::String, untyped] header_hash) { () -> String } -> void",
112-
CGI.new, :out, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 } do '' end
113-
assert_send_type "(::Hash[::String | ::Symbol, untyped] header_hash) { () -> String } -> void",
114-
CGI.new, :out, { type: 'text/csv' } do '' end
115-
end
116-
117-
def test_stdinput
118-
assert_send_type "() -> ::IO",
119-
CGI.new, :stdinput
120-
end
121-
122-
def test_stdoutput
123-
assert_send_type "() -> ::IO",
124-
CGI.new, :stdoutput
83+
# These methods are removed in Ruby 3.5.
84+
unless RUBY_VERSION >= "3.5"
85+
def test_http_header
86+
assert_send_type "() -> ::String",
87+
CGI.new, :http_header
88+
assert_send_type "(::String options) -> ::String",
89+
CGI.new, :http_header, 'text/csv'
90+
assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String",
91+
CGI.new, :http_header, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 }
92+
assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String",
93+
CGI.new, :http_header, { type: 'text/csv', nph: false, length: 1024 }
94+
end
95+
96+
def test_header
97+
assert_send_type "() -> ::String",
98+
CGI.new, :header
99+
assert_send_type "(::String options) -> ::String",
100+
CGI.new, :header, 'text/csv'
101+
assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String",
102+
CGI.new, :header, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 }
103+
assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String",
104+
CGI.new, :header, { type: 'text/csv', nph: false, length: 1024 }
105+
end
106+
107+
def test_nph?
108+
assert_send_type "() -> ::boolish",
109+
CGI.new, :nph?
110+
end
111+
112+
def test_out
113+
assert_send_type "() { () -> void } -> void",
114+
CGI.new, :out do '' end
115+
assert_send_type "(::String content_type_string) { () -> String } -> void",
116+
CGI.new, :out, 'text/csv' do '' end
117+
assert_send_type "(::Hash[::String, untyped] header_hash) { () -> String } -> void",
118+
CGI.new, :out, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 } do '' end
119+
assert_send_type "(::Hash[::String | ::Symbol, untyped] header_hash) { () -> String } -> void",
120+
CGI.new, :out, { type: 'text/csv' } do '' end
121+
end
122+
123+
def test_stdinput
124+
assert_send_type "() -> ::IO",
125+
CGI.new, :stdinput
126+
end
127+
128+
def test_stdoutput
129+
assert_send_type "() -> ::IO",
130+
CGI.new, :stdoutput
131+
end
125132
end
126133
end

0 commit comments

Comments
 (0)