mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/test/unit/assertions.rb (assert_send): make arguments in
the default message clearer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
776227cbcf
commit
1161616768
2 changed files with 57 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Sep 12 12:40:44 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/test/unit/assertions.rb (assert_send): make arguments in
|
||||
the default message clearer.
|
||||
|
||||
Sun Sep 11 05:23:14 2011 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||
|
||||
* lib/matrix.rb: Deal with subclasses of Matrix [redmine #5307]
|
||||
|
|
|
@ -253,6 +253,58 @@ EOT
|
|||
super if !caller[0].rindex(MiniTest::MINI_DIR, 0) || !obj.respond_to?(meth)
|
||||
end
|
||||
|
||||
# :call-seq:
|
||||
# assert_send( +send_array+, failure_message = nil )
|
||||
#
|
||||
# Passes if the method send returns a true value.
|
||||
#
|
||||
# +send_array+ is composed of:
|
||||
# * A receiver
|
||||
# * A method
|
||||
# * Arguments to the method
|
||||
#
|
||||
# Example:
|
||||
# assert_send([[1, 2], :member?, 1]) # -> pass
|
||||
# assert_send([[1, 2], :member?, 4]) # -> fail
|
||||
def assert_send send_ary, m = nil
|
||||
recv, msg, *args = send_ary
|
||||
m = message(m) {
|
||||
if args.empty?
|
||||
argsstr = ""
|
||||
else
|
||||
(argsstr = mu_pp(args)).sub!(/\A\[(.*)\]\z/m, '\1')
|
||||
end
|
||||
"Expected #{mu_pp(recv)}.#{msg}#{argsstr} to return false"
|
||||
}
|
||||
assert recv.__send__(msg, *args), m
|
||||
end
|
||||
|
||||
# :call-seq:
|
||||
# assert_not_send( +send_array+, failure_message = nil )
|
||||
#
|
||||
# Passes if the method send doesn't return a true value.
|
||||
#
|
||||
# +send_array+ is composed of:
|
||||
# * A receiver
|
||||
# * A method
|
||||
# * Arguments to the method
|
||||
#
|
||||
# Example:
|
||||
# assert_not_send([[1, 2], :member?, 1]) # -> fail
|
||||
# assert_not_send([[1, 2], :member?, 4]) # -> pass
|
||||
def assert_not_send send_ary, m = nil
|
||||
recv, msg, *args = send_ary
|
||||
m = message(m) {
|
||||
if args.empty?
|
||||
argsstr = ""
|
||||
else
|
||||
(argsstr = mu_pp(args)).sub!(/\A\[(.*)\]\z/m, '\1')
|
||||
end
|
||||
"Expected #{mu_pp(recv)}.#{msg}#{argsstr} to return false"
|
||||
}
|
||||
assert !recv.__send__(msg, *args), m
|
||||
end
|
||||
|
||||
ms = instance_methods(true).map {|sym| sym.to_s }
|
||||
ms.grep(/\Arefute_/) do |m|
|
||||
mname = ('assert_not_' << m.to_s[/.*?_(.*)/, 1])
|
||||
|
|
Loading…
Reference in a new issue