aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_symbol.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-18 13:59:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-18 13:59:46 +0000
commit188b67397315283a86388531f87bac4384a5af00 (patch)
tree4ac8ab419dae7e469eae3544b43ab8c2f707b48b /test/ruby/test_symbol.rb
parent1df9c2bc1cde43d454146691ea9a68f2ff6fbe16 (diff)
downloadruby-188b67397315283a86388531f87bac4384a5af00.tar.gz
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 <manga.osyo@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_symbol.rb')
-rw-r--r--test/ruby/test_symbol.rb30
1 files changed, 30 insertions, 0 deletions
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