mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
2ed68d0ff9
commit
abe12d8b96
2 changed files with 5 additions and 0 deletions
|
@ -707,6 +707,7 @@ methodref
|
|||
(VALUE ret)
|
||||
{
|
||||
ret = rb_obj_method(val, ID2SYM(id));
|
||||
RB_OBJ_FREEZE_RAW(ret);
|
||||
}
|
||||
|
||||
/**********************************************************/
|
||||
|
|
|
@ -1120,16 +1120,20 @@ class TestMethod < Test::Unit::TestCase
|
|||
|
||||
def test_method_reference_operator
|
||||
m = 1.:succ
|
||||
assert_predicate(m, :frozen?)
|
||||
assert_equal(1.method(:succ), m)
|
||||
assert_equal(2, m.())
|
||||
m = 1.:+
|
||||
assert_predicate(m, :frozen?)
|
||||
assert_equal(1.method(:+), m)
|
||||
assert_equal(42, m.(41))
|
||||
m = 1.:-@
|
||||
assert_predicate(m, :frozen?)
|
||||
assert_equal(1.method(:-@), m)
|
||||
assert_equal(-1, m.())
|
||||
o = Object.new
|
||||
def o.foo; 42; end
|
||||
assert_predicate(o.:foo, :frozen?)
|
||||
m = o.method(:foo)
|
||||
assert_equal(m, o.:foo)
|
||||
def o.method(m); nil; end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue