1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add Method#=== that invokes #call

Patch by osyo via [Feature #14142]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
a_matsuda 2017-12-12 12:12:38 +00:00
parent 2ce0847e9e
commit 476a539ff6
2 changed files with 7 additions and 0 deletions

1
proc.c
View file

@ -3124,6 +3124,7 @@ Init_Proc(void)
rb_define_method(rb_cMethod, "hash", method_hash, 0);
rb_define_method(rb_cMethod, "clone", method_clone, 0);
rb_define_method(rb_cMethod, "call", rb_method_call, -1);
rb_define_method(rb_cMethod, "===", rb_method_call, -1);
rb_define_method(rb_cMethod, "curry", rb_method_curry, -1);
rb_define_method(rb_cMethod, "[]", rb_method_call, -1);
rb_define_method(rb_cMethod, "arity", method_arity_m, 0);

View file

@ -1017,4 +1017,10 @@ class TestMethod < Test::Unit::TestCase
# without trace insn
assert_separately [], "RubyVM::InstructionSequence.compile_option = {trace_instruction: false}\n" + body
end
def test_eqq
assert(Method.instance_methods(false).include? :===)
assert_operator(0.method(:<), :===, 5)
assert_not_operator(0.method(:<), :===, -5)
end
end