[前][次][番号順一覧][スレッド一覧]

ruby-changes:31145

From: nobu <ko1@a...>
Date: Thu, 10 Oct 2013 00:17:25 +0900 (JST)
Subject: [ruby-changes:31145] nobu:r43224 (trunk): test/ruby: assert_raise_with_message

nobu	2013-10-10 00:17:20 +0900 (Thu, 10 Oct 2013)

  New Revision: 43224

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43224

  Log:
    test/ruby: assert_raise_with_message
    
    * test/ruby: use assert_raise_with_message

  Modified files:
    trunk/test/ruby/test_argf.rb
    trunk/test/ruby/test_array.rb
    trunk/test/ruby/test_marshal.rb
    trunk/test/ruby/test_rand.rb
    trunk/test/ruby/test_refinement.rb
Index: test/ruby/test_argf.rb
===================================================================
--- test/ruby/test_argf.rb	(revision 43223)
+++ test/ruby/test_argf.rb	(revision 43224)
@@ -799,8 +799,7 @@ class TestArgf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_argf.rb#L799
     end
     argf = ARGF.class.new(*paths)
     paths.each do |path|
-      e = assert_raise(Errno::ENOENT) {argf.gets}
-      assert_match(/- #{Regexp.quote(path)}\z/, e.message)
+      assert_raise_with_message(Errno::ENOENT, /- #{Regexp.quote(path)}\z/) {argf.gets}
     end
     assert_nil(argf.gets, bug4274)
   end
Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb	(revision 43223)
+++ test/ruby/test_array.rb	(revision 43224)
@@ -2300,8 +2300,7 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L2300
     assert_equal([], a.rotate!(13))
     assert_equal([], a.rotate!(-13))
     a = [].freeze
-    e = assert_raise(RuntimeError) {a.rotate!}
-    assert_match(/can't modify frozen/, e.message)
+    assert_raise_with_message(RuntimeError, /can't modify frozen/) {a.rotate!}
     a = [1,2,3]
     assert_raise(ArgumentError) { a.rotate!(1, 1) }
   end
Index: test/ruby/test_marshal.rb
===================================================================
--- test/ruby/test_marshal.rb	(revision 43223)
+++ test/ruby/test_marshal.rb	(revision 43224)
@@ -84,10 +84,9 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L84
   def test_too_long_string
     data = Marshal.dump(C.new("a".force_encoding("ascii-8bit")))
     data[-2, 1] = "\003\377\377\377"
-    e = assert_raise(ArgumentError, "[ruby-dev:32054]") {
+    assert_raise_with_message(ArgumentError, "marshal data too short", "[ruby-dev:32054]") {
       Marshal.load(data)
     }
-    assert_equal("marshal data too short", e.message)
   end
 
 
Index: test/ruby/test_refinement.rb
===================================================================
--- test/ruby/test_refinement.rb	(revision 43223)
+++ test/ruby/test_refinement.rb	(revision 43224)
@@ -441,12 +441,11 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L441
 
   def test_refine_without_block
     c1 = Class.new
-    e = assert_raise(ArgumentError) {
+    assert_raise_with_message(ArgumentError, "no block given") {
       Module.new do
         refine c1
       end
     }
-    assert_equal("no block given", e.message)
   end
 
   module Inspect
Index: test/ruby/test_rand.rb
===================================================================
--- test/ruby/test_rand.rb	(revision 43223)
+++ test/ruby/test_rand.rb	(revision 43224)
@@ -510,13 +510,11 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rand.rb#L510
     assert_equal([2], (1..100).map {[1,2,3].sample(random: gen)}.uniq)
 
     def (gen = Object.new).rand(*) 100 end
-    e = assert_raise(RangeError) {[1,2,3].sample(random: gen)}
-    assert_match(/big 100\z/, e.message)
+    assert_raise_with_message(RangeError, /big 100\z/) {[1,2,3].sample(random: gen)}
 
     bug7903 = '[ruby-dev:47061] [Bug #7903]'
     def (gen = Object.new).rand(*) -1 end
-    e = assert_raise(RangeError) {[1,2,3].sample(random: gen)}
-    assert_match(/small -1\z/, e.message, bug7903)
+    assert_raise_with_message(RangeError, /small -1\z/, e.message, bug7903) {[1,2,3].sample(random: gen)}
 
     bug7935 = '[ruby-core:52779] [Bug #7935]'
     class << (gen = Object.new)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]