test/lib/test/unit/core_assertions.rb
def assert_nothing_raised(*args)
        self._assertions += 1
        if Module === args.last
          msg = nil
        else
          msg = args.pop
        end
        begin
          line = __LINE__; yield
        rescue MiniTest::Skip
          raise
        rescue Exception => e
          bt = e.backtrace
          as = e.instance_of?(MiniTest::Assertion)
          if as
            ans = /\A#{Regexp.quote(__FILE__)}:#{line}:in /o
            bt.reject! {|ln| ans =~ ln}
          end
          if ((args.empty? && !as) ||
              args.any? {|a| a.instance_of?(Module) ? e.is_a?(a) : e.class == a })
            msg = message(msg) {
              "Exception raised:\n<#{mu_pp(e)}>\n" +
              "Backtrace:\n" +
              e.backtrace.map{|frame| "  #{frame}"}.join("\n")
            }
            raise MiniTest::Assertion, msg.call, bt
          else
            raise
          end
        end
      end
# :call-seq:
#   assert_nothing_raised( *args, &block )
#
#If any exceptions are given as arguments, the assertion will
#fail if one of those exceptions are raised. Otherwise, the test fails
#if any exceptions are raised.
#
#The final argument may be a failure message.
#
#    assert_nothing_raised RuntimeError do
#      raise Exception #Assertion passes, Exception is not a RuntimeError
#    end
#
#    assert_nothing_raised do
#      raise Exception #Assertion fails
#    end
:call-seq:
assert_nothing_raised( *args, █ )

If any exceptions are given as arguments, the assertion will
fail if one of those exceptions are raised. Otherwise, the test fails
if any exceptions are raised.

The final argument may be a failure message.

assert_nothing_raised RuntimeError do
raise Exception #Assertion passes, Exception is not a RuntimeError
end

assert_nothing_raised do
raise Exception #Assertion fails
end
: call - seq : assert_nothing_raised ( * args █ ) If any exceptions are given as arguments the assertion will fail if one of those exceptions are raised . Otherwise the test fails if any exceptions are raised . The final argument may be a failure message . assert_nothing_raised RuntimeError do raise Exception #Assertion passes Exception is not a RuntimeError end assert_nothing_raised do raise Exception #Assertion fails end
def assert_nothing_raised(*args)
        self._assertions += 1
        if Module === args.last
          msg = nil
        else
          msg = args.pop
        end
        begin
          line = __LINE__; yield
        rescue MiniTest::Skip
          raise
        rescue Exception => e
          bt = e.backtrace
          as = e.instance_of?(MiniTest::Assertion)
          if as
            ans = /\A#{Regexp.quote(__FILE__)}:#{line}:in /o
            bt.reject! {|ln| ans =~ ln}
          end
          if ((args.empty? && !as) ||
              args.any? {|a| a.instance_of?(Module) ? e.is_a?(a) : e.class == a })
            msg = message(msg) {
              "Exception raised:\n<#{mu_pp(e)}>\n" +
              "Backtrace:\n" +
              e.backtrace.map{|frame| "  #{frame}"}.join("\n")
            }
            raise MiniTest::Assertion, msg.call, bt
          else
            raise
          end
        end
      end
def assert_nothing_raised ( * args ) self . _assertions += 1 if Module === args . last msg = nil else msg = args . pop end begin line = __LINE__ ; yield rescue MiniTest :: Skip raise rescue Exception => e bt = e . backtrace as = e . instance_of? ( MiniTest :: Assertion ) if as ans = / \A #{ Regexp . quote ( __FILE__ ) } : #{ line } :in  /o bt . reject! { | ln | ans =~ ln } end if ( ( args . empty? && ! as ) || args . any? { | a | a . instance_of? ( Module ) ? e . is_a? ( a ) : e . class == a } ) msg = message ( msg ) { "Exception raised:\n<#{mu_pp(e)}>\n" + "Backtrace:\n" + e . backtrace . map { | frame | "  #{frame}" } . join ( "\n" ) } raise MiniTest :: Assertion , msg . call , bt else raise end end end
:call-seq:
assert_nothing_raised( *args, &block )
: call - seq : assert_nothing_raised ( * args &block )
args