summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2021-12-13 02:02:41 +0900
committerKoichi Sasada <ko1@atdot.net>2021-12-13 10:23:52 +0900
commitfdfb43b2b129afb78c352c95776118eeceb245a2 (patch)
tree9b06149bb01316743f685936bc7905703e41059f /test/ruby
parent6659253cc6c807641e23d469b425ddcf18de7af4 (diff)
fix Struct's setter arity
https://github.com/ruby/ruby/pull/5131/files#diff-b2553d23e6b1fe76e20608d06c25f6acca06279100f1a9c24febcd79a82fac3cR2689
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5252
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_struct.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb
index b0e6bae9e3..5a39ecc3aa 100644
--- a/test/ruby/test_struct.rb
+++ b/test/ruby/test_struct.rb
@@ -497,6 +497,20 @@ module TestStruct
assert_equal(42, x.public_send("a"))
end
+ def test_arity
+ klass = @Struct.new(:a)
+ assert_equal 0, klass.instance_method(:a).arity
+ assert_equal 1, klass.instance_method(:a=).arity
+
+ klass.module_eval do
+ define_method(:b=, &klass.new.method(:a=).to_proc)
+ alias c= a=
+ end
+
+ assert_equal 1, klass.instance_method(:b=).arity
+ assert_equal 1, klass.instance_method(:c=).arity
+ end
+
def test_parameters
klass = @Struct.new(:a)
assert_equal [], klass.instance_method(:a).parameters