summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-23 01:34:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-23 01:34:01 +0000
commitc10b7435f61a463d3582359579c5a682bbf012a0 (patch)
treecaf955368e249411602fde3dea2ac18713187830
parentf856c1237b3a673a0b7dc9da45055abb52b51c17 (diff)
test_module.rb: use assertions for messages
* test/ruby/test_module.rb (TestModule#assert_top_method_is_private): use assert_separately and assert_raise_with_message for better messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_module.rb25
1 files changed, 13 insertions, 12 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index f6212f9..f8cf3c0 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1800,18 +1800,6 @@ class TestModule < Test::Unit::TestCase
assert_equal :bar, retvals[1]
end
- private
-
- def assert_top_method_is_private(method)
- top = eval("self", TOPLEVEL_BINDING)
- methods = top.singleton_class.private_instance_methods(false)
- assert(methods.include?(method), "#{method} should be private")
-
- assert_in_out_err([], <<-INPUT, [], /private method `#{method}' called for main:Object \(NoMethodError\)/)
- self.#{method}
- INPUT
- end
-
def test_prepend_gc
assert_separately [], %{
module Foo
@@ -1827,4 +1815,17 @@ class TestModule < Test::Unit::TestCase
1_000_000.times{''} # cause GC
}
end
+
+ private
+
+ def assert_top_method_is_private(method)
+ assert_separately [], %{
+ methods = singleton_class.private_instance_methods(false)
+ assert_include(methods, :#{method}, ":#{method} should be private")
+
+ assert_raise_with_message(NoMethodError, "private method `#{method}' called for main:Object") {
+ self.#{method}
+ }
+ }
+ end
end