ruby-changes:30939
From: nobu <ko1@a...>
Date: Mon, 23 Sep 2013 10:34:08 +0900 (JST)
Subject: [ruby-changes:30939] nobu:r43018 (trunk): test_module.rb: use assertions for messages
nobu 2013-09-23 10:34:01 +0900 (Mon, 23 Sep 2013) New Revision: 43018 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43018 Log: 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. Modified files: trunk/test/ruby/test_module.rb Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 43017) +++ test/ruby/test_module.rb (revision 43018) @@ -1800,18 +1800,6 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1800 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1815 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/