From 409b0ec4c3c4878c0ba164d1303de67787157808 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 30 Jun 2019 09:34:41 +0900 Subject: Suppress unused variable warnings --- test/net/ftp/test_ftp.rb | 3 +++ test/objspace/test_objspace.rb | 2 +- test/ruby/test_ast.rb | 4 ++-- test/ruby/test_eval.rb | 1 + test/ruby/test_flip.rb | 3 ++- test/ruby/test_gc.rb | 1 + test/ruby/test_gc_compact.rb | 2 ++ test/ruby/test_iseq.rb | 2 +- test/ruby/test_literal.rb | 2 +- test/ruby/test_m17n.rb | 2 ++ test/ruby/test_optimization.rb | 1 + test/ruby/test_parse.rb | 4 +++- test/ruby/test_proc.rb | 2 +- test/ruby/test_refinement.rb | 2 ++ test/socket/test_socket.rb | 1 + test/test_open3.rb | 1 + 16 files changed, 25 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb index a5219644bb..39f1220dbb 100644 --- a/test/net/ftp/test_ftp.rb +++ b/test/net/ftp/test_ftp.rb @@ -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 diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 833b372105..336b30f75a 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -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 diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index e782653755..9598aa7553 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -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 diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb index 8900b4f165..49bb3305e4 100644 --- a/test/ruby/test_eval.rb +++ b/test/ruby/test_eval.rb @@ -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 diff --git a/test/ruby/test_flip.rb b/test/ruby/test_flip.rb index 8ea6416bdb..9156be0553 100644 --- a/test/ruby/test_flip.rb +++ b/test/ruby/test_flip.rb @@ -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 diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index b5fb532c72..c63ef51bd3 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -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 { diff --git a/test/ruby/test_gc_compact.rb b/test/ruby/test_gc_compact.rb index 94acbb3a4d..4228ceeb1d 100644 --- a/test/ruby/test_gc_compact.rb +++ b/test/ruby/test_gc_compact.rb @@ -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 diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index ac3f9a355d..f10a6659ba 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -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' diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index 3f5acde3df..3f87f860b1 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -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) diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 75daf61376..953f6417b0 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -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 diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index 5f360779cf..1a7d62817f 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -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 diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index b63f170981..287c8358a0 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -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 diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 17def93362..bc270115df 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -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 diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 59029de890..afb4784d00 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -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 diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb index e07c1d633f..6cbf3edca8 100644 --- a/test/socket/test_socket.rb +++ b/test/socket/test_socket.rb @@ -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 diff --git a/test/test_open3.rb b/test/test_open3.rb index 848f70b07d..24bd08e597 100644 --- a/test/test_open3.rb +++ b/test/test_open3.rb @@ -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 -- cgit v1.2.3