ruby-changes:41798
From: nobu <ko1@a...>
Date: Fri, 19 Feb 2016 16:47:37 +0900 (JST)
Subject: [ruby-changes:41798] nobu:r53872 (trunk): test/ruby: suppress parser warnings
nobu 2016-02-19 16:48:02 +0900 (Fri, 19 Feb 2016) New Revision: 53872 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53872 Log: test/ruby: suppress parser warnings Modified files: trunk/test/ruby/enc/test_casing_options.rb trunk/test/ruby/enc/test_regex_casefold.rb trunk/test/ruby/test_array.rb trunk/test/ruby/test_backtrace.rb trunk/test/ruby/test_basicinstructions.rb trunk/test/ruby/test_class.rb trunk/test/ruby/test_enum.rb trunk/test/ruby/test_enumerator.rb trunk/test/ruby/test_env.rb trunk/test/ruby/test_eval.rb trunk/test/ruby/test_exception.rb trunk/test/ruby/test_fixnum.rb trunk/test/ruby/test_flip.rb trunk/test/ruby/test_hash.rb trunk/test/ruby/test_io.rb trunk/test/ruby/test_iseq.rb trunk/test/ruby/test_iterator.rb trunk/test/ruby/test_lambda.rb trunk/test/ruby/test_method.rb trunk/test/ruby/test_object.rb trunk/test/ruby/test_parse.rb trunk/test/ruby/test_primitive.rb trunk/test/ruby/test_proc.rb trunk/test/ruby/test_rational.rb trunk/test/ruby/test_rubyoptions.rb trunk/test/ruby/test_settracefunc.rb trunk/test/ruby/test_sprintf.rb trunk/test/ruby/test_super.rb trunk/test/ruby/test_symbol.rb trunk/test/ruby/test_syntax.rb trunk/test/ruby/test_variable.rb Index: test/ruby/test_settracefunc.rb =================================================================== --- test/ruby/test_settracefunc.rb (revision 53871) +++ test/ruby/test_settracefunc.rb (revision 53872) @@ -1359,7 +1359,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L1359 assert_consistent_call_return '[Bug #9959]' do begin method_test_argument_error_on_bmethod(wrong_key: 2) - rescue => e + rescue # ignore end end @@ -1369,7 +1369,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L1369 assert_consistent_call_return '[Bug #9961]' do begin -Numeric.new - rescue => e + rescue # ignore end end @@ -1413,7 +1413,7 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L1413 return if Thread.current != target_th evs << tp.event }.enable{ - a = Bug10724.new + Bug10724.new } assert_equal([:call, :return], evs) Index: test/ruby/test_eval.rb =================================================================== --- test/ruby/test_eval.rb (revision 53871) +++ test/ruby/test_eval.rb (revision 53872) @@ -258,9 +258,9 @@ class TestEval < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_eval.rb#L258 # def make_test_binding - local1 = "local1" + local1 = local1 = "local1" lambda { - local2 = "local2" + local2 = local2 = "local2" return binding }.call end @@ -287,7 +287,7 @@ class TestEval < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_eval.rb#L287 assert_equal('assert(true)', eval("$foo")) assert_equal(true, eval("true")) - i = 5 + i = i = 5 assert(eval("i == 5")) assert_equal(5, eval("i")) assert(eval("defined? i")) @@ -308,6 +308,7 @@ class TestEval < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_eval.rb#L308 module EvTest EVTEST1 = 25 evtest2 = 125 + evtest2 = evtest2 binding end ) @@ -354,7 +355,7 @@ class TestEval < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_eval.rb#L355 p = binding eval "foo11 = 1", p foo22 = 5 - proc{foo11=22}.call + proc{foo11=22;foo11}.call proc{foo22=55}.call # assert_equal(eval("foo11"), eval("foo11", p)) # assert_equal(1, eval("foo11")) Index: test/ruby/test_flip.rb =================================================================== --- test/ruby/test_flip.rb (revision 53871) +++ test/ruby/test_flip.rb (revision 53872) @@ -9,6 +9,7 @@ class TestFlip < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_flip.rb#L9 assert_nothing_raised(NotImplementedError, bug6899) do 2000.times {eval %[(foo..bar) ? 1 : 2]} end + foo = bar end def test_shared_eval Index: test/ruby/test_super.rb =================================================================== --- test/ruby/test_super.rb (revision 53871) +++ test/ruby/test_super.rb (revision 53872) @@ -485,8 +485,8 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_super.rb#L485 bug9740 = '[ruby-core:62017] [Bug #9740]' b.module_eval do - define_method(:foo) do |result| - um.bind(self).call(result) + define_method(:foo) do |res| + um.bind(self).call(res) end end Index: test/ruby/test_iseq.rb =================================================================== --- test/ruby/test_iseq.rb (revision 53871) +++ test/ruby/test_iseq.rb (revision 53872) @@ -89,9 +89,9 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L89 LINE_BEFORE_METHOD = __LINE__ def method_test_line_trace - a = 1 + _a = 1 - b = 2 + _b = 2 end Index: test/ruby/test_symbol.rb =================================================================== --- test/ruby/test_symbol.rb (revision 53871) +++ test/ruby/test_symbol.rb (revision 53872) @@ -356,7 +356,7 @@ class TestSymbol < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L356 def test_symbol_fstr_leak bug10686 = '[ruby-core:67268] [Bug #10686]' - x = 0 + x = x = 0 assert_no_memory_leak([], '200_000.times { |i| i.to_s.to_sym }; GC.start', <<-"end;", bug10686, limit: 1.71, rss: true) 200_000.times { |i| (i + 200_000).to_s.to_sym } end; Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 53871) +++ test/ruby/test_io.rb (revision 53872) @@ -2185,7 +2185,7 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2185 assert_file.exist?(fname) stdin = $stdin.dup begin - assert_nothing_raised(Errno::ENOENT, enc) { + assert_nothing_raised(Errno::ENOENT, "#{bug11320}: #{enc}") { $stdin.reopen(fname, 'r') } ensure @@ -2461,7 +2461,7 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2461 def test_flush_in_finalizer1 require 'tempfile' bug3910 = '[ruby-dev:42341]' - t = Tempfile.open("bug3910") {|t| + tmp = Tempfile.open("bug3910") {|t| path = t.path t.close fds = [] @@ -2481,7 +2481,7 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2481 f.close end } - t.close! + tmp.close! end def test_flush_in_finalizer2 @@ -2959,7 +2959,6 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2959 def test_frozen_autoclose with_pipe do |r,w| - fd = r.fileno assert_equal(true, r.freeze.autoclose?) end end Index: test/ruby/test_primitive.rb =================================================================== --- test/ruby/test_primitive.rb (revision 53871) +++ test/ruby/test_primitive.rb (revision 53872) @@ -82,7 +82,7 @@ class TestRubyPrimitive < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/ruby/test_primitive.rb#L82 end i = 0 while i < 3 - r = A3::B3::C # cache + r = r = A3::B3::C # cache class A3::B3 remove_const :C end Index: test/ruby/test_hash.rb =================================================================== --- test/ruby/test_hash.rb (revision 53871) +++ test/ruby/test_hash.rb (revision 53872) @@ -1330,7 +1330,7 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_hash.rb#L1330 def o.respond_to?(*args) super end - assert_raise(TypeError) {{foo: o}.dig(:foo, :foo)} + assert_raise(TypeError, bug12030) {{foo: o}.dig(:foo, :foo)} end def test_cmp Index: test/ruby/test_syntax.rb =================================================================== --- test/ruby/test_syntax.rb (revision 53871) +++ test/ruby/test_syntax.rb (revision 53872) @@ -205,7 +205,7 @@ class TestSyntax < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L205 def test_keyword_invalid_name bug11663 = '[ruby-core:71356] [Bug #11663]' - o = Object.new + o = o = Object.new assert_syntax_error('def o.foo(arg1?:) end', /arg1\?/, bug11663) assert_syntax_error('def o.foo(arg1?:, arg2:) end', /arg1\?/, bug11663) assert_syntax_error('proc {|arg1?:|}', /arg1\?/, bug11663) @@ -362,7 +362,7 @@ WARN https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L362 def test_cmdarg_kwarg_lvar_clashing_method bug12073 = '[ruby-core:73816] [Bug#12073]' - a = 1 + a = a = 1 assert_valid_syntax("a b: 1") assert_valid_syntax("a = 1; a b: 1", bug12073) end @@ -442,7 +442,7 @@ WARN https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L442 } } assert_warning(/#{w}/){#/3: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m){ - a = 1 + a = a = 1 eval %q{ case 1 when 1, 1 @@ -590,7 +590,7 @@ e" https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L590 end def test_dedented_heredoc_with_interpolated_string - w = "" + w = w = "" result = " \#{mesg} a\n" \ " zy\n" expect = '#{mesg} a'"\n" \ Index: test/ruby/test_env.rb =================================================================== --- test/ruby/test_env.rb (revision 53871) +++ test/ruby/test_env.rb (revision 53872) @@ -53,7 +53,7 @@ class TestEnv < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_env.rb#L53 end assert_raise(TypeError) { - tmp = ENV[1] + ENV[1] } assert_raise(TypeError) { ENV[1] = 'foo' @@ -318,7 +318,7 @@ class TestEnv < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_env.rb#L318 assert_equal("test", k) assert_equal("foo", v) end - assert_invalid_env {|v| ENV.assoc(v)} + assert_invalid_env {|var| ENV.assoc(var)} end def test_has_value2 Index: test/ruby/test_rubyoptions.rb =================================================================== --- test/ruby/test_rubyoptions.rb (revision 53871) +++ test/ruby/test_rubyoptions.rb (revision 53872) @@ -818,14 +818,14 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L818 ["--disable-frozen-string-literal", false], [nil, false], ] - debug = [ + debugs = [ ["--debug-frozen-string-literal", true], ["--debug=frozen-string-literal", true], ["--debug", true], [nil, false], ] opts = ["--disable=gems"] - frozen.product(debug) do |(opt1, freeze), (opt2, debug)| + frozen.product(debugs) do |(opt1, freeze), (opt2, debug)| opt = opts + [opt1, opt2].compact err = !freeze ? [] : debug ? with_debug_pat : wo_debug_pat assert_in_out_err(opt, '"foo" << "bar"', [], err) Index: test/ruby/test_exception.rb =================================================================== --- test/ruby/test_exception.rb (revision 53871) +++ test/ruby/test_exception.rb (revision 53872) @@ -20,8 +20,8 @@ class TestException < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L20 if bad bad = false retry - assert(false) end + assert(!bad) end assert(true) end @@ -626,6 +626,7 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L626 end def test_cause_raised_in_rescue + a = nil e = assert_raise_with_message(RuntimeError, 'b') { begin raise 'a' @@ -633,6 +634,7 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L634 begin raise 'b' rescue => b + assert_same(a, b.cause) begin raise 'c' rescue @@ -641,15 +643,17 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L643 end end } - assert_equal('a', e.cause.message, 'cause should not be overwritten by reraise') + assert_same(a, e.cause, 'cause should not be overwritten by reraise') end def test_cause_at_raised + a = nil e = assert_raise_with_message(RuntimeError, 'b') { begin raise 'a' rescue => a b = RuntimeError.new('b') + assert_nil(b.cause) begin raise 'c' rescue @@ -658,6 +662,7 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L662 end } assert_equal('c', e.cause.message, 'cause should be the exception at raised') + assert_same(a, e.cause.cause) end def test_raise_with_cause @@ -682,6 +687,7 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L687 begin raise 'b' rescue => b + assert_same(a, b.cause) begin raise 'c' rescue @@ -691,6 +697,7 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L697 end } assert_equal('d', e.cause.message, 'cause option should be honored always') + assert_nil(e.cause.cause) end def test_unknown_option @@ -751,7 +758,8 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L758 assert_same(obj, e.receiver) def obj.test(a, b=nil, *c, &d) e = a - 1.times {|f| g = foo} + 1.times {|f| g = foo; g} + e end e = assert_raise(NameError) { obj.test(3) @@ -776,7 +784,7 @@ $stderr = $stdout; raise "\x82\xa0"') do https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L784 assert_equal 0, errs.size err = outs.first.force_encoding('utf-8') assert err.valid_encoding?, 'must be valid encoding' - assert_match /\u3042/, err + assert_match %r/\u3042/, err end end Index: test/ruby/test_class.rb =================================================================== --- test/ruby/test_class.rb (revision 53871) +++ test/ruby/test_class.rb (revision 53872) @@ -371,6 +371,9 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_class.rb#L371 end; } assert_raise_with_message(TypeError, /#{n}/) { + Class.new(c) + } + assert_raise_with_message(TypeError, /#{n}/) { m.module_eval "class #{n} < Class.new; end" } end Index: test/ruby/test_fixnum.rb =================================================================== --- test/ruby/test_fixnum.rb (revision 53871) +++ test/ruby/test_fixnum.rb (revision 53872) @@ -305,7 +305,7 @@ class TestFixnum < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fixnum.rb#L305 big = 1 << 66 assert_eql 1, 1 ** -big , bug5715 assert_eql 1, (-1) ** -big , bug5715 - assert_eql -1, (-1) ** -(big+1) , bug5715 + assert_eql (-1), (-1) ** -(big+1), bug5715 end def test_power_of_0 Index: test/ruby/test_rational.rb =================================================================== --- test/ruby/test_rational.rb (revision 53871) +++ test/ruby/test_rational.rb (revision 53872) @@ -913,7 +913,7 @@ class Rational_Test < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rational.rb#L913 one = Rational( 1, 1) assert_eql one, one ** -big , bug5715 assert_eql one, (-one) ** -big , bug5715 - assert_eql -one, (-one) ** -(big+1) , bug5715 + assert_eql (-one), (-one) ** -(big+1) , bug5715 assert_equal Complex, ((-one) ** Rational(1,3)).class end Index: test/ruby/test_parse.rb =================================================================== --- test/ruby/test_parse.rb (revision 53871) +++ test/ruby/test_parse.rb (revision 53872) @@ -681,14 +681,14 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L681 def test_invalid_char bug10117 = '[ruby-core:64243] [Bug #10117]' invalid_char = /Invalid char `\\x01'/ - x = 1 + x = x = 1 assert_in_out_err(%W"-e \x01x", "", [], invalid_char, bug10117) assert_syntax_error("\x01x", invalid_char, bug10117) assert_equal(nil, eval("\x04x")) end def test_literal_concat - x = "baz" + x = x = "baz" assert_equal("foobarbaz", eval('"foo" "bar#{x}"')) end @@ -759,7 +759,7 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L759 $VERBOSE = true stderr = $stderr $stderr = StringIO.new("") - x = 1 + x = x = 1 assert_nil eval("x; nil") assert_nil eval("1+1; nil") assert_nil eval("TestParse; nil") @@ -825,7 +825,7 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L825 end assert_nothing_raised do - x = "bar" + x = x = "bar" eval <<-END, nil, __FILE__, __LINE__+1 :"foo#{"x"}baz" ? 1 : 2 END Index: test/ruby/test_backtrace.rb =================================================================== --- test/ruby/test_backtrace.rb (revision 53871) +++ test/ruby/test_backtrace.rb (revision 53872) @@ -198,7 +198,7 @@ class TestBacktrace < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ruby/test_backtrace.rb#L198 def test_caller_locations_base_label assert_equal("#{__method__}", caller_locations(0, 1)[0].base_label) - loc, = tap {|loc| break caller_locations(0, 1)} + loc, = tap {break caller_locations(0, 1)} assert_equal("#{__method__}", loc.base_label) begin raise @@ -209,7 +209,7 @@ class TestBacktrace < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ruby/test_backtrace.rb#L209 def test_caller_locations_label assert_equal("#{__method__}", caller_locations(0, 1)[0].label) - loc, = tap {|loc| break caller_locations(0, 1)} + loc, = tap {break caller_locations(0, 1)} assert_equal("block in #{__method__}", loc.label) begin raise Index: test/ruby/test_lambda.rb =================================================================== --- test/ruby/test_lambda.rb (revision 53871) +++ test/ruby/test_lambda.rb (revision 53872) @@ -61,9 +61,9 @@ class TestLambdaParameters < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_lambda.rb#L61 assert_equal(nil, ->(&b){ b }.call) foo { puts "bogus block " } assert_equal(1, ->(&b){ b.call }.call { 1 }) - b = nil - assert_equal(1, ->(&b){ b.call }.call { 1 }) - assert_nil(b) + _b = nil + assert_equal(1, ->(&_b){ _b.call }.call { 1 }) + assert_nil(_b) end def test_call_block_from_lambda Index: test/ruby/test_enumerator.rb =================================================================== --- test/ruby/test_enumerator.rb (revision 53871) +++ test/ruby/test_enumerator.rb (revision 53872) @@ -103,6 +103,7 @@ class TestEnumerator < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enumerator.rb#L103 1.times do foo = [1,2,3].to_enum GC.start + foo end GC.start end Index: test/ruby/test_iterator.rb =================================================================== --- test/ruby/test_iterator.rb (revision 53871) +++ test/ruby/test_iterator.rb (revision 53872) @@ -109,7 +109,7 @@ class TestIterator < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iterator.rb#L109 def test_append_method_to_built_in_class x = [[1,2],[3,4],[5,6]] - assert_equal(x.iter_test1{|x|x}, x.iter_test2{|x|x}) + assert_equal(x.iter_test1{|e|e}, x.iter_test2{|e|e}) end class IterTest Index: test/ruby/test_basicinstructions.rb =================================================================== --- test/ruby/test_basicinstructions.rb (revision 53871) +++ test/ruby/test_basicinstructions.rb (revision 53872) @@ -211,9 +211,9 @@ class TestBasicInstructions < Test::Unit https://github.com/ruby/ruby/blob/trunk/test/ruby/test_basicinstructions.rb#L211 assert_raise(NameError) { a } assert_raise(NameError) { b } assert_raise(NameError) { c } - a = "NOT OK" - b = "NOT OK" - c = "NOT OK" + a = a = "NOT OK" + b = b = "NOT OK" + c = c = "NOT OK" end class Const @@ -611,8 +611,8 @@ class TestBasicInstructions < Test::Unit https://github.com/ruby/ruby/blob/trunk/test/ruby/test_basicinstructions.rb#L611 x = OP.new assert_equal 42, x.foo = 42, bug7773 assert_equal 42, x.foo, bug7773 - assert_equal -6, x.send(:foo=, -6), bug7773 - assert_equal -6, x.foo, bug7773 + assert_equal (-6), x.send(:foo=, -6), bug7773 + assert_equal (-6), x.foo, bug7773 assert_equal :Bug1996, x.send(:x=, :case_when_sette (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/