mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4a3970c211
commit
3d88196632
2 changed files with 9 additions and 8 deletions
|
@ -319,6 +319,14 @@ EOT
|
|||
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
|
||||
|
|
|
@ -10,9 +10,6 @@ $extout_prefix = "$(extout)$(target_prefix)/"
|
|||
|
||||
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
|
|||
attr_reader :stdout
|
||||
|
||||
def mkmflog(msg)
|
||||
log = proc {MKMFLOG[] << msg}
|
||||
class << log
|
||||
alias to_s call
|
||||
end
|
||||
log
|
||||
proc {MKMFLOG[] << msg}
|
||||
end
|
||||
|
||||
def setup
|
||||
|
|
Loading…
Reference in a new issue