diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-06-24 15:07:00 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-07-26 07:35:58 -0700 |
commit | 4b7d7d007fa5a06d237be6f379106feea25fca79 (patch) | |
tree | f79ecb64050abbc88d3c1616fa794eda4c668026 /test | |
parent | 21ce8b3298bd3b2c8afa7fd747a958e70b55b708 (diff) | |
download | ruby-4b7d7d007fa5a06d237be6f379106feea25fca79.tar.gz |
Document and add spec for delegating to constants in Forwardable
Fixes [Bug #13142]
Diffstat (limited to 'test')
-rw-r--r-- | test/test_forwardable.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_forwardable.rb b/test/test_forwardable.rb index b3f8467c5c..0a90d3a878 100644 --- a/test/test_forwardable.rb +++ b/test/test_forwardable.rb @@ -3,6 +3,7 @@ require 'test/unit' require 'forwardable' class TestForwardable < Test::Unit::TestCase + INTEGER = 42 RECEIVER = BasicObject.new RETURNED1 = BasicObject.new RETURNED2 = BasicObject.new @@ -27,6 +28,16 @@ class TestForwardable < Test::Unit::TestCase end end + def test_def_instance_delegator_constant + %i[def_delegator def_instance_delegator].each do |m| + cls = forwardable_class do + __send__ m, 'TestForwardable::INTEGER', :to_i + end + + assert_equal 42, cls.new.to_i + end + end + def test_def_instance_delegator_using_args_method_as_receiver %i[def_delegator def_instance_delegator].each do |m| cls = forwardable_class( |