1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
Koichi Sasada 2021-12-13 02:02:41 +09:00
parent 6659253cc6
commit fdfb43b2b1
Notes: git 2021-12-13 10:24:23 +09:00
2 changed files with 15 additions and 1 deletions

2
proc.c
View file

@ -2684,7 +2684,7 @@ method_def_min_max_arity(const rb_method_definition_t *def, int *max)
return 0;
case OPTIMIZED_METHOD_TYPE_STRUCT_ASET:
*max = 1;
return 0;
return 1;
default:
break;
}

View file

@ -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