From fad980a7d34ffe8571a373a4d548a403ae9dea5d Mon Sep 17 00:00:00 2001 From: ntalbott Date: Mon, 8 Dec 2003 15:58:41 +0000 Subject: * lib/test/unit/assertions.rb: renamed #assert_raises to #assert_raise and made the former call the latter. [ruby-core:01890] * test/testunit/test_assertions.rb: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/testunit/test_assertions.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'test/testunit') diff --git a/test/testunit/test_assertions.rb b/test/testunit/test_assertions.rb index 6d0283174..999376e76 100644 --- a/test/testunit/test_assertions.rb +++ b/test/testunit/test_assertions.rb @@ -104,37 +104,37 @@ module Test end end - def test_assert_raises + def test_assert_raise return_value = nil check_nothing_fails(true) { - return_value = assert_raises(RuntimeError) { + return_value = assert_raise(RuntimeError) { raise "Error" } } - check(return_value.kind_of?(Exception), "Should have returned the exception from a successful assert_raises") - check(return_value.message == "Error", "Should have returned the correct exception from a successful assert_raises") + check(return_value.kind_of?(Exception), "Should have returned the exception from a successful assert_raise") + check(return_value.message == "Error", "Should have returned the correct exception from a successful assert_raise") check_nothing_fails(true) { - assert_raises(ArgumentError, "successful assert_raises") { + assert_raise(ArgumentError, "successful assert_raise") { raise ArgumentError.new("Error") } } check_nothing_fails(true) { - assert_raises(RuntimeError) { + assert_raise(RuntimeError) { raise "Error" } } check_nothing_fails(true) { - assert_raises(RuntimeError, "successful assert_raises") { + assert_raise(RuntimeError, "successful assert_raise") { raise "Error" } } check_fails(" exception expected but none was thrown.") { - assert_raises(RuntimeError) { + assert_raise(RuntimeError) { 1 + 1 } } - check_fails(%r{\Afailed assert_raises.\n exception expected but was\nClass: \nMessage: <"Error">\n---Backtrace---\n.+\n---------------\Z}m) { - assert_raises(ArgumentError, "failed assert_raises") { + check_fails(%r{\Afailed assert_raise.\n exception expected but was\nClass: \nMessage: <"Error">\n---Backtrace---\n.+\n---------------\Z}m) { + assert_raise(ArgumentError, "failed assert_raise") { raise "Error" } } @@ -147,26 +147,26 @@ module Test exceptions = [ArgumentError, TypeError] exceptions.each do |exc| check_nothing_fails(true) { - return_value = assert_raises(*exceptions) { + return_value = assert_raise(*exceptions) { raise exc, "Error" } } check(return_value.instance_of?(exc), "Should have returned #{exc} but was #{return_value.class}") - check(return_value.message == "Error", "Should have returned the correct exception from a successful assert_raises") + check(return_value.message == "Error", "Should have returned the correct exception from a successful assert_raise") end check_fails("<[ArgumentError, TypeError]> exception expected but none was thrown.") { - assert_raises(*exceptions) { + assert_raise(*exceptions) { 1 + 1 } } - check_fails(%r{\Afailed assert_raises. + check_fails(%r{\Afailed assert_raise. <\[ArgumentError, TypeError\]> exception expected but was Class: Message: <"Error"> ---Backtrace--- .+ ---------------\Z}m) { - assert_raises(ArgumentError, TypeError, "failed assert_raises") { + assert_raise(ArgumentError, TypeError, "failed assert_raise") { raise "Error" } } -- cgit