artichoke-backend/vendor/mruby/test/assert.rb
def assert(str = 'assert', iso = '')
  t_print(str, (iso != '' ? " [#{iso}]" : ''), ' : ') if $mrbtest_verbose
  begin
    $mrbtest_child_noassert ||= [0]
    $mrbtest_child_noassert << 0
    parent_asserts = $asserts
    $asserts = []
    parent_mrbtest_assert = $mrbtest_assert
    $mrbtest_assert = []

    if $mrbtest_assert_idx && !$mrbtest_assert_idx.empty?
      $mrbtest_assert_idx[-1] += 1
      $mrbtest_assert_idx << 0
    else
      $mrbtest_assert_idx = [0]
      class << $mrbtest_assert_idx
        alias to_s _assertion_join
      end
    end

    yield
    if $mrbtest_assert.size > 0
      if $mrbtest_assert.size == $mrbtest_child_noassert[-1]
        $asserts.push(assertion_string('Skip: ', str, iso))
        $mrbtest_child_noassert[-2] += 1
        $skip_test += 1
        t_print('?')
      else
        $asserts.push(assertion_string('Fail: ', str, iso))
        $ko_test += 1
        t_print('F')
      end
    elsif $mrbtest_assert_idx[-1] == 0
      $asserts.push(assertion_string('Warn: ', str, iso, 'no assertion'))
      $warning_test += 1
      t_print('W')
    else
      $ok_test += 1
      t_print('.')
    end
  rescue MRubyTestSkip => e
    $asserts.push(assertion_string('Skip: ', str, iso, e))
    $skip_test += 1
    $mrbtest_child_noassert[-2] += 1
    t_print('?')
  rescue Exception => e
    $asserts.push(assertion_string("#{e.class}: ", str, iso, e, e.backtrace))
    $kill_test += 1
    t_print('X')
  ensure
    if $mrbtest_assert_idx.size > 1
      $asserts.each do |mesg|
        idx = $mrbtest_assert_idx[0..-2]._assertion_join
        mesg = mesg._assertion_indent("    ")

        # Give `mesg` as a `diff` argument to avoid adding extra periods.
        parent_mrbtest_assert << [idx, nil, mesg]
      end
    else
      parent_asserts.concat $asserts
    end
    $asserts = parent_asserts

    $mrbtest_assert = parent_mrbtest_assert
    $mrbtest_assert_idx.pop
    $mrbtest_assert_idx = nil if $mrbtest_assert_idx.empty?
    $mrbtest_child_noassert.pop

    nil
  end
  t_print("\n") if $mrbtest_verbose
end
##
# Verify a code block.
#
# str : A remark which will be printed in case
#       this assertion fails
# iso : The ISO reference code of the feature
#       which will be tested by this
#       assertion
Verify a code block.
str : A remark which will be printed in case
this assertion fails
iso : The ISO reference code of the feature
which will be tested by this
assertion
Verify a code block . str : A remark which will be printed in case this assertion fails iso : The ISO reference code of the feature which will be tested by this assertion
def assert(str = 'assert', iso = '')
  t_print(str, (iso != '' ? " [#{iso}]" : ''), ' : ') if $mrbtest_verbose
  begin
    $mrbtest_child_noassert ||= [0]
    $mrbtest_child_noassert << 0
    parent_asserts = $asserts
    $asserts = []
    parent_mrbtest_assert = $mrbtest_assert
    $mrbtest_assert = []
    if $mrbtest_assert_idx && !$mrbtest_assert_idx.empty?
      $mrbtest_assert_idx[-1] += 1
      $mrbtest_assert_idx << 0
    else
      $mrbtest_assert_idx = [0]
      class << $mrbtest_assert_idx
        alias to_s _assertion_join
      end
    end
    yield
    if $mrbtest_assert.size > 0
      if $mrbtest_assert.size == $mrbtest_child_noassert[-1]
        $asserts.push(assertion_string('Skip: ', str, iso))
        $mrbtest_child_noassert[-2] += 1
        $skip_test += 1
        t_print('?')
      else
        $asserts.push(assertion_string('Fail: ', str, iso))
        $ko_test += 1
        t_print('F')
      end
    elsif $mrbtest_assert_idx[-1] == 0
      $asserts.push(assertion_string('Warn: ', str, iso, 'no assertion'))
      $warning_test += 1
      t_print('W')
    else
      $ok_test += 1
      t_print('.')
    end
  rescue MRubyTestSkip => e
    $asserts.push(assertion_string('Skip: ', str, iso, e))
    $skip_test += 1
    $mrbtest_child_noassert[-2] += 1
    t_print('?')
  rescue Exception => e
    $asserts.push(assertion_string("#{e.class}: ", str, iso, e, e.backtrace))
    $kill_test += 1
    t_print('X')
  ensure
    if $mrbtest_assert_idx.size > 1
      $asserts.each do |mesg|
        idx = $mrbtest_assert_idx[0..-2]._assertion_join
        mesg = mesg._assertion_indent("    ")
        parent_mrbtest_assert << [idx, nil, mesg]
      end
    else
      parent_asserts.concat $asserts
    end
    $asserts = parent_asserts
    $mrbtest_assert = parent_mrbtest_assert
    $mrbtest_assert_idx.pop
    $mrbtest_assert_idx = nil if $mrbtest_assert_idx.empty?
    $mrbtest_child_noassert.pop
    nil
  end
  t_print("\n") if $mrbtest_verbose
end
def assert ( str = 'assert' , iso = '' ) t_print ( str , ( iso != '' ? " [#{iso}]" : '' ) , ' : ' ) if $mrbtest_verbose begin $mrbtest_child_noassert ||= [ 0 ] $mrbtest_child_noassert << 0 parent_asserts = $asserts $asserts = [ ] parent_mrbtest_assert = $mrbtest_assert $mrbtest_assert = [ ] if $mrbtest_assert_idx && ! $mrbtest_assert_idx . empty? $mrbtest_assert_idx [ - 1 ] += 1 $mrbtest_assert_idx << 0 else $mrbtest_assert_idx = [ 0 ] class << $mrbtest_assert_idx alias to_s _assertion_join end end yield if $mrbtest_assert . size > 0 if $mrbtest_assert . size == $mrbtest_child_noassert [ - 1 ] $asserts . push ( assertion_string ( 'Skip: ' , str , iso ) ) $mrbtest_child_noassert [ - 2 ] += 1 $skip_test += 1 t_print ( '?' ) else $asserts . push ( assertion_string ( 'Fail: ' , str , iso ) ) $ko_test += 1 t_print ( 'F' ) end elsif $mrbtest_assert_idx [ - 1 ] == 0 $asserts . push ( assertion_string ( 'Warn: ' , str , iso , 'no assertion' ) ) $warning_test += 1 t_print ( 'W' ) else $ok_test += 1 t_print ( '.' ) end rescue MRubyTestSkip => e $asserts . push ( assertion_string ( 'Skip: ' , str , iso , e ) ) $skip_test += 1 $mrbtest_child_noassert [ - 2 ] += 1 t_print ( '?' ) rescue Exception => e $asserts . push ( assertion_string ( "#{e.class}: " , str , iso , e , e . backtrace ) ) $kill_test += 1 t_print ( 'X' ) ensure if $mrbtest_assert_idx . size > 1 $asserts . each do | mesg | idx = $mrbtest_assert_idx [ 0 .. - 2 ] . _assertion_join mesg = mesg . _assertion_indent ( "    " ) parent_mrbtest_assert << [ idx , nil , mesg ] end else parent_asserts . concat $asserts end $asserts = parent_asserts $mrbtest_assert = parent_mrbtest_assert $mrbtest_assert_idx . pop $mrbtest_assert_idx = nil if $mrbtest_assert_idx . empty? $mrbtest_child_noassert . pop nil end t_print ( "\n" ) if $mrbtest_verbose end
Verify a code block.
Verify a code block .
# Give `mesg` as a `diff` argument to avoid adding extra periods.
str
iso