diff --git a/test/stdlib/CGI_test.rb b/test/stdlib/CGI_test.rb index c88b05b2c..dfdff203b 100644 --- a/test/stdlib/CGI_test.rb +++ b/test/stdlib/CGI_test.rb @@ -7,37 +7,6 @@ class CGISingletonTest < Test::Unit::TestCase library "cgi" testing "singleton(::CGI)" - def test_new - ARGV.replace(%w(abc=001 def=002)) - assert_send_type "() -> void", - CGI, :new - assert_send_type "(?::String options) -> void", - CGI, :new, 'html3' - assert_send_type "(?::String options) ?{ (::String name, ::String value) -> void } -> void", - CGI, :new, 'html3' do |name, value| name + value end - assert_send_type "(::Hash[::Symbol, untyped] options_hash) -> void", - CGI, :new, { tag_maker: 'html5', max_multipart_length: 2048 } - assert_send_type "(::Hash[::Symbol, untyped] options_hash) ?{ (::String name, ::String value) -> void } -> void", - CGI, :new, { tag_maker: 'html5', max_multipart_length: 2048 } do |name, value| name + value end - end - - def test_accept_charset - assert_send_type "() -> ::encoding", - CGI, :accept_charset - end - - def test_accept_charset= - assert_send_type "(::String accept_charset) -> ::String", - CGI, :accept_charset=, 'utf-8' - assert_send_type "(::Encoding accept_charset) -> ::Encoding", - CGI, :accept_charset=, Encoding::UTF_8 - end - - def test_parse - assert_send_type "(::String query) -> ::Hash[::String, String | Array[String]]", - CGI, :parse, 'a=hoge&b=1&c[]=test1&c[]=test2' - end - def test_escapeURIComponent assert_send_type( "(String) -> String", @@ -59,6 +28,41 @@ def test_unescapeURIComponent CGI, :unescapeURIComponent, ToStr.new("hogehoge") ) end + + # These methods are removed in Ruby 3.5. + unless RUBY_VERSION >= "3.5" + def test_new + ARGV.replace(%w(abc=001 def=002)) + assert_send_type "() -> void", + CGI, :new + + assert_send_type "(?::String options) -> void", + CGI, :new, 'html3' + assert_send_type "(?::String options) ?{ (::String name, ::String value) -> void } -> void", + CGI, :new, 'html3' do |name, value| name + value end + assert_send_type "(::Hash[::Symbol, untyped] options_hash) -> void", + CGI, :new, { tag_maker: 'html5', max_multipart_length: 2048 } + assert_send_type "(::Hash[::Symbol, untyped] options_hash) ?{ (::String name, ::String value) -> void } -> void", + CGI, :new, { tag_maker: 'html5', max_multipart_length: 2048 } do |name, value| name + value end + end + + def test_accept_charset + assert_send_type "() -> ::encoding", + CGI, :accept_charset + end + + def test_accept_charset= + assert_send_type "(::String accept_charset) -> ::String", + CGI, :accept_charset=, 'utf-8' + assert_send_type "(::Encoding accept_charset) -> ::Encoding", + CGI, :accept_charset=, Encoding::UTF_8 + end + + def test_parse + assert_send_type "(::String query) -> ::Hash[::String, String | Array[String]]", + CGI, :parse, 'a=hoge&b=1&c[]=test1&c[]=test2' + end + end end class CGITest < Test::Unit::TestCase @@ -77,51 +81,54 @@ def test_print CGI.new, :print, '' end - def test_http_header - assert_send_type "() -> ::String", - CGI.new, :http_header - assert_send_type "(::String options) -> ::String", - CGI.new, :http_header, 'text/csv' - assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String", - CGI.new, :http_header, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 } - assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String", - CGI.new, :http_header, { type: 'text/csv', nph: false, length: 1024 } - end - - def test_header - assert_send_type "() -> ::String", - CGI.new, :header - assert_send_type "(::String options) -> ::String", - CGI.new, :header, 'text/csv' - assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String", - CGI.new, :header, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 } - assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String", - CGI.new, :header, { type: 'text/csv', nph: false, length: 1024 } - end - - def test_nph? - assert_send_type "() -> ::boolish", - CGI.new, :nph? - end - - def test_out - assert_send_type "() { () -> void } -> void", - CGI.new, :out do '' end - assert_send_type "(::String content_type_string) { () -> String } -> void", - CGI.new, :out, 'text/csv' do '' end - assert_send_type "(::Hash[::String, untyped] header_hash) { () -> String } -> void", - CGI.new, :out, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 } do '' end - assert_send_type "(::Hash[::String | ::Symbol, untyped] header_hash) { () -> String } -> void", - CGI.new, :out, { type: 'text/csv' } do '' end - end - - def test_stdinput - assert_send_type "() -> ::IO", - CGI.new, :stdinput - end - - def test_stdoutput - assert_send_type "() -> ::IO", - CGI.new, :stdoutput + # These methods are removed in Ruby 3.5. + unless RUBY_VERSION >= "3.5" + def test_http_header + assert_send_type "() -> ::String", + CGI.new, :http_header + assert_send_type "(::String options) -> ::String", + CGI.new, :http_header, 'text/csv' + assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String", + CGI.new, :http_header, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 } + assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String", + CGI.new, :http_header, { type: 'text/csv', nph: false, length: 1024 } + end + + def test_header + assert_send_type "() -> ::String", + CGI.new, :header + assert_send_type "(::String options) -> ::String", + CGI.new, :header, 'text/csv' + assert_send_type "(::Hash[::String, untyped] header_hash) -> ::String", + CGI.new, :header, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 } + assert_send_type "(::Hash[::Symbol, untyped] header_hash) -> ::String", + CGI.new, :header, { type: 'text/csv', nph: false, length: 1024 } + end + + def test_nph? + assert_send_type "() -> ::boolish", + CGI.new, :nph? + end + + def test_out + assert_send_type "() { () -> void } -> void", + CGI.new, :out do '' end + assert_send_type "(::String content_type_string) { () -> String } -> void", + CGI.new, :out, 'text/csv' do '' end + assert_send_type "(::Hash[::String, untyped] header_hash) { () -> String } -> void", + CGI.new, :out, { 'type' => 'text/csv', 'nph' => false, 'length' => 1024 } do '' end + assert_send_type "(::Hash[::String | ::Symbol, untyped] header_hash) { () -> String } -> void", + CGI.new, :out, { type: 'text/csv' } do '' end + end + + def test_stdinput + assert_send_type "() -> ::IO", + CGI.new, :stdinput + end + + def test_stdoutput + assert_send_type "() -> ::IO", + CGI.new, :stdoutput + end end end diff --git a/test/stdlib/Pathname_test.rb b/test/stdlib/Pathname_test.rb index 2e9fceec7..a70b86f00 100644 --- a/test/stdlib/Pathname_test.rb +++ b/test/stdlib/Pathname_test.rb @@ -28,6 +28,8 @@ def test_pwd end def test_initialize + omit "Pathname is developing in head" if RUBY_VERSION >= '3.5' + assert_send_type '(String) -> Pathname', Pathname, :new, 'foo' assert_send_type '(ToStr) -> Pathname', @@ -43,6 +45,8 @@ class PathnameInstanceTest < Test::Unit::TestCase testing '::Pathname' def test_plus + omit "Pathname is developing in head" if RUBY_VERSION >= '3.5' + assert_send_type '(Pathname) -> Pathname', Pathname('foo'), :+, Pathname('bar') assert_send_type '(String) -> Pathname', @@ -52,6 +56,8 @@ def test_plus end def test_slash + omit "Pathname is developing in head" if RUBY_VERSION >= '3.5' + assert_send_type '(Pathname) -> Pathname', Pathname('foo'), :/, Pathname('bar') assert_send_type '(String) -> Pathname', @@ -380,6 +386,8 @@ def test_inspect end def test_join + omit "Pathname is developing in head" if RUBY_VERSION >= '3.5' + assert_send_type '() -> Pathname', Pathname('.'), :join assert_send_type '(String) -> Pathname', @@ -602,6 +610,8 @@ def test_relative? end def test_relative_path_from + omit "Pathname is developing in head" if RUBY_VERSION >= '3.5' + assert_send_type '(Pathname) -> Pathname', Pathname('.'), :relative_path_from, Pathname('.') assert_send_type '(String) -> Pathname', @@ -824,6 +834,8 @@ class PathnameKernelTest < Test::Unit::TestCase testing '::Kernel' def test_Pathname + omit "Pathname is developing in head" if RUBY_VERSION >= '3.5' + with_string("Gemfile") do assert_send_type( "(::string) -> ::Pathname", diff --git a/test/stdlib/Ractor_test.rb b/test/stdlib/Ractor_test.rb index f2d0897db..d25dfc965 100644 --- a/test/stdlib/Ractor_test.rb +++ b/test/stdlib/Ractor_test.rb @@ -74,14 +74,18 @@ def test_recv end def test_receive_if + omit "Ractor.receive_if is not implemented" if RUBY_VERSION >= "3.5" + Ractor.current.send 42 assert_send_type "() { (Integer) -> bool } -> Integer", Ractor, :receive_if do |n| n == 42 end end def test_select - r1 = Ractor.new { loop { Ractor.yield 42 } } - r2 = Ractor.new { loop { Ractor.yield 43 } } + omit "Ractor#yield is not implemented" if RUBY_VERSION >= "3.5" + + r1 = Ractor.new {|r| loop { Ractor.yield 42 } } + r2 = Ractor.new {|r| loop { Ractor.yield 43 } } assert_send_type "(Ractor) -> [Ractor, Integer]", Ractor, :select, r1 @@ -115,6 +119,8 @@ def test_store_if_absent end def test_yield + omit "Ractor#yield is not implemented" if RUBY_VERSION >= "3.5" + Ractor.new(Ractor.current) { |r| loop { r.take } } assert_send_type "(Integer) -> untyped", @@ -153,12 +159,16 @@ def test_aset end def test_close_incoming + omit "Ractor#close_incoming is not implemented" if RUBY_VERSION >= "3.5" + r = Ractor.new {} assert_send_type "() -> bool", r, :close_incoming end def test_close_outgoing + omit "Ractor#close_outgoing is not implemented" if RUBY_VERSION >= "3.5" + r = Ractor.new {} assert_send_type "() -> bool", r, :close_outgoing @@ -190,6 +200,8 @@ def test_send end def test_take + omit "Ractor#take is not implemented" if RUBY_VERSION >= "3.5" + r = Ractor.new { 42 } assert_send_type "() -> Integer",