ruby-changes:38646
From: nobu <ko1@a...>
Date: Tue, 2 Jun 2015 11:18:56 +0900 (JST)
Subject: [ruby-changes:38646] nobu:r50727 (trunk): use assert_raise
nobu 2015-06-02 11:18:44 +0900 (Tue, 02 Jun 2015) New Revision: 50727 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50727 Log: use assert_raise Modified files: trunk/test/digest/test_digest_extend.rb trunk/test/io/wait/test_io_wait.rb trunk/test/logger/test_logdevice.rb trunk/test/net/http/test_http.rb trunk/test/net/http/test_httpresponse.rb trunk/test/net/smtp/test_smtp.rb trunk/test/net/smtp/test_ssl_socket.rb trunk/test/open-uri/test_open-uri.rb trunk/test/openssl/test_asn1.rb trunk/test/openssl/test_buffering.rb trunk/test/openssl/test_digest.rb trunk/test/openssl/test_pkcs12.rb trunk/test/openssl/test_pkey_dh.rb trunk/test/optparse/test_acceptable.rb trunk/test/rexml/test_changing_encoding.rb trunk/test/rexml/test_entity.rb trunk/test/ruby/test_gc.rb trunk/test/socket/test_nonblock.rb trunk/test/socket/test_socket.rb trunk/test/socket/test_tcp.rb trunk/test/socket/test_udp.rb trunk/test/socket/test_unix.rb trunk/test/test_ipaddr.rb trunk/test/test_prime.rb trunk/test/test_set.rb trunk/test/test_singleton.rb trunk/test/test_syslog.rb trunk/test/webrick/test_server.rb trunk/test/xmlrpc/test_client.rb trunk/test/zlib/test_zlib.rb Index: test/logger/test_logdevice.rb =================================================================== --- test/logger/test_logdevice.rb (revision 50726) +++ test/logger/test_logdevice.rb (revision 50727) @@ -37,7 +37,7 @@ class TestLogDevice < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/logger/test_logdevice.rb#L37 logdev = d(STDERR) assert_equal(STDERR, logdev.dev) assert_nil(logdev.filename) - assert_raises(TypeError) do + assert_raise(TypeError) do d(nil) end # Index: test/ruby/test_gc.rb =================================================================== --- test/ruby/test_gc.rb (revision 50726) +++ test/ruby/test_gc.rb (revision 50727) @@ -147,7 +147,7 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L147 assert_not_empty info assert_equal info[:gc_by], GC.latest_gc_info(:gc_by) - assert_raises(ArgumentError){ GC.latest_gc_info(:invalid) } + assert_raise(ArgumentError){ GC.latest_gc_info(:invalid) } assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) {GC.latest_gc_info(:"\u{30eb 30d3 30fc}")} end Index: test/zlib/test_zlib.rb =================================================================== --- test/zlib/test_zlib.rb (revision 50726) +++ test/zlib/test_zlib.rb (revision 50727) @@ -233,7 +233,7 @@ if defined? Zlib https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L233 class TestZlibInflate < Test::Unit::TestCase def test_class_inflate_dictionary - assert_raises(Zlib::NeedDict) do + assert_raise(Zlib::NeedDict) do Zlib::Inflate.inflate([0x08,0x3C,0x0,0x0,0x0,0x0].pack("c*")) end end Index: test/xmlrpc/test_client.rb =================================================================== --- test/xmlrpc/test_client.rb (revision 50726) +++ test/xmlrpc/test_client.rb (revision 50727) @@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/xmlrpc/test_client.rb#L1 -require 'minitest/autorun' +require 'test/unit' require 'xmlrpc/client' require 'net/http' begin @@ -7,7 +7,7 @@ rescue LoadError https://github.com/ruby/ruby/blob/trunk/test/xmlrpc/test_client.rb#L7 end module XMLRPC - class ClientTest < MiniTest::Unit::TestCase + class ClientTest < Test::Unit::TestCase module Fake class HTTP attr_accessor :read_timeout, :open_timeout, :use_ssl @@ -182,13 +182,13 @@ module XMLRPC https://github.com/ruby/ruby/blob/trunk/test/xmlrpc/test_client.rb#L182 end def test_new2_bad_protocol - assert_raises(ArgumentError) do + assert_raise(ArgumentError) do XMLRPC::Client.new2 'ftp://example.org' end end def test_new2_bad_uri - assert_raises(ArgumentError) do + assert_raise(ArgumentError) do XMLRPC::Client.new2 ':::::' end end Index: test/test_prime.rb =================================================================== --- test/test_prime.rb (revision 50726) +++ test/test_prime.rb (revision 50727) @@ -64,7 +64,7 @@ class TestPrime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_prime.rb#L64 end def test_new - exception = assert_raises(NoMethodError) { Prime.new } + exception = assert_raise(NoMethodError) { Prime.new } end def test_enumerator_succ Index: test/openssl/test_digest.rb =================================================================== --- test/openssl/test_digest.rb (revision 50726) +++ test/openssl/test_digest.rb (revision 50727) @@ -106,7 +106,7 @@ class OpenSSL::TestDigest < Test::Unit:: https://github.com/ruby/ruby/blob/trunk/test/openssl/test_digest.rb#L106 def test_openssl_digest assert_equal OpenSSL::Digest::MD5, OpenSSL::Digest("MD5") - assert_raises NameError do + assert_raise NameError do OpenSSL::Digest("no such digest") end end Index: test/openssl/test_pkey_dh.rb =================================================================== --- test/openssl/test_pkey_dh.rb (revision 50726) +++ test/openssl/test_pkey_dh.rb (revision 50727) @@ -13,7 +13,7 @@ class OpenSSL::TestPKeyDH < Test::Unit:: https://github.com/ruby/ruby/blob/trunk/test/openssl/test_pkey_dh.rb#L13 def test_new_break assert_nil(OpenSSL::PKey::DH.new(NEW_KEYLEN) { break }) - assert_raises(RuntimeError) do + assert_raise(RuntimeError) do OpenSSL::PKey::DH.new(NEW_KEYLEN) { raise } end end Index: test/openssl/test_asn1.rb =================================================================== --- test/openssl/test_asn1.rb (revision 50726) +++ test/openssl/test_asn1.rb (revision 50727) @@ -552,7 +552,7 @@ rEzBQ0F9dUyqQ9gyRg8KHhDfv9HzT1d/rnUZMkoo https://github.com/ruby/ruby/blob/trunk/test/openssl/test_asn1.rb#L552 end def test_primitive_inf_length - assert_raises(OpenSSL::ASN1::ASN1Error) do + assert_raise(OpenSSL::ASN1::ASN1Error) do spec = %w{ 02 80 02 01 01 00 00 } raw = [spec.join('')].pack('H*') OpenSSL::ASN1.decode(raw) Index: test/openssl/test_pkcs12.rb =================================================================== --- test/openssl/test_pkcs12.rb (revision 50726) +++ test/openssl/test_pkcs12.rb (revision 50727) @@ -113,7 +113,7 @@ Li8JsX5yIiuVYaBg/6ha3tOg4TCa5K/3r3tVliRZ https://github.com/ruby/ruby/blob/trunk/test/openssl/test_pkcs12.rb#L113 end def test_create_with_bad_nid - assert_raises(ArgumentError) do + assert_raise(ArgumentError) do OpenSSL::PKCS12.create( "omg", "hello", @@ -137,7 +137,7 @@ Li8JsX5yIiuVYaBg/6ha3tOg4TCa5K/3r3tVliRZ https://github.com/ruby/ruby/blob/trunk/test/openssl/test_pkcs12.rb#L137 2048 ) - assert_raises(TypeError) do + assert_raise(TypeError) do OpenSSL::PKCS12.create( "omg", "hello", @@ -164,7 +164,7 @@ Li8JsX5yIiuVYaBg/6ha3tOg4TCa5K/3r3tVliRZ https://github.com/ruby/ruby/blob/trunk/test/openssl/test_pkcs12.rb#L164 2048 ) - assert_raises(TypeError) do + assert_raise(TypeError) do OpenSSL::PKCS12.create( "omg", "hello", Index: test/openssl/test_buffering.rb =================================================================== --- test/openssl/test_buffering.rb (revision 50726) +++ test/openssl/test_buffering.rb (revision 50727) @@ -61,7 +61,7 @@ class OpenSSL::TestBuffering < Test::Uni https://github.com/ruby/ruby/blob/trunk/test/openssl/test_buffering.rb#L61 raise SystemCallError, 'fail' end - assert_raises SystemCallError do + assert_raise SystemCallError do @io.flush end Index: test/webrick/test_server.rb =================================================================== --- test/webrick/test_server.rb (revision 50726) +++ test/webrick/test_server.rb (revision 50727) @@ -29,7 +29,7 @@ class TestWEBrickServer < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/webrick/test_server.rb#L29 log = [] logger = WEBrick::Log.new(log, WEBrick::BasicLog::WARN) - assert_raises(SignalException) do + assert_raise(SignalException) do listener = Object.new def listener.to_io # IO.select invokes #to_io. raise SignalException, 'SIGTERM' # simulate signal in main thread Index: test/rexml/test_changing_encoding.rb =================================================================== --- test/rexml/test_changing_encoding.rb (revision 50726) +++ test/rexml/test_changing_encoding.rb (revision 50727) @@ -21,7 +21,7 @@ module REXMLTests https://github.com/ruby/ruby/blob/trunk/test/rexml/test_changing_encoding.rb#L21 @f.encoding = 'EUC-JP' assert_equal( @u, @f.decode(@e) ) # This doesn't happen anymore, for some reason - #assert_raises( Iconv::IllegalSequence, "Decoding unicode should fail" ) { + #assert_raise( Iconv::IllegalSequence, "Decoding unicode should fail" ) { # @f.decode(@u) == @u #} end @@ -36,7 +36,7 @@ module REXMLTests https://github.com/ruby/ruby/blob/trunk/test/rexml/test_changing_encoding.rb#L36 @f.encoding = 'EUC-JP' assert_equal( @u, @f.decode(@e) ) # This doesn't happen anymore, for some reason - #assert_raises( Iconv::IllegalSequence, "Decoding unicode should fail" ) { + #assert_raise( Iconv::IllegalSequence, "Decoding unicode should fail" ) { # @f.decode(@u) == @u #} end Index: test/rexml/test_entity.rb =================================================================== --- test/rexml/test_entity.rb (revision 50726) +++ test/rexml/test_entity.rb (revision 50727) @@ -118,7 +118,7 @@ module REXMLTests https://github.com/ruby/ruby/blob/trunk/test/rexml/test_entity.rb#L118 # above 10k explodes entities = '&a;' * 3 # 5k entity * 2 = 15k xmldoc = REXML::Document.new(template.sub(/\$/, entities)) - assert_raises(RuntimeError) do + assert_raise(RuntimeError) do xmldoc.root.text end end @@ -134,7 +134,7 @@ module REXMLTests https://github.com/ruby/ruby/blob/trunk/test/rexml/test_entity.rb#L134 # above 10k explodes entities = '%a;' * 3 # 5k entity * 2 = 15k - assert_raises(REXML::ParseException) do + assert_raise(REXML::ParseException) do REXML::Document.new(template.sub(/\$/, entities)) end end Index: test/digest/test_digest_extend.rb =================================================================== --- test/digest/test_digest_extend.rb (revision 50726) +++ test/digest/test_digest_extend.rb (revision 50727) @@ -151,7 +151,7 @@ class TestDigestExtend < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/digest/test_digest_extend.rb#L151 end def test_block_length - assert_raises(RuntimeError) do + assert_raise(RuntimeError) do @MyDigest.new.block_length end end Index: test/test_syslog.rb =================================================================== --- test/test_syslog.rb (revision 50726) +++ test/test_syslog.rb (revision 50727) @@ -11,7 +11,7 @@ end https://github.com/ruby/ruby/blob/trunk/test/test_syslog.rb#L11 class TestSyslog < Test::Unit::TestCase def test_new - assert_raises(NoMethodError) { + assert_raise(NoMethodError) { Syslog.new } end @@ -37,7 +37,7 @@ class TestSyslog < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_syslog.rb#L37 assert_equal(Syslog::LOG_USER, Syslog.facility) # open without close - assert_raises(RuntimeError) { + assert_raise(RuntimeError) { Syslog.open } @@ -88,7 +88,7 @@ class TestSyslog < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_syslog.rb#L88 end def test_close - assert_raises(RuntimeError) { + assert_raise(RuntimeError) { Syslog.close } end Index: test/optparse/test_acceptable.rb =================================================================== --- test/optparse/test_acceptable.rb (revision 50726) +++ test/optparse/test_acceptable.rb (revision 50727) @@ -32,19 +32,19 @@ class TestOptionParser::Acceptable < Tes https://github.com/ruby/ruby/blob/trunk/test/optparse/test_acceptable.rb#L32 assert_equal(%w"", no_error {@opt.parse!(%w"--integer 0x3")}) assert_equal(3, @integer) - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--integer 0b") end - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--integer 09") end - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--integer 0x") end - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--integer 1234xyz") end end @@ -65,11 +65,11 @@ class TestOptionParser::Acceptable < Tes https://github.com/ruby/ruby/blob/trunk/test/optparse/test_acceptable.rb#L65 assert_equal(%w"", no_error {@opt.parse!(%w"--float 1E-2")}) assert_in_epsilon(0.01, @float) - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--float 0e") end - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--float 1.234xyz") end end @@ -87,15 +87,15 @@ class TestOptionParser::Acceptable < Tes https://github.com/ruby/ruby/blob/trunk/test/optparse/test_acceptable.rb#L87 assert_equal(%w"", no_error {@opt.parse!(%w"--numeric 1.2/2.3")}) assert_equal(Rational(12, 23), @numeric) - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--numeric 1/") end - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--numeric 12/34xyz") end - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--numeric 12x/34yz") end end @@ -107,21 +107,21 @@ class TestOptionParser::Acceptable < Tes https://github.com/ruby/ruby/blob/trunk/test/optparse/test_acceptable.rb#L107 assert_equal(%w"", no_error {@opt.parse!(%w"--decimal-integer 10")}) assert_equal(10, @decimal_integer) - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--decimal-integer 0b1") end - e = assert_raises(OptionParser::InvalidArgument) do + e = assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--decimal-integer 09") end assert_equal("invalid argument: --decimal-integer 09", e.message) - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--decimal-integer x") end - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--decimal-integer 1234xyz") end end @@ -142,19 +142,19 @@ class TestOptionParser::Acceptable < Tes https://github.com/ruby/ruby/blob/trunk/test/optparse/test_acceptable.rb#L142 assert_equal(%w"", no_error {@opt.parse!(%w"--octal-integer 011")}) assert_equal(9, @octal_integer) - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--octal-integer 09") end - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--octal-integer 0b1") end - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--octal-integer x") end - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--octal-integer 01234xyz") end end @@ -172,21 +172,21 @@ class TestOptionParser::Acceptable < Tes https://github.com/ruby/ruby/blob/trunk/test/optparse/test_acceptable.rb#L172 assert_equal(%w"", no_error {@opt.parse!(%w"--decimal-numeric 1E2")}) assert_in_delta(100.0, @decimal_numeric) - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--decimal-numeric 0b1") end - e = assert_raises(OptionParser::InvalidArgument) do + e = assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--decimal-numeric 09") end assert_equal("invalid argument: --decimal-numeric 09", e.message) - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--decimal-integer 1234xyz") end - assert_raises(OptionParser::InvalidArgument) do + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--decimal-integer 12.34xyz") end end Index: test/open-uri/test_open-uri.rb =================================================================== --- test/open-uri/test_open-uri.rb (revision 50726) +++ test/open-uri/test_open-uri.rb (revision 50727) @@ -137,7 +137,7 @@ class TestOpenURI < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/open-uri/test_open-uri.rb#L137 end def test_open_timeout - assert_raises(Net::OpenTimeout) do + assert_raise(Net::OpenTimeout) do URI("http://example.com/").read(open_timeout: 0.000001) end if false # avoid external resources in tests Index: test/test_ipaddr.rb =================================================================== --- test/test_ipaddr.rb (revision 50726) +++ test/test_ipaddr.rb (revision 50727) @@ -69,15 +69,15 @@ class TC_IPAddr < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_ipaddr.rb#L69 assert_equal("1:2:3:4:5:6:7:0", IPAddr.new("1:2:3:4:5:6:7::").to_s) assert_equal("0:2:3:4:5:6:7:8", IPAddr.new("::2:3:4:5:6:7:8").to_s) - assert_raises(IPAddr::InvalidAddressError) { IPAddr.new("192.168.0.256") } - assert_raises(IPAddr::InvalidAddressError) { IPAddr.new("192.168.0.011") } - assert_raises(IPAddr::InvalidAddressError) { IPAddr.new("fe80::1%fxp0") } - assert_raises(IPAddr::InvalidAddressError) { IPAddr.new("[192.168.1.2]/120") } - assert_raises(IPAddr::InvalidPrefixError) { IPAddr.new("::1/255.255.255.0") } - assert_raises(IPAddr::InvalidPrefixError) { IPAddr.new("::1/129") } - assert_raises(IPAddr::InvalidPrefixError) { IPAddr.new("192.168.0.1/33") } - assert_raises(IPAddr::AddressFamilyError) { IPAddr.new(1) } - assert_raises(IPAddr::AddressFamilyError) { IPAddr.new("::ffff:192.168.1.2/120", Socket::AF_INET) } + assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("192.168.0.256") } + assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("192.168.0.011") } + assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("fe80::1%fxp0") } + assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("[192.168.1.2]/120") } + assert_raise(IPAddr::InvalidPrefixError) { IPAddr.new("::1/255.255.255.0") } + assert_raise(IPAddr::InvalidPrefixError) { IPAddr.new("::1/129") } + assert_raise(IPAddr::InvalidPrefixError) { IPAddr.new("192.168.0.1/33") } + assert_raise(IPAddr::AddressFamilyError) { IPAddr.new(1) } + assert_raise(IPAddr::AddressFamilyError) { IPAddr.new("::ffff:192.168.1.2/120", Socket::AF_INET) } end def test_s_new_ntoh @@ -138,14 +138,14 @@ class TC_IPAddr < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_ipaddr.rb#L138 def test_ip6_arpa assert_equal("f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.arpa", IPAddr.new("3ffe:505:2::f").ip6_arpa) - assert_raises(IPAddr::InvalidAddressError) { + assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("192.168.2.1").ip6_arpa } end def test_ip6_int assert_equal("f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.int", IPAddr.new("3ffe:505:2::f").ip6_int) - assert_raises(IPAddr::InvalidAddressError) { + assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("192.168.2.1").ip6_int } end Index: test/net/http/test_httpresponse.rb =================================================================== --- test/net/http/test_httpresponse.rb (revision 50726) +++ test/net/http/test_httpresponse.rb (revision 50727) @@ -253,7 +253,7 @@ Connection: close https://github.com/ruby/ruby/blob/trunk/test/net/http/test_httpresponse.rb#L253 hello EOS - assert_raises Net::HTTPBadResponse do + assert_raise Net::HTTPBadResponse do Net::HTTPResponse.read_new(io) end end Index: test/net/http/test_http.rb =================================================================== --- test/net/http/test_http.rb (revi (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/