diff options
author | Koichi Sasada <[email protected]> | 2021-12-13 01:58:21 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2021-12-13 10:23:52 +0900 |
commit | 6659253cc6c807641e23d469b425ddcf18de7af4 (patch) | |
tree | 0fb1ac56a26c1c045bec12965b6ebdabab58ce9c /test/ruby/test_struct.rb | |
parent | 4d0cb1a54ba5e8e053e6acc860fd1cb9ca5e1b19 (diff) |
Struct setter's parameters == `[:req, :_]`
fix [Bug #18405]
Note that the parameter name `_` is not a spec, so we shouldn't
rely on this behavior.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5252
Diffstat (limited to 'test/ruby/test_struct.rb')
-rw-r--r-- | test/ruby/test_struct.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb index 0301612395..b0e6bae9e3 100644 --- a/test/ruby/test_struct.rb +++ b/test/ruby/test_struct.rb @@ -497,6 +497,21 @@ module TestStruct assert_equal(42, x.public_send("a")) end + def test_parameters + klass = @Struct.new(:a) + assert_equal [], klass.instance_method(:a).parameters + # NOTE: :_ may not be a spec. + assert_equal [[:req, :_]], klass.instance_method(:a=).parameters + + klass.module_eval do + define_method(:b=, &klass.new.method(:a=).to_proc) + alias c= a= + end + + assert_equal [[:req, :_]], klass.instance_method(:b=).parameters + assert_equal [[:req, :_]], klass.instance_method(:c=).parameters + end + class TopStruct < Test::Unit::TestCase include TestStruct |