c4se記:さっちゃんですよ☆

.。oO(さっちゃんですよヾ(〃l _ l)ノ゙☆)

.。oO(此のblogは、主に音樂考察Programming に分類されますよ。ヾ(〃l _ l)ノ゙♬♪♡)

音樂は SoundCloud に公開中です。

考察は現在は主に Scrapbox で公表中です。

Programming は GitHub で開發中です。

Rubyで、D言語風にassertionを直書きする簡易unit test

まあ、なんと云ふか、めんどくさかったりするし、D言語のunittest blockが羨ましかったりするし(〃l _ l)
assertion丈使ひたいので、Module: Test::Unit::Assertions (Ruby 2.0)を読み込む。
下記を読めば解る。

# license: Public Domain

$DEBUG = true

# @param test_name [String]
def unittest test_name, &proc
  if $DEBUG
    include Test::Unit::Assertions
    proc.call
    puts "#{test_name} ok."
  end
end
if $DEBUG
  eval 'require "test/unit/assertions"'
end

unittest 'test of test' do
  assert_equal 2, 1 + 1
end