From a967f738c83b960f23f5b04403a17ca37f049e25 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 25 Jan 2010 22:08:29 +0000 Subject: * lib/matrix.rb: suppress warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 +++ lib/mathn.rb | 4 +++ lib/matrix.rb | 54 ++++++++++++++++++++-------------------- test/fileutils/test_dryrun.rb | 2 +- test/fileutils/test_fileutils.rb | 2 +- test/ruby/test_case.rb | 4 +-- test/ruby/test_rubyoptions.rb | 6 ++++- test/ruby/test_transcode.rb | 2 +- test/socket/test_unix.rb | 2 +- 9 files changed, 46 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 196f843d62..bf81a4faa9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Jan 26 07:06:05 2010 Tanaka Akira + + * lib/matrix.rb: suppress warnings. + Tue Jan 26 03:16:45 2010 Yusuke Endoh * cont.c, vm_core.h, eval.c: because rb_protect must not be jumped by diff --git a/lib/mathn.rb b/lib/mathn.rb index f834893f3f..716b48602d 100644 --- a/lib/mathn.rb +++ b/lib/mathn.rb @@ -54,6 +54,7 @@ class Bignum end class Rational + remove_method :** def ** (other) if other.kind_of?(Rational) other2 = other @@ -188,6 +189,9 @@ module Math end end + class << self + remove_method(:sqrt) + end module_function :sqrt module_function :rsqrt end diff --git a/lib/matrix.rb b/lib/matrix.rb index 222bf4b698..c7ae64923f 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -603,16 +603,16 @@ class Matrix end akk = a[k][k] - size.times do |i| - next if i == k - q = a[i][k].quo(akk) - a[i][k] = 0 + size.times do |ii| + next if ii == k + q = a[ii][k].quo(akk) + a[ii][k] = 0 (k + 1 ... size).each do |j| - a[i][j] -= a[k][j] * q + a[ii][j] -= a[k][j] * q end size.times do |j| - @rows[i][j] -= @rows[k][j] * q + @rows[ii][j] -= @rows[k][j] * q end end @@ -678,19 +678,19 @@ class Matrix det = 1 size.times do |k| if (akk = a[k][k]) == 0 - i = (k+1 ... size).find {|i| - a[i][k] != 0 + i = (k+1 ... size).find {|ii| + a[ii][k] != 0 } - return 0 if i.nil? - a[i], a[k] = a[k], a[i] + return 0 if ii.nil? + a[ii], a[k] = a[k], a[ii] akk = a[k][k] det *= -1 end - (k + 1 ... size).each do |i| - q = a[i][k].quo(akk) + (k + 1 ... size).each do |ii| + q = a[ii][k].quo(akk) (k + 1 ... size).each do |j| - a[i][j] -= a[k][j] * q + a[ii][j] -= a[k][j] * q end end det *= akk @@ -718,21 +718,21 @@ class Matrix det = 1 size.times do |k| if a[k][k].zero? - i = (k+1 ... size).find {|i| - a[i][k] != 0 + i = (k+1 ... size).find {|ii| + a[ii][k] != 0 } return 0 if i.nil? a[i], a[k] = a[k], a[i] det *= -1 end - (k + 1 ... size).each do |i| - q = a[i][k].quo(a[k][k]) + (k + 1 ... size).each do |ii| + q = a[ii][k].quo(a[k][k]) (k ... size).each do |j| - a[i][j] -= a[k][j] * q + a[ii][j] -= a[k][j] * q end - unless a[i][k].zero? - a[i], a[k] = a[k], a[i] + unless a[ii][k].zero? + a[ii], a[k] = a[k], a[ii] det *= -1 redo end @@ -764,15 +764,15 @@ class Matrix rank = 0 a_column_size.times do |k| if (akk = a[k][k]) == 0 - i = (k+1 ... a_row_size).find {|i| - a[i][k] != 0 + i = (k+1 ... a_row_size).find {|ii| + a[ii][k] != 0 } if i a[i], a[k] = a[k], a[i] akk = a[k][k] else - i = (k+1 ... a_column_size).find {|i| - a[k][i] != 0 + i = (k+1 ... a_column_size).find {|ii| + a[k][ii] != 0 } next if i.nil? (k ... a_column_size).each do |j| @@ -782,10 +782,10 @@ class Matrix end end - (k + 1 ... a_row_size).each do |i| - q = a[i][k].quo(akk) + (k + 1 ... a_row_size).each do |ii| + q = a[ii][k].quo(akk) (k + 1... a_column_size).each do |j| - a[i][j] -= a[k][j] * q + a[ii][j] -= a[k][j] * q end end rank += 1 diff --git a/test/fileutils/test_dryrun.rb b/test/fileutils/test_dryrun.rb index 2fdd65d2f6..e5ca25c9b4 100644 --- a/test/fileutils/test_dryrun.rb +++ b/test/fileutils/test_dryrun.rb @@ -15,7 +15,7 @@ class TestFileUtilsDryRun < Test::Unit::TestCase "FileUtils::DryRun.#{m} not public" end FileUtils::METHODS.each do |m| - assert_equal true, respond_to?(m, true) + assert_equal true, respond_to?(m, true), "FileUtils::DryRun\##{m} is not defined" assert_equal true, FileUtils::DryRun.private_method_defined?(m), "FileUtils::DryRun\##{m} is not private" diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index dfbeec5b20..048d255c60 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -726,7 +726,7 @@ class TestFileUtils Dir.rmdir "tmp-first-line\ntmp-second-line" end if lf_in_path_allowed? - def test_mkdir_pathname + def test_mkdir_pathname # pathname assert_nothing_raised { mkdir Pathname.new('tmp/tmpdirtmp') diff --git a/test/ruby/test_case.rb b/test/ruby/test_case.rb index f9f16d55a2..c4938ee55a 100644 --- a/test/ruby/test_case.rb +++ b/test/ruby/test_case.rb @@ -57,11 +57,11 @@ class TestCase < Test::Unit::TestCase def test_deoptimization assert_in_out_err(['-e', <<-EOS], '', %w[42], []) - class Symbol; def ===(o); p 42; true; end; end; case :foo; when :foo; end + class Symbol; undef ===; def ===(o); p 42; true; end; end; case :foo; when :foo; end EOS assert_in_out_err(['-e', <<-EOS], '', %w[42], []) - class Fixnum; def ===(o); p 42; true; end; end; case 1; when 1; end + class Fixnum; undef ===; def ===(o); p 42; true; end; end; case 1; when 1; end EOS end end diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index f1897c5d0b..771d7cdfff 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -38,10 +38,14 @@ class TestRubyOptions < Test::Unit::TestCase end def test_warning + save_rubyopt = ENV['RUBYOPT'] + ENV['RUBYOPT'] = nil assert_in_out_err(%w(-W0 -e) + ['p $-W'], "", %w(0), []) assert_in_out_err(%w(-W1 -e) + ['p $-W'], "", %w(1), []) assert_in_out_err(%w(-Wx -e) + ['p $-W'], "", %w(1), []) assert_in_out_err(%w(-W -e) + ['p $-W'], "", %w(2), []) + ensure + ENV['RUBYOPT'] = save_rubyopt end def test_safe_level @@ -271,7 +275,7 @@ class TestRubyOptions < Test::Unit::TestCase def test_sflag assert_in_out_err(%w(- -abc -def=foo -ghi-jkl -- -xyz), - "#!ruby -s\np [$abc, $def, $ghi_jkl, $xyz]\n", + "#!ruby -s\np [$abc, $def, $ghi_jkl, defined?($xyz)]\n", ['[true, "foo", true, nil]'], []) assert_in_out_err(%w(- -#), "#!ruby -s\n", [], diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb index 9d4305876f..bca51ba251 100644 --- a/test/ruby/test_transcode.rb +++ b/test/ruby/test_transcode.rb @@ -909,7 +909,7 @@ class TestTranscode < Test::Unit::TestCase assert_raise(Encoding::UndefinedConversionError) { "\xFF".encode("utf-8", 'TIS-620') } end - def test_CP850 + def test_CP850 check_both_ways("\u00C7", "\x80", 'CP850') # Ç check_both_ways("\u00C5", "\x8F", 'CP850') # Å check_both_ways("\u00C9", "\x90", 'CP850') # É diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb index e18f5d6e95..d8cf7139e9 100644 --- a/test/socket/test_unix.rb +++ b/test/socket/test_unix.rb @@ -43,7 +43,7 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase UNIXSocket.pair {|s1, s2| begin ret = s1.sendmsg("\0", 0, nil, [Socket::SOL_SOCKET, Socket::SCM_RIGHTS, - send_io_ary.map {|io| io.fileno }.pack("i!*")]) + send_io_ary.map {|io2| io2.fileno }.pack("i!*")]) rescue NotImplementedError return end -- cgit v1.2.3