Passed block symbol to proc
* proc.c (passed_block): convert passed block symbol to proc. based on the patch by Daisuke Sato in [ruby-dev:49695]. [Bug #12531] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e3503ee218
commit
86a756ae15
@ -1,3 +1,9 @@
|
|||||||
|
Wed Jun 29 08:45:53 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* proc.c (passed_block): convert passed block symbol to proc.
|
||||||
|
based on the patch by Daisuke Sato in [ruby-dev:49695].
|
||||||
|
[Bug #12531]
|
||||||
|
|
||||||
Wed Jun 29 03:34:41 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
Wed Jun 29 03:34:41 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* bignum.c (rb_big2ulong): the old logic seems to try to avoid
|
* bignum.c (rb_big2ulong): the old logic seems to try to avoid
|
||||||
|
3
proc.c
3
proc.c
@ -820,6 +820,9 @@ passed_block(VALUE pass_procval)
|
|||||||
{
|
{
|
||||||
if (!NIL_P(pass_procval)) {
|
if (!NIL_P(pass_procval)) {
|
||||||
rb_proc_t *pass_proc;
|
rb_proc_t *pass_proc;
|
||||||
|
if (SYMBOL_P(pass_procval)) {
|
||||||
|
pass_procval = sym_proc_new(rb_cProc, pass_procval);
|
||||||
|
}
|
||||||
GetProcPtr(pass_procval, pass_proc);
|
GetProcPtr(pass_procval, pass_proc);
|
||||||
return &pass_proc->block;
|
return &pass_proc->block;
|
||||||
}
|
}
|
||||||
|
@ -229,6 +229,35 @@ class TestSymbol < Test::Unit::TestCase
|
|||||||
assert_equal([false, false], m2.call(self, m2), "#{bug8531} nested without block")
|
assert_equal([false, false], m2.call(self, m2), "#{bug8531} nested without block")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_block_curry_proc
|
||||||
|
assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
|
||||||
|
begin;
|
||||||
|
b = proc { true }.curry
|
||||||
|
assert(b.call, "without block")
|
||||||
|
assert(b.call { |o| o.to_s }, "with block")
|
||||||
|
assert(b.call(&:to_s), "with sym block")
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_block_curry_lambda
|
||||||
|
assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
|
||||||
|
begin;
|
||||||
|
b = lambda { true }.curry
|
||||||
|
assert(b.call, "without block")
|
||||||
|
assert(b.call { |o| o.to_s }, "with block")
|
||||||
|
assert(b.call(&:to_s), "with sym block")
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_block_method_to_proc
|
||||||
|
assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
|
||||||
|
begin;
|
||||||
|
b = method(:tap).to_proc
|
||||||
|
assert(b.call { |o| o.to_s }, "with block")
|
||||||
|
assert(b.call(&:to_s), "with sym block")
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
|
||||||
def test_succ
|
def test_succ
|
||||||
assert_equal(:fop, :foo.succ)
|
assert_equal(:fop, :foo.succ)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user