1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/test/unit/assertions.rb: un-deprecated #assert_not_nil to

maintain symmetry with #assert_nil. Also added better output for
	  #assert_kind_of.

	* test/testunit/tc_assertions.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ntalbott 2003-11-08 17:06:11 +00:00
parent c103eb6793
commit 152380a87c
3 changed files with 18 additions and 4 deletions

View file

@ -1,3 +1,11 @@
Sat Nov 9 02:05:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
* lib/test/unit/assertions.rb: un-deprecated #assert_not_nil to
maintain symmetry with #assert_nil. Also added better output for
#assert_kind_of.
* test/testunit/tc_assertions.rb: ditto.
Sat Nov 8 18:50:20 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/wsdl/raa/*: add new testcase for WSDL loading, parsing and

View file

@ -104,7 +104,7 @@ EOT
def assert_kind_of(klass, object, message="")
_wrap_assertion do
assert(klass.kind_of?(Module), "The first parameter to assert_kind_of should be a kind_of Module.")
full_message = build_message(message, "<?>\nexpected to be kind_of\\?<?>.", object, klass)
full_message = build_message(message, "<?>\nexpected to be kind_of\\?\n<?> but was\n<?>.", object, klass, object.class)
assert_block(full_message){object.kind_of?(klass)}
end
end
@ -221,7 +221,6 @@ EOT
# Passes if !object.nil?.
public
def assert_not_nil(object, message="")
warn("Assertions#assert_not_nil is deprecated and will be removed after 1.8.1. Use #assert.")
full_message = build_message(message, "<?> expected to not be nil.", object)
assert_block(full_message){!object.nil?}
end

View file

@ -176,6 +176,13 @@ module Test
}
end
def test_assert_not_nil
check_nothing_fails{assert_not_nil(false)}
check_nothing_fails{assert_not_nil(false, "message")}
check_fails("<nil> expected to not be nil."){assert_not_nil(nil)}
check_fails("message.\n<nil> expected to not be nil.") {assert_not_nil(nil, "message")}
end
def test_assert_kind_of
check_nothing_fails {
assert_kind_of(Module, Array)
@ -189,10 +196,10 @@ module Test
check_nothing_fails {
assert_kind_of(Comparable, 1)
}
check_fails(%Q{<"string">\nexpected to be kind_of?<Class>.}) {
check_fails(%Q{<"string">\nexpected to be kind_of?\n<Class> but was\n<String>.}) {
assert_kind_of(Class, "string")
}
check_fails(%Q{failed assert_kind_of.\n<"string">\nexpected to be kind_of?<Class>.}) {
check_fails(%Q{failed assert_kind_of.\n<"string">\nexpected to be kind_of?\n<Class> but was\n<String>.}) {
assert_kind_of(Class, "string", "failed assert_kind_of")
}
end