* 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
Родитель c103eb6793
Коммит 152380a87c
3 изменённых файлов: 18 добавлений и 4 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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