Permalink
Browse files

Merge pull request #1842 from ksss/assert_nothing_raised

add assertion method `assert_nothing_raised'
  • Loading branch information...
2 parents 86a48b7 + 23680cb commit 6dd2f36d201e86057009770e309171b32aec937e @matz matz committed Mar 10, 2014
Showing with 18 additions and 0 deletions.
  1. +18 −0 test/assert.rb
View
18 test/assert.rb
@@ -174,6 +174,24 @@ def assert_raise(*exp)
ret
end
+def assert_nothing_raised(*exp)
+ ret = true
+ if $mrbtest_assert
+ $mrbtest_assert_idx += 1
+ msg = exp.last.class == String ? exp.pop : ""
+ begin
+ yield
+ rescue Exception => e
+ msg = "#{msg} exception raised."
+ diff = " Class: <#{e.class}>\n" +
+ " Message: #{e.message}"
+ $mrbtest_assert.push([$mrbtest_assert_idx, msg, diff])
+ ret = false
+ end
+ end
+ ret
+end
+
##
# Fails unless +obj+ is a kind of +cls+.
def assert_kind_of(cls, obj, msg = nil)

0 comments on commit 6dd2f36

Please sign in to comment.