diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-03 00:09:26 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-03 00:09:26 +0000 |
commit | d2fd7f32c8f4b134dc6716903be3be0f6c67760b (patch) | |
tree | f77d935eeaf0307f867526df4e71c08e03e4a99d | |
parent | f7894e422a935d975f7fc4130b73fefba16a9433 (diff) | |
download | ruby-d2fd7f32c8f4b134dc6716903be3be0f6c67760b.tar.gz |
* 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
-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 |