1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Suppress unused variable warnings

This commit is contained in:
Nobuyoshi Nakada 2019-06-30 09:34:41 +09:00
parent 84837e6d16
commit 409b0ec4c3
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
16 changed files with 25 additions and 8 deletions

View file

@ -530,6 +530,7 @@ class FTPTest < Test::Unit::TestCase
sock.print("553 Requested action not taken.\r\n")
commands.push(sock.gets)
sock.print("200 Switching to Binary mode.\r\n")
[host, port]
}
begin
begin
@ -711,6 +712,7 @@ class FTPTest < Test::Unit::TestCase
host, port = process_port_or_eprt(sock, line)
commands.push(sock.gets)
sock.print("550 Requested action not taken.\r\n")
[host, port]
}
begin
begin
@ -937,6 +939,7 @@ class FTPTest < Test::Unit::TestCase
host, port = process_port_or_eprt(sock, line)
commands.push(sock.gets)
sock.print("452 Requested file action aborted.\r\n")
[host, port]
}
begin
begin

View file

@ -106,7 +106,7 @@ class TestObjSpace < Test::Unit::TestCase
end
def test_memsize_of_iseq
iseqw = RubyVM::InstructionSequence.compile('def a; a = :b; end')
iseqw = RubyVM::InstructionSequence.compile('def a; a = :b; a; end')
base_obj_size = ObjectSpace.memsize_of(Object.new)
assert_operator(ObjectSpace.memsize_of(iseqw), :>, base_obj_size)
end

View file

@ -205,9 +205,9 @@ class TestAst < Test::Unit::TestCase
end
def test_scope_local_variables
node = RubyVM::AbstractSyntaxTree.parse("x = 0")
node = RubyVM::AbstractSyntaxTree.parse("_x = 0")
lv, _, body = *node.children
assert_equal([:x], lv)
assert_equal([:_x], lv)
assert_equal(:LASGN, body.type)
end

View file

@ -345,6 +345,7 @@ class TestEval < Test::Unit::TestCase
# assert_equal(1, eval("foo11"))
assert_equal(eval("foo22"), eval("foo22", p))
assert_equal(55, eval("foo22"))
assert_equal(55, foo22)
}.call
end

View file

@ -29,7 +29,7 @@ class TestFlip < Test::Unit::TestCase
assert_nothing_raised(NotImplementedError, bug6899) do
2000.times {eval %[(foo..bar) ? 1 : 2]}
end
foo = bar
[foo, bar]
end
def test_shared_eval
@ -38,6 +38,7 @@ class TestFlip < Test::Unit::TestCase
eval("vs.select {|n| if n==2..n==16 then 1 end}")
v = eval("vs.select {|n| if n==3..n==6 then 1 end}")
assert_equal([*3..6], v, bug7671)
vs
end
def test_shared_thread

View file

@ -17,6 +17,7 @@ class TestGc < Test::Unit::TestCase
1.upto(10000) {
tmp = [0,1,2,3,4,5,6,7,8,9]
}
tmp
end
l=nil
100000.times {

View file

@ -119,6 +119,8 @@ class TestGCCompact < Test::Unit::TestCase
collisions = GC.stat(:object_id_collisions)
skip "couldn't get objects to collide" if collisions == 0
assert_operator collisions, :>, 0
ids.clear
new_tenants.clear
end
def test_complex_hash_keys

View file

@ -452,7 +452,7 @@ class TestISeq < Test::Unit::TestCase
class B
2.times {
def self.foo
a = 'good day'
_a = 'good day'
raise
rescue
'dear reader'

View file

@ -187,7 +187,7 @@ class TestRubyLiteral < Test::Unit::TestCase
if defined?(RubyVM::InstructionSequence.compile_option) and
RubyVM::InstructionSequence.compile_option.key?(:debug_frozen_string_literal)
def test_debug_frozen_string
src = 'n = 1; "foo#{n ? "-#{n}" : ""}"'; f = "test.rb"; n = 1
src = 'n = 1; _="foo#{n ? "-#{n}" : ""}"'; f = "test.rb"; n = 1
opt = {frozen_string_literal: true, debug_frozen_string_literal: true}
str = RubyVM::InstructionSequence.compile(src, f, f, n, opt).eval
assert_equal("foo-1", str)

View file

@ -615,6 +615,8 @@ class TestM17N < Test::Unit::TestCase
r1 = Regexp.new('\xa1'.force_encoding("ascii-8bit"))
r2 = eval('/\xa1#{r1}/'.force_encoding('ascii-8bit'))
assert_equal(Encoding::ASCII_8BIT, r2.encoding)
[r1, r2]
end
def test_regexp_named_class

View file

@ -751,6 +751,7 @@ class TestRubyOptimization < Test::Unit::TestCase
h = {}
assert_equal(bug, eval('{ok: 42, **h}; bug'))
assert_equal(:ok, eval('{ok: bug = :ok, **h}; bug'))
assert_empty(h)
end
def test_overwritten_blockparam

View file

@ -481,6 +481,7 @@ class TestParse < Test::Unit::TestCase
t[42, &blk] ||= t.dummy 42 # command_asgn test
END
assert_equal([:aref, :aset], a)
blk
end
def test_backquote
@ -1148,7 +1149,7 @@ x = __ENCODING__
end
o.instance_eval {i (-1.3).abs}
assert_equal(1.3, o.x)
o.instance_eval {i = 0; i (-1.3).abs}
o.instance_eval {i = 0; i (-1.3).abs; i}
assert_equal(1.3, o.x)
end
@ -1157,6 +1158,7 @@ x = __ENCODING__
$VERBOSE = true
x = 1
eval("if false; 0 < x < 2; end")
x
end
end

View file

@ -1302,7 +1302,7 @@ class TestProc < Test::Unit::TestCase
def test_local_variables
b = get_binding
assert_equal(%i'if case when begin end a', b.local_variables)
a = tap {|;x, y| x = y; break binding.local_variables}
a = tap {|;x, y| x = y = x; break binding.local_variables}
assert_equal(%i[a b x y], a.sort)
end

View file

@ -1562,6 +1562,7 @@ class TestRefinement < Test::Unit::TestCase
undef :foo
end
end
ext
end
def test_call_refined_method_in_duplicate_module
@ -2291,6 +2292,7 @@ class TestRefinement < Test::Unit::TestCase
end
end
assert_equal("[C[A[B]]]", c.new.foo, '[ruby-dev:50390] [Bug #14232]')
d
end
private

View file

@ -736,6 +736,7 @@ class TestSocket < Test::Unit::TestCase
ret, addr, rflags = s1.recvmsg(10, 0)
assert_equal "b" * 10, ret
assert_equal Socket::MSG_TRUNC, rflags & Socket::MSG_TRUNC if !rflags.nil?
addr
ensure
s1.close
s2.close

View file

@ -320,5 +320,6 @@ class TestOpen3 < Test::Unit::TestCase
command = [RUBY, '-e', 'puts "test_integer_and_symbol_key"']
out, status = Open3.capture2(*command, :chdir => '.', 2 => IO::NULL)
assert_equal("test_integer_and_symbol_key\n", out)
assert_predicate(status, :success?)
end
end