summaryrefslogtreecommitdiff
path: root/test/ruby/envutil.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-26 04:26:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-26 04:26:09 +0000
commit9a4185de2581fc826d3c4687e210c9264e2dae5b (patch)
tree7b400f2d28835ff3c2382588b638640bb8d85373 /test/ruby/envutil.rb
parenta2fb6e600cc3530ee481efa52521220338e4d6ee (diff)
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
Diffstat (limited to 'test/ruby/envutil.rb')
-rw-r--r--test/ruby/envutil.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb
index 2e9ebbbca2..6ef0eb6245 100644
--- a/test/ruby/envutil.rb
+++ b/test/ruby/envutil.rb
@@ -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'