From 188b67397315283a86388531f87bac4384a5af00 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 18 Dec 2018 13:59:46 +0000 Subject: Enable refinements on symbol-proc in ruby-level methods * vm_args.c (refine_sym_proc_call): resolve refinements when the proc is invoked, instead of resolving at making the proc, to enable refinements on symbol-proc in ruby-level methods * vm.c (vm_cref_dup): clear cached symbol-procs when duplicating. [Bug #15114] [Fix GH-2039] From: manga_osyo git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_symbol.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test') diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb index 36cbf4a710..6438ec8771 100644 --- a/test/ruby/test_symbol.rb +++ b/test/ruby/test_symbol.rb @@ -161,6 +161,36 @@ class TestSymbol < Test::Unit::TestCase assert_equal(1, first, bug11594) end + class TestToPRocArgWithRefinements; end + def _test_to_proc_arg_with_refinements_call(&block) + block.call TestToPRocArgWithRefinements.new + end + using Module.new { + refine TestToPRocArgWithRefinements do + def hoge + :hoge + end + end + } + def test_to_proc_arg_with_refinements + assert_equal(:hoge, _test_to_proc_arg_with_refinements_call(&:hoge)) + end + + def self._test_to_proc_arg_with_refinements_call(&block) + block.call TestToPRocArgWithRefinements.new + end + _test_to_proc_arg_with_refinements_call(&:hoge) + using Module.new { + refine TestToPRocArgWithRefinements do + def hoge + :hogehoge + end + end + } + def test_to_proc_arg_with_refinements_override + assert_equal(:hogehoge, _test_to_proc_arg_with_refinements_call(&:hoge)) + end + private def return_from_proc Proc.new { return 1 }.tap(&:call) end -- cgit v1.2.3