diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | test/ruby/test_refinement.rb | 27 |
2 files changed, 37 insertions, 0 deletions
@@ -1,3 +1,13 @@ +Sat Nov 3 09:03:34 2012 Shugo Maeda <shugo@ruby-lang.org> + + * 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. + Sat Nov 3 04:14:19 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> * vm.c (rb_vm_rewrite_ep_in_errinfo): rewrite all catch points in 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 |