* test/ruby/test_arity.rb (TestArity#err_mess): use assert_raise.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-03-15 01:31:43 +00:00
parent 724e683e86
commit 9f9201b85d
5 changed files with 11 additions and 7 deletions

View File

@ -1,3 +1,7 @@
Thu Mar 15 10:31:40 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/ruby/test_arity.rb (TestArity#err_mess): use assert_raise.
Thu Mar 15 07:03:52 2012 Eric Hodel <drbrain@segment7.net>
* vm_eval.c (check_funcall): Raise ArgumentError if respond_to?

View File

@ -3,16 +3,16 @@ require 'test/unit'
class TestArity < Test::Unit::TestCase
def err_mess(method_proc = nil, argc = 0)
args = (1..argc).to_a
case method_proc
err = assert_raise(ArgumentError) do
case method_proc
when nil
yield
when Symbol
method(method_proc).call(*args)
else
method_proc.call(*args)
end
end
fail "Expected ArgumentError to be raised"
rescue ArgumentError => err
s = err.to_s
assert s =~ /wrong number of arguments \((.*)\)/, "Unexpected ArgumentError's message: #{s}"
$1

View File

@ -471,11 +471,11 @@ class TestObject < Test::Unit::TestCase
end
end
e = assert_raises(ArgumentError, '[bug:6000]') do
e = assert_raise(ArgumentError, '[bug:6000]') do
[[p]].flatten
end
assert_equal('respond_to? must accept 1 or 2 arguments (requires 3)', e.message)
assert_equal('respond_to? must accept 1 or 2 arguments (requires 3)', e.message)
end
def test_method_missing_passed_block

View File

@ -7,7 +7,7 @@ require 'tmpdir'
class TestRequire < Test::Unit::TestCase
def test_load_error_path
filename = "should_not_exist"
error = assert_raises(LoadError) do
error = assert_raise(LoadError) do
require filename
end
assert_equal filename, error.path

View File

@ -137,7 +137,7 @@ class TestThread < Test::Unit::TestCase
# mutex = Mutex.new
# cv = ConditionVariable.new
#
# assert_raises(fatal) {
# assert_raise(fatal) {
# mutex.lock
# cv.wait mutex
# mutex.unlock