mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/test/unit/assertions.rb: assert_nothing_thrown,
assert_raise, assert_not_equal, assert_no_match, assert_not_nil, assert_not_same are coming back as alias. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fd1dc66691
commit
ccf184d9e4
2 changed files with 33 additions and 16 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Wed Oct 8 11:56:15 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/test/unit/assertions.rb: assert_nothing_thrown,
|
||||||
|
assert_raise, assert_not_equal, assert_no_match, assert_not_nil,
|
||||||
|
assert_not_same are coming back as alias.
|
||||||
|
|
||||||
Wed Oct 8 11:18:12 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Oct 8 11:18:12 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* variable.c (autoload_delete, autoload_file): should not delete
|
* variable.c (autoload_delete, autoload_file): should not delete
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
require 'mini/test'
|
require 'mini/test'
|
||||||
require 'test/unit/deprecate'
|
|
||||||
|
|
||||||
module Test; end
|
module Test; end
|
||||||
module Test::Unit # patch up bastards that that extend improperly.
|
module Test::Unit # patch up bastards that that extend improperly.
|
||||||
|
@ -32,28 +31,40 @@ module Test::Unit # patch up bastards that that extend improperly.
|
||||||
end
|
end
|
||||||
|
|
||||||
module Test::Unit
|
module Test::Unit
|
||||||
module Assertions # deprecations
|
module Assertions
|
||||||
tu_deprecate :assert_nothing_thrown, :assert_nothing_raised # 2009-06-01
|
def assert_nothing_raised(*exp)
|
||||||
tu_deprecate :assert_raise, :assert_raises # 2010-06-01
|
msg = (Module === exp.last) ? "" : exp.pop
|
||||||
tu_deprecate :assert_not_equal, :refute_equal # 2009-06-01
|
noexc = exp.select {|e| not (Module === e and Exception >= e)}
|
||||||
tu_deprecate :assert_no_match, :refute_match # 2009-06-01
|
unless noexc.empty?
|
||||||
tu_deprecate :assert_not_nil, :refute_nil # 2009-06-01
|
noexc = *noexc if noexc.size == 1
|
||||||
tu_deprecate :assert_not_same, :refute_same # 2009-06-01
|
raise TypeError, "Should expect a class of exception, #{noexc.inspect}"
|
||||||
|
end
|
||||||
def assert_nothing_raised _ = :ignored, msg = nil # 2009-06-01
|
|
||||||
self.class.tu_deprecation_warning :assert_nothing_raised
|
|
||||||
self._assertions += 1
|
self._assertions += 1
|
||||||
yield
|
begin
|
||||||
rescue => e
|
yield
|
||||||
raise Mini::Assertion, exception_details(e, "Exception raised:")
|
rescue Exception => e
|
||||||
|
exp.include?(e.class) or raise
|
||||||
|
raise(Mini::Assertion, exception_details(e, "#{msg}#{msg.empty? ? '' : ' '}Exception raised:"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_message(user_message, template_message, *args) # 2009-06-01
|
def build_message(user_message, template_message, *args)
|
||||||
self.class.tu_deprecation_warning :build_message
|
|
||||||
user_message ||= ''
|
user_message ||= ''
|
||||||
user_message += ' ' unless user_message.empty?
|
user_message += ' ' unless user_message.empty?
|
||||||
msg = template_message.split(/<\?>/).zip(args.map { |o| o.inspect })
|
msg = template_message.split(/<\?>/).zip(args.map { |o| o.inspect })
|
||||||
user_message + msg.join
|
user_message + msg.join
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias assert_nothing_thrown assert_nothing_raised
|
||||||
|
alias assert_raise assert_raises
|
||||||
|
alias assert_not_equal refute_equal
|
||||||
|
alias assert_no_match refute_match
|
||||||
|
alias assert_not_nil refute_nil
|
||||||
|
alias assert_not_same refute_same
|
||||||
|
|
||||||
|
private
|
||||||
|
def _wrap_assertion
|
||||||
|
yield
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue