Prevent warnings "the block passed to ... may be ignored"
This commit is contained in:
parent
b6c7226fac
commit
0f3dc2f958
Notes:
git
2024-09-13 07:52:56 +00:00
@ -648,11 +648,11 @@ class Socket < BasicSocket
|
|||||||
# sock.close_write
|
# sock.close_write
|
||||||
# puts sock.read
|
# puts sock.read
|
||||||
# }
|
# }
|
||||||
def self.tcp(host, port, local_host = nil, local_port = nil, connect_timeout: nil, resolv_timeout: nil, fast_fallback: tcp_fast_fallback, &block) # :yield: socket
|
def self.tcp(host, port, local_host = nil, local_port = nil, connect_timeout: nil, resolv_timeout: nil, fast_fallback: tcp_fast_fallback, &) # :yield: socket
|
||||||
sock = if fast_fallback && !(host && ip_address?(host))
|
sock = if fast_fallback && !(host && ip_address?(host))
|
||||||
tcp_with_fast_fallback(host, port, local_host, local_port, connect_timeout:, resolv_timeout:, &block)
|
tcp_with_fast_fallback(host, port, local_host, local_port, connect_timeout:, resolv_timeout:)
|
||||||
else
|
else
|
||||||
tcp_without_fast_fallback(host, port, local_host, local_port, connect_timeout:, resolv_timeout:, &block)
|
tcp_without_fast_fallback(host, port, local_host, local_port, connect_timeout:, resolv_timeout:)
|
||||||
end
|
end
|
||||||
|
|
||||||
if block_given?
|
if block_given?
|
||||||
@ -897,7 +897,7 @@ class Socket < BasicSocket
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.tcp_without_fast_fallback(host, port, local_host, local_port, connect_timeout:, resolv_timeout:, &block)
|
def self.tcp_without_fast_fallback(host, port, local_host, local_port, connect_timeout:, resolv_timeout:)
|
||||||
last_error = nil
|
last_error = nil
|
||||||
ret = nil
|
ret = nil
|
||||||
|
|
||||||
|
@ -3,7 +3,24 @@ require 'test/unit'
|
|||||||
require '-test-/iter'
|
require '-test-/iter'
|
||||||
|
|
||||||
class TestCall < Test::Unit::TestCase
|
class TestCall < Test::Unit::TestCase
|
||||||
def aaa(a, b=100, *rest)
|
# These dummy method definitions prevent warnings "the block passed to 'a'..."
|
||||||
|
def a(&) = nil
|
||||||
|
def b(&) = nil
|
||||||
|
def c(&) = nil
|
||||||
|
def d(&) = nil
|
||||||
|
def e(&) = nil
|
||||||
|
def f(&) = nil
|
||||||
|
def g(&) = nil
|
||||||
|
def h(&) = nil
|
||||||
|
def i(&) = nil
|
||||||
|
def j(&) = nil
|
||||||
|
def k(&) = nil
|
||||||
|
def l(&) = nil
|
||||||
|
def m(&) = nil
|
||||||
|
def n(&) = nil
|
||||||
|
def o(&) = nil
|
||||||
|
|
||||||
|
def aaa(a, b=100, *rest, &)
|
||||||
res = [a, b]
|
res = [a, b]
|
||||||
res += rest if rest
|
res += rest if rest
|
||||||
return res
|
return res
|
||||||
|
@ -175,10 +175,13 @@ class TestIterator < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_block_given
|
def test_block_given
|
||||||
|
verbose_bak, $VERBOSE = $VERBOSE, nil
|
||||||
assert(m1{p 'test'})
|
assert(m1{p 'test'})
|
||||||
assert(m2{p 'test'})
|
assert(m2{p 'test'})
|
||||||
assert(!m1())
|
assert(!m1())
|
||||||
assert(!m2())
|
assert(!m2())
|
||||||
|
ensure
|
||||||
|
$VERBOSE = verbose_bak
|
||||||
end
|
end
|
||||||
|
|
||||||
def m3(var, &block)
|
def m3(var, &block)
|
||||||
@ -308,7 +311,18 @@ class TestIterator < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_ljump
|
def test_ljump
|
||||||
assert_raise(LocalJumpError) {get_block{break}.call}
|
assert_raise(LocalJumpError) {get_block{break}.call}
|
||||||
|
begin
|
||||||
|
verbose_bak, $VERBOSE = $VERBOSE, nil
|
||||||
|
# See the commit https://github.com/ruby/ruby/commit/7d8a415bc2d08a1b5e9d1ea802493b6eeb99c219
|
||||||
|
# This block is not used but this is intentional.
|
||||||
|
# |
|
||||||
|
# +-----------------------------------------------------+
|
||||||
|
# |
|
||||||
|
# vv
|
||||||
assert_raise(LocalJumpError) {proc_call2(get_block{break}){}}
|
assert_raise(LocalJumpError) {proc_call2(get_block{break}){}}
|
||||||
|
ensure
|
||||||
|
$VERBOSE = verbose_bak
|
||||||
|
end
|
||||||
|
|
||||||
# cannot use assert_nothing_raised due to passing block.
|
# cannot use assert_nothing_raised due to passing block.
|
||||||
begin
|
begin
|
||||||
|
@ -207,10 +207,13 @@ class TestProc < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_block_given_method
|
def test_block_given_method
|
||||||
|
verbose_bak, $VERBOSE = $VERBOSE, nil
|
||||||
m = method(:m_block_given?)
|
m = method(:m_block_given?)
|
||||||
assert(!m.call, "without block")
|
assert(!m.call, "without block")
|
||||||
assert(m.call {}, "with block")
|
assert(m.call {}, "with block")
|
||||||
assert(!m.call, "without block second")
|
assert(!m.call, "without block second")
|
||||||
|
ensure
|
||||||
|
$VERBOSE = verbose_bak
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_block_given_method_to_proc
|
def test_block_given_method_to_proc
|
||||||
|
@ -1387,7 +1387,7 @@ eom
|
|||||||
|
|
||||||
def test_block_after_cmdarg_in_paren
|
def test_block_after_cmdarg_in_paren
|
||||||
bug11873 = '[ruby-core:72482] [Bug #11873]'
|
bug11873 = '[ruby-core:72482] [Bug #11873]'
|
||||||
def bug11873.p(*);end;
|
def bug11873.p(*, &);end;
|
||||||
|
|
||||||
assert_raise(LocalJumpError, bug11873) do
|
assert_raise(LocalJumpError, bug11873) do
|
||||||
bug11873.instance_eval do
|
bug11873.instance_eval do
|
||||||
@ -2256,7 +2256,7 @@ eom
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def caller_lineno(*)
|
def caller_lineno(*, &)
|
||||||
caller_locations(1, 1)[0].lineno
|
caller_locations(1, 1)[0].lineno
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user