From d2fd7f32c8f4b134dc6716903be3be0f6c67760b Mon Sep 17 00:00:00 2001 From: shugo Date: Sat, 3 Nov 2012 00:09:26 +0000 Subject: * test/ruby/test_refinement.rb (test_new_method_by_send, test_new_method_by_method_object): add tests for Kernel#send and Kernel#method with refinements. * test/ruby/test_refinement.rb (test_symbol_to_proc): add a test calling a proc created by Symbol#to_proc outside the scope where a refinement is closed over. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_refinement.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index eee66105b1..20542d6492 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -72,6 +72,14 @@ class TestRefinement < Test::Unit::TestCase return foo.z end + def self.send_z_on(foo) + return foo.send(:z) + end + + def self.method_z(foo) + return foo.method(:z) + end + def self.invoke_call_x_on(foo) return foo.call_x end @@ -114,6 +122,20 @@ class TestRefinement < Test::Unit::TestCase assert_raise(NoMethodError) { foo.z } end + def test_new_method_by_send + foo = Foo.new + assert_raise(NoMethodError) { foo.send(:z) } + assert_equal("FooExt#z", FooExtClient.send_z_on(foo)) + assert_raise(NoMethodError) { foo.send(:z) } + end + + def test_new_method_by_method_object + foo = Foo.new + assert_raise(NoMethodError) { foo.send(:z) } + assert_equal("FooExt#z", FooExtClient.method_z(foo).call) + assert_raise(NoMethodError) { foo.send(:z) } + end + def test_no_local_rebinding foo = Foo.new assert_equal("Foo#x", foo.call_x) @@ -616,11 +638,16 @@ class TestRefinement < Test::Unit::TestCase c = C.new :foo.to_proc.call(c) end + + def self.foo_proc + :foo.to_proc + end end end def test_symbol_to_proc assert_equal("foo", SymbolToProc::M.call_foo) + assert_equal("foo", SymbolToProc::M.foo_proc.call(SymbolToProc::C.new)) end module Inspect -- cgit v1.2.3