Skip to content

Commit 8777b31

Browse files
authored
Merge pull request #2672 from ruby/fix-pathname
Fix test failure
2 parents ba2829a + f39a1f3 commit 8777b31

File tree

3 files changed

+110
-79
lines changed

3 files changed

+110
-79
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
@@ -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
127134
end

test/stdlib/Pathname_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def test_pwd
2828
end
2929

3030
def test_initialize
31+
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
32+
3133
assert_send_type '(String) -> Pathname',
3234
Pathname, :new, 'foo'
3335
assert_send_type '(ToStr) -> Pathname',
@@ -43,6 +45,8 @@ class PathnameInstanceTest < Test::Unit::TestCase
4345
testing '::Pathname'
4446

4547
def test_plus
48+
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
49+
4650
assert_send_type '(Pathname) -> Pathname',
4751
Pathname('foo'), :+, Pathname('bar')
4852
assert_send_type '(String) -> Pathname',
@@ -52,6 +56,8 @@ def test_plus
5256
end
5357

5458
def test_slash
59+
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
60+
5561
assert_send_type '(Pathname) -> Pathname',
5662
Pathname('foo'), :/, Pathname('bar')
5763
assert_send_type '(String) -> Pathname',
@@ -380,6 +386,8 @@ def test_inspect
380386
end
381387

382388
def test_join
389+
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
390+
383391
assert_send_type '() -> Pathname',
384392
Pathname('.'), :join
385393
assert_send_type '(String) -> Pathname',
@@ -602,6 +610,8 @@ def test_relative?
602610
end
603611

604612
def test_relative_path_from
613+
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
614+
605615
assert_send_type '(Pathname) -> Pathname',
606616
Pathname('.'), :relative_path_from, Pathname('.')
607617
assert_send_type '(String) -> Pathname',
@@ -824,6 +834,8 @@ class PathnameKernelTest < Test::Unit::TestCase
824834
testing '::Kernel'
825835

826836
def test_Pathname
837+
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
838+
827839
with_string("Gemfile") do
828840
assert_send_type(
829841
"(::string) -> ::Pathname",

test/stdlib/Ractor_test.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,18 @@ def test_recv
7474
end
7575

7676
def test_receive_if
77+
omit "Ractor.receive_if is not implemented" if RUBY_VERSION >= "3.5"
78+
7779
Ractor.current.send 42
7880
assert_send_type "() { (Integer) -> bool } -> Integer",
7981
Ractor, :receive_if do |n| n == 42 end
8082
end
8183

8284
def test_select
83-
r1 = Ractor.new { loop { Ractor.yield 42 } }
84-
r2 = Ractor.new { loop { Ractor.yield 43 } }
85+
omit "Ractor#yield is not implemented" if RUBY_VERSION >= "3.5"
86+
87+
r1 = Ractor.new {|r| loop { Ractor.yield 42 } }
88+
r2 = Ractor.new {|r| loop { Ractor.yield 43 } }
8589

8690
assert_send_type "(Ractor) -> [Ractor, Integer]",
8791
Ractor, :select, r1
@@ -115,6 +119,8 @@ def test_store_if_absent
115119
end
116120

117121
def test_yield
122+
omit "Ractor#yield is not implemented" if RUBY_VERSION >= "3.5"
123+
118124
Ractor.new(Ractor.current) { |r| loop { r.take } }
119125

120126
assert_send_type "(Integer) -> untyped",
@@ -153,12 +159,16 @@ def test_aset
153159
end
154160

155161
def test_close_incoming
162+
omit "Ractor#close_incoming is not implemented" if RUBY_VERSION >= "3.5"
163+
156164
r = Ractor.new {}
157165
assert_send_type "() -> bool",
158166
r, :close_incoming
159167
end
160168

161169
def test_close_outgoing
170+
omit "Ractor#close_outgoing is not implemented" if RUBY_VERSION >= "3.5"
171+
162172
r = Ractor.new {}
163173
assert_send_type "() -> bool",
164174
r, :close_outgoing
@@ -190,6 +200,8 @@ def test_send
190200
end
191201

192202
def test_take
203+
omit "Ractor#take is not implemented" if RUBY_VERSION >= "3.5"
204+
193205
r = Ractor.new { 42 }
194206

195207
assert_send_type "() -> Integer",

0 commit comments

Comments
 (0)