summaryrefslogtreecommitdiff
path: root/test/ruby/test_struct.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_struct.rb')
-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