1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
shugo 2012-11-03 00:09:26 +00:00
parent f7894e422a
commit d2fd7f32c8
2 changed files with 37 additions and 0 deletions

View file

@ -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> 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 * vm.c (rb_vm_rewrite_ep_in_errinfo): rewrite all catch points in

View file

@ -72,6 +72,14 @@ class TestRefinement < Test::Unit::TestCase
return foo.z return foo.z
end 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) def self.invoke_call_x_on(foo)
return foo.call_x return foo.call_x
end end
@ -114,6 +122,20 @@ class TestRefinement < Test::Unit::TestCase
assert_raise(NoMethodError) { foo.z } assert_raise(NoMethodError) { foo.z }
end 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 def test_no_local_rebinding
foo = Foo.new foo = Foo.new
assert_equal("Foo#x", foo.call_x) assert_equal("Foo#x", foo.call_x)
@ -616,11 +638,16 @@ class TestRefinement < Test::Unit::TestCase
c = C.new c = C.new
:foo.to_proc.call(c) :foo.to_proc.call(c)
end end
def self.foo_proc
:foo.to_proc
end
end end
end end
def test_symbol_to_proc def test_symbol_to_proc
assert_equal("foo", SymbolToProc::M.call_foo) assert_equal("foo", SymbolToProc::M.call_foo)
assert_equal("foo", SymbolToProc::M.foo_proc.call(SymbolToProc::C.new))
end end
module Inspect module Inspect