ruby-changes:27586
From: nobu <ko1@a...>
Date: Fri, 8 Mar 2013 16:02:49 +0900 (JST)
Subject: [ruby-changes:27586] nobu:r39638 (trunk): assertions.rb: allow proc
nobu 2013-03-08 16:02:37 +0900 (Fri, 08 Mar 2013) New Revision: 39638 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39638 Log: assertions.rb: allow proc * lib/test/unit/assertions.rb (Test::Unit::Assertions#message): convert msg by call if it is a proc, as well as assert. Modified files: trunk/lib/test/unit/assertions.rb trunk/test/mkmf/base.rb Index: lib/test/unit/assertions.rb =================================================================== --- lib/test/unit/assertions.rb (revision 39637) +++ lib/test/unit/assertions.rb (revision 39638) @@ -319,6 +319,14 @@ EOT https://github.com/ruby/ruby/blob/trunk/lib/test/unit/assertions.rb#L319 template &&= template.chomp template.gsub(/\G((?:[^\\]|\\.)*?)(\\)?\?/) { $1 + ($2 ? "?" : mu_pp(arguments.shift)) } end + + def message(msg = nil, *args, &default) + if Proc === msg + super(nil, *args) {"#{msg.call}#{default.call if default}"} + else + super + end + end end end end Index: test/mkmf/base.rb =================================================================== --- test/mkmf/base.rb (revision 39637) +++ test/mkmf/base.rb (revision 39638) @@ -10,9 +10,6 @@ $extout_prefix = "$(extout)$(target_pref https://github.com/ruby/ruby/blob/trunk/test/mkmf/base.rb#L10 class TestMkmf < Test::Unit::TestCase MKMFLOG = proc {File.read("mkmf.log") rescue ""} - class << MKMFLOG - alias to_s call - end class Capture attr_accessor :origin @@ -54,11 +51,7 @@ class TestMkmf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/mkmf/base.rb#L51 attr_reader :stdout def mkmflog(msg) - log = proc {MKMFLOG[] << msg} - class << log - alias to_s call - end - log + proc {MKMFLOG[] << msg} end def setup -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/