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

supress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-01-25 23:12:50 +00:00
parent a967f738c8
commit 37679ee584
20 changed files with 77 additions and 77 deletions

View file

@ -23,35 +23,35 @@ class TestERB < Test::Unit::TestCase
def test_generate_magic_comment
erb = ERB.new("hello")
assert_match /#coding:UTF-8/, erb.src
assert_match(/#coding:UTF-8/, erb.src)
erb = ERB.new("hello".force_encoding("EUC-JP"))
assert_match /#coding:EUC-JP/, erb.src
assert_match(/#coding:EUC-JP/, erb.src)
erb = ERB.new("hello".force_encoding("ISO-8859-9"))
assert_match /#coding:ISO-8859-9/, erb.src
assert_match(/#coding:ISO-8859-9/, erb.src)
end
def test_literal_encoding
erb = ERB.new("literal encoding is <%= 'hello'.encoding %>")
assert_match /literal encoding is UTF-8/, erb.result
assert_match(/literal encoding is UTF-8/, erb.result)
erb = ERB.new("literal encoding is <%= 'こんにちは'.encoding %>".encode("EUC-JP"))
assert_match /literal encoding is EUC-JP/, erb.result
assert_match(/literal encoding is EUC-JP/, erb.result)
erb = ERB.new("literal encoding is <%= '\xC4\xE3\xBA\xC3'.encoding %>".force_encoding("EUC-CN"))
assert_match /literal encoding is GB2312/, erb.result
assert_match(/literal encoding is GB2312/, erb.result)
end
def test___ENCODING__
erb = ERB.new("__ENCODING__ is <%= __ENCODING__ %>")
assert_match /__ENCODING__ is UTF-8/, erb.result
assert_match(/__ENCODING__ is UTF-8/, erb.result)
erb = ERB.new("__ENCODING__ is <%= __ENCODING__ %>".force_encoding("EUC-JP"))
assert_match /__ENCODING__ is EUC-JP/, erb.result
assert_match(/__ENCODING__ is EUC-JP/, erb.result)
erb = ERB.new("__ENCODING__ is <%= __ENCODING__ %>".force_encoding("Big5"))
assert_match /__ENCODING__ is Big5/, erb.result
assert_match(/__ENCODING__ is Big5/, erb.result)
end
def test_recognize_magic_comment
@ -59,35 +59,35 @@ class TestERB < Test::Unit::TestCase
<%# -*- coding: EUC-KR -*- %>
EOS
assert_match /#coding:EUC-KR/, erb.src
assert_match(/#coding:EUC-KR/, erb.src)
assert_equal Encoding::EUC_KR, erb.result.encoding
erb = ERB.new(<<-EOS.encode("EUC-KR").force_encoding("ASCII-8BIT"))
<%#-*- coding: EUC-KR -*-%>
EOS
assert_match /#coding:EUC-KR/, erb.src
assert_match(/#coding:EUC-KR/, erb.src)
assert_equal Encoding::EUC_KR, erb.result.encoding
erb = ERB.new(<<-EOS.encode("EUC-KR").force_encoding("ASCII-8BIT"))
<%# vim: tabsize=8 encoding=EUC-KR shiftwidth=2 expandtab %>
EOS
assert_match /#coding:EUC-KR/, erb.src
assert_match(/#coding:EUC-KR/, erb.src)
assert_equal Encoding::EUC_KR, erb.result.encoding
erb = ERB.new(<<-EOS.encode("EUC-KR").force_encoding("ASCII-8BIT"))
<%#coding:EUC-KR %>
EOS
assert_match /#coding:EUC-KR/, erb.src
assert_match(/#coding:EUC-KR/, erb.src)
assert_equal Encoding::EUC_KR, erb.result.encoding
erb = ERB.new(<<-EOS.encode("EUC-KR").force_encoding("EUC-JP"))
<%#coding:EUC-KR %>
EOS
assert_match /#coding:EUC-KR/, erb.src
assert_match(/#coding:EUC-KR/, erb.src)
assert_equal Encoding::EUC_KR, erb.result.encoding
end
@ -105,8 +105,8 @@ __ENCODING__ is <%= __ENCODING__ %>
result = obj.m_from_magic_comment
assert_equal Encoding::EUC_JP, result.encoding
assert_match /literal encoding is EUC-JP/, result
assert_match /__ENCODING__ is EUC-JP/, result
assert_match(/literal encoding is EUC-JP/, result)
assert_match(/__ENCODING__ is EUC-JP/, result)
erb = ERB.new(<<-EOS.encode("EUC-KR"))
literal encoding is <%= '안녕하세요'.encoding %>
@ -115,8 +115,8 @@ EOS
erb.def_method(M, :m_from_eval_encoding)
result = obj.m_from_eval_encoding
assert_equal Encoding::EUC_KR, result.encoding
assert_match /literal encoding is EUC-KR/, result
assert_match /__ENCODING__ is EUC-KR/, result
assert_match(/literal encoding is EUC-KR/, result)
assert_match(/__ENCODING__ is EUC-KR/, result)
end
end

View file

@ -571,7 +571,7 @@ class OpenSSL::TestSSL < Test::Unit::TestCase
ctx_proc = Proc.new do |ctx, ssl|
foo_ctx = ctx.dup
ctx.servername_cb = Proc.new do |ssl, hostname|
ctx.servername_cb = Proc.new do |ssl2, hostname|
case hostname
when 'foo.example.com'
foo_ctx

View file

@ -366,11 +366,11 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
thru_mlhs_add_star = false
tree = parse("a, *b = 1, 2", :on_mlhs_add_star) {thru_mlhs_add_star = true}
assert_equal true, thru_mlhs_add_star
assert_match /mlhs_add_star\(mlhs_add\(mlhs_new\(\),a\),b\)/, tree
assert_match(/mlhs_add_star\(mlhs_add\(mlhs_new\(\),a\),b\)/, tree)
thru_mlhs_add_star = false
tree = parse("a, *b, c = 1, 2", :on_mlhs_add_star) {thru_mlhs_add_star = true}
assert_equal true, thru_mlhs_add_star
assert_match /mlhs_add\(mlhs_add_star\(mlhs_add\(mlhs_new\(\),a\),b\),mlhs_add\(mlhs_new\(\),c\)\)/, tree, bug2232
assert_match(/mlhs_add\(mlhs_add_star\(mlhs_add\(mlhs_new\(\),a\),b\),mlhs_add\(mlhs_new\(\),c\)\)/, tree, bug2232)
end
def test_mlhs_new

View file

@ -64,7 +64,7 @@ class TestBasicInstructions < Test::Unit::TestCase
end
def test_regexp
assert_equal /test/, /test/
assert_equal(/test/, /test/)
assert_equal 'test', /test/.source
assert_equal 'TEST', /TEST/.source
assert_equal true, !!(/test/ =~ 'test')
@ -76,9 +76,9 @@ class TestBasicInstructions < Test::Unit::TestCase
assert_equal true, !!(re =~ 'test')
assert_equal false, !!(re =~ 'does not match')
assert_equal /x#{1+1}x/, /x#{1+1}x/
assert_equal(/x#{1+1}x/, /x#{1+1}x/)
s = "OK"
assert_equal /x#{s}x/, /x#{s}x/
assert_equal(/x#{s}x/, /x#{s}x/)
assert_equal true, !!(/x#{s}x/ =~ "xOKx")
assert_equal false, !!(/x#{s}x/ =~ "does not match")

View file

@ -80,8 +80,8 @@ EOW
'-e', 'raise %[SomethingElse]']) {|f|
f.read
}
assert_match /SomethingBad/, out, "[ruby-core:9675]"
assert_match /SomethingElse/, out, "[ruby-core:9675]"
assert_match(/SomethingBad/, out, "[ruby-core:9675]")
assert_match(/SomethingElse/, out, "[ruby-core:9675]")
end
def test_should_propagate_exit_code
@ -99,7 +99,7 @@ EOW
'-e', 'at_exit{Process.kill(:INT, $$); loop{}}']) {|f|
f.read
}
assert_match /Interrupt$/, out
assert_match(/Interrupt$/, out)
Process.kill(0, 0) rescue return # check if signal works
assert_nil $?.exitstatus
assert_equal Signal.list["INT"], $?.termsig

View file

@ -143,27 +143,27 @@ class TestEnumerable < Test::Unit::TestCase
def test_min
assert_equal(1, @obj.min)
assert_equal(3, @obj.min {|a,b| b <=> a })
a = %w(albatross dog horse)
assert_equal("albatross", a.min)
assert_equal("dog", a.min {|a,b| a.length <=> b.length })
ary = %w(albatross dog horse)
assert_equal("albatross", ary.min)
assert_equal("dog", ary.min {|a,b| a.length <=> b.length })
assert_equal(1, [3,2,1].min)
end
def test_max
assert_equal(3, @obj.max)
assert_equal(1, @obj.max {|a,b| b <=> a })
a = %w(albatross dog horse)
assert_equal("horse", a.max)
assert_equal("albatross", a.max {|a,b| a.length <=> b.length })
ary = %w(albatross dog horse)
assert_equal("horse", ary.max)
assert_equal("albatross", ary.max {|a,b| a.length <=> b.length })
assert_equal(1, [3,2,1].max{|a,b| b <=> a })
end
def test_minmax
assert_equal([1, 3], @obj.minmax)
assert_equal([3, 1], @obj.minmax {|a,b| b <=> a })
a = %w(albatross dog horse)
assert_equal(["albatross", "horse"], a.minmax)
assert_equal(["dog", "albatross"], a.minmax {|a,b| a.length <=> b.length })
ary = %w(albatross dog horse)
assert_equal(["albatross", "horse"], ary.minmax)
assert_equal(["dog", "albatross"], ary.minmax {|a,b| a.length <=> b.length })
assert_equal([1, 3], [2,3,1].minmax)
assert_equal([3, 1], [2,3,1].minmax {|a,b| b <=> a })
assert_equal([1, 3], [2,2,3,3,1,1].minmax)

View file

@ -140,13 +140,13 @@ class TestFile < Test::Unit::TestCase
end
def test_s_chown
assert_nothing_raised { File.chown -1, -1 }
assert_nothing_raised { File.chown(-1, -1) }
assert_nothing_raised { File.chown nil, nil }
end
def test_chown
assert_nothing_raised {
File.open(__FILE__) {|f| f.chown -1, -1 }
File.open(__FILE__) {|f| f.chown(-1, -1) }
}
assert_nothing_raised("[ruby-dev:27140]") {
File.open(__FILE__) {|f| f.chown nil, nil }

View file

@ -492,7 +492,7 @@ class TestFileExhaustive < Test::Unit::TestCase
f.close
make_file("foo", @file)
assert_raise(IOError) { File.open(@file) {|f| f.truncate(0)} }
assert_raise(IOError) { File.open(@file) {|ff| ff.truncate(0)} }
rescue NotImplementedError
end

View file

@ -51,7 +51,7 @@ class TestHash < Test::Unit::TestCase
assert_equal([], x[22])
assert_not_same(x[22], x[22])
x = Hash.new{|h,k| z = k; h[k] = k*2}
x = Hash.new{|h,kk| z = kk; h[kk] = kk*2}
z = 0
assert_equal(44, x[22])
assert_equal(22, z)
@ -703,14 +703,14 @@ class TestHash < Test::Unit::TestCase
end
def test_default_proc
h = Hash.new {|h, k| h + k + "baz" }
h = Hash.new {|hh, k| hh + k + "baz" }
assert_equal("foobarbaz", h.default_proc.call("foo", "bar"))
h = {}
assert_nil(h.default_proc)
end
def test_shift2
h = Hash.new {|h, k| :foo }
h = Hash.new {|hh, k| :foo }
h[1] = 2
assert_equal([1, 2], h.shift)
assert_equal(:foo, h.shift)

View file

@ -150,10 +150,10 @@ class TestInteger < Test::Unit::TestCase
1.upto(0) {|x| a << x }
assert_equal([], a)
x = 2**30 - 1
y = 2**30 - 1
a = []
x.upto(x+2) {|x| a << x }
assert_equal([x, x+1, x+2], a)
y.upto(y+2) {|x| a << x }
assert_equal([y, y+1, y+2], a)
end
def test_downto
@ -165,10 +165,10 @@ class TestInteger < Test::Unit::TestCase
1.downto(2) {|x| a << x }
assert_equal([], a)
x = -(2**30)
y = -(2**30)
a = []
x.downto(x-2) {|x| a << x }
assert_equal([x, x-1, x-2], a)
y.downto(y-2) {|x| a << x }
assert_equal([y, y-1, y-2], a)
end
def test_times

View file

@ -5,8 +5,8 @@ class Array
collect{|e| [e, yield(e)]}.sort{|a,b|a[1]<=>b[1]}
end
def iter_test2
a = collect{|e| [e, yield(e)]}
a.sort{|a,b|a[1]<=>b[1]}
ary = collect{|e| [e, yield(e)]}
ary.sort{|a,b|a[1]<=>b[1]}
end
end
@ -51,7 +51,7 @@ class TestIterator < Test::Unit::TestCase
def test_nested_iterator
i = 0
tt{|i| break if i == 5}
tt{|j| break if j == 5}
assert_equal(0, i)
assert_raise(ArgumentError) do

View file

@ -77,16 +77,16 @@ class TestRubyLiteral < Test::Unit::TestCase
def test_regexp
assert_instance_of Regexp, //
assert_match //, 'a'
assert_match //, ''
assert_match(//, 'a')
assert_match(//, '')
assert_instance_of Regexp, /a/
assert_match /a/, 'a'
assert_no_match /test/, 'tes'
assert_match(/a/, 'a')
assert_no_match(/test/, 'tes')
re = /test/
assert_match re, 'test'
str = 'test'
assert_match re, str
assert_match /test/, str
assert_match(/test/, str)
assert_equal 0, (/test/ =~ 'test')
assert_equal 0, (re =~ 'test')
assert_equal 0, (/test/ =~ str)

View file

@ -178,7 +178,7 @@ class TestProc < Test::Unit::TestCase
b = proc { :foo }
assert_equal(:foo, b.curry[])
b = lambda {|x, y, &b| b.call(x + y) }.curry
b = lambda {|x, y, &blk| blk.call(x + y) }.curry
b = b.call(2) { raise }
b = b.call(3) {|x| x + 4 }
assert_equal(9, b)

View file

@ -229,7 +229,7 @@ class TestSprintfComb < Test::Unit::TestCase
digits.reverse!
str = digits.map {|d| digitmap[d] }.join
str = digits.map {|digit| digitmap[digit] }.join
pad = ''
nlen = prefix.length + sign.length + str.length

View file

@ -190,8 +190,8 @@ class TestOpen3 < Test::Unit::TestCase
ts.each {|t| assert_kind_of(Thread, t) }
i.print str
i.close
ts.each_with_index {|t, i|
assert_equal(str[i] == ?t, t.value.success?)
ts.each_with_index {|t, ii|
assert_equal(str[ii] == ?t, t.value.success?)
}
}
end

View file

@ -107,7 +107,7 @@ class TestPrime < Test::Unit::TestCase
def test_from_prime_division
assert_equal PRIMES.inject(&:*), Integer.from_prime_division(PRIMES.map{|p| [p,1]})
assert_equal -PRIMES.inject(&:*), Integer.from_prime_division([[-1, 1]] + PRIMES.map{|p| [p,1]})
assert_equal(-PRIMES.inject(&:*), Integer.from_prime_division([[-1, 1]] + PRIMES.map{|p| [p,1]}))
end
def test_prime?
@ -124,11 +124,11 @@ class TestPrime < Test::Unit::TestCase
assert !9.prime?
# mersenne numbers
assert (2**31-1).prime?
assert((2**31-1).prime?)
assert !(2**32-1).prime?
# fermat numbers
assert (2**(2**4)+1).prime?
assert((2**(2**4)+1).prime?)
assert !(2**(2**5)+1).prime? # Euler!
# large composite
@ -139,8 +139,8 @@ class TestPrime < Test::Unit::TestCase
# negative
assert !-1.prime?
assert -2.prime?
assert -3.prime?
assert(-2.prime?)
assert(-3.prime?)
assert !-4.prime?
end
end

View file

@ -81,8 +81,8 @@ class TestLDAP < Test::Unit::TestCase
['ldap', nil, URI::LDAP::DEFAULT_PORT,
'',
nil, 'sub', nil, '!bindname=cn=Manager%2co=Foo'],
}.each do |url, ary|
u = URI.parse(url)
}.each do |url2, ary|
u = URI.parse(url2)
assert_equal(ary, uri_to_ary(u))
end
end

View file

@ -254,8 +254,8 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
:SSLPrivateKey => key,
}
TestWEBrick.start_httpserver(s_config){|s_server, s_addr, s_port, s_log|
s_server.mount_proc("/"){|req, res|
res.body = "SSL #{req.request_method} #{req.path} #{req.body}"
s_server.mount_proc("/"){|req2, res|
res.body = "SSL #{req2.request_method} #{req2.path} #{req2.body}"
}
http = Net::HTTP.new("127.0.0.1", s_port, addr, port, up_log.call + log.call + s_log.call)
http.use_ssl = true
@ -263,14 +263,14 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
store_ctx.current_cert.to_der == cert.to_der
end
req = Net::HTTP::Get.new("/")
http.request(req){|res|
req2 = Net::HTTP::Get.new("/")
http.request(req2){|res|
assert_equal("SSL GET / ", res.body, up_log.call + log.call + s_log.call)
}
req = Net::HTTP::Post.new("/")
req.body = "post-data"
http.request(req){|res|
req2 = Net::HTTP::Post.new("/")
req2.body = "post-data"
http.request(req2){|res|
assert_equal("SSL POST / post-data", res.body, up_log.call + log.call + s_log.call)
}
}

View file

@ -88,11 +88,11 @@ class Test_Webrick < Test::Unit::TestCase
# default handler (missing handler)
ok, param = @s.call2('test.nonexisting')
assert_equal false, ok
assert_equal -99, param.faultCode
assert_equal(-99, param.faultCode)
# default handler (wrong number of arguments)
ok, param = @s.call2('test.add', 1, 2, 3)
assert_equal false, ok
assert_equal -99, param.faultCode
assert_equal(-99, param.faultCode)
end
end

View file

@ -7,7 +7,7 @@ module WEBrick_Testing
end
def start_server(config={})
raise "already started" if @__server
raise "already started" if defined?(@__server) && @__server
@__started = false
@__server_thread = Thread.new {