envutil.rb: move labeled_module and labeled_class

* test/ruby/envutil.rb (labeled_module, labeled_class): move from
  test/ruby/test_module.rb.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-02-26 04:26:09 +00:00
parent a2fb6e600c
commit 9a4185de25
2 changed files with 18 additions and 8 deletions

View File

@ -157,6 +157,22 @@ module EnvUtil
end
module_function :with_default_internal
def labeled_module(name, &block)
Module.new do
singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
class_eval(&block) if block
end
end
module_function :labeled_module
def labeled_class(name, superclass = Object, &block)
Class.new(superclass) do
singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
class_eval(&block) if block
end
end
module_function :labeled_class
if /darwin/ =~ RUBY_PLATFORM
DIAGNOSTIC_REPORTS_PATH = File.expand_path("~/Library/Logs/DiagnosticReports")
DIAGNOSTIC_REPORTS_TIMEFORMAT = '%Y-%m-%d-%H%M%S'

View File

@ -1564,17 +1564,11 @@ class TestModule < Test::Unit::TestCase
end
def labeled_module(name, &block)
Module.new do
singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
class_eval(&block) if block
end
EnvUtil.labeled_module(name, &block)
end
def labeled_class(name, superclass = Object, &block)
Class.new(superclass) do
singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
class_eval(&block) if block
end
EnvUtil.labeled_class(name, superclass, &block)
end
def test_prepend_instance_methods_false