mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (proc_eq): avoid false positive by using scope and
dyna_vars. no longer use frame.uniq. * eval.c (proc_arity): arity is now defined as number of parameters that would not be ignored. i.e. Proc.new{}.arity returns zero. update test suites too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
311fdfdfea
commit
c223709c3b
6 changed files with 18 additions and 9 deletions
|
@ -10,6 +10,15 @@ Thu Mar 18 17:46:35 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
|
|||
|
||||
* lib/drb/drb.rb: do not undef :to_a.
|
||||
|
||||
Thu Mar 18 16:22:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (proc_eq): avoid false positive by using scope and
|
||||
dyna_vars. no longer use frame.uniq.
|
||||
|
||||
* eval.c (proc_arity): arity is now defined as number of
|
||||
parameters that would not be ignored. i.e. Proc.new{}.arity
|
||||
returns zero. update test suites too.
|
||||
|
||||
Thu Mar 18 15:27:25 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c: remove specialized version of rb_Array(). use simple
|
||||
|
|
6
eval.c
6
eval.c
|
@ -8160,9 +8160,8 @@ proc_arity(proc)
|
|||
data->body->nd_cfnc == bmcall) {
|
||||
return method_arity(data->body->nd_tval);
|
||||
}
|
||||
return INT2FIX(-1);
|
||||
return INT2FIX(0);
|
||||
}
|
||||
if (!(data->flags & BLOCK_LAMBDA)) return INT2FIX(-1);
|
||||
if (data->var == (NODE*)1) return INT2FIX(0);
|
||||
if (data->var == (NODE*)2) return INT2FIX(0);
|
||||
switch (nd_type(data->var)) {
|
||||
|
@ -8202,7 +8201,8 @@ proc_eq(self, other)
|
|||
Data_Get_Struct(other, struct BLOCK, data2);
|
||||
if (data->body != data2->body) return Qfalse;
|
||||
if (data->var != data2->var) return Qfalse;
|
||||
if (data->frame.uniq != data2->frame.uniq) return Qfalse;
|
||||
if (data->scope != data2->scope) return Qfalse;
|
||||
if (data->dyna_vars != data2->dyna_vars) return Qfalse;
|
||||
if (data->flags != data2->flags) return Qfalse;
|
||||
|
||||
return Qtrue;
|
||||
|
|
|
@ -1000,7 +1000,7 @@ module DRb
|
|||
end
|
||||
|
||||
undef :to_s
|
||||
undef :to_a if respond_to?(:respond_to)
|
||||
undef :to_a if respond_to?(:to_a)
|
||||
undef :respond_to?
|
||||
|
||||
# Routes method calls to the referenced object.
|
||||
|
|
|
@ -353,7 +353,7 @@ class Range
|
|||
def to_yaml( opts = {} )
|
||||
YAML::quick_emit( nil, opts ) { |out|
|
||||
out << "!ruby/range "
|
||||
self.to_s.to_yaml( :Emitter => out )
|
||||
self.to_s.to_yaml(:Emitter => out)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -311,8 +311,8 @@ class TestIterator < Test::Unit::TestCase
|
|||
|
||||
block = get_block{11}
|
||||
lambda = lambda{44}
|
||||
assert_equal(-1, block.arity)
|
||||
assert_equal(-1, lambda.arity)
|
||||
assert_equal(0, block.arity)
|
||||
assert_equal(0, lambda.arity)
|
||||
assert_equal(0, lambda{||}.arity)
|
||||
assert_equal(1, lambda{|a|}.arity)
|
||||
assert_equal(1, lambda{|a,|}.arity)
|
||||
|
|
|
@ -50,7 +50,7 @@ class TestProc < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_arity
|
||||
assert_equal(-1, proc{}.arity)
|
||||
assert_equal(0, proc{}.arity)
|
||||
assert_equal(0, proc{||}.arity)
|
||||
assert_equal(1, proc{|x|}.arity)
|
||||
assert_equal(2, proc{|x, y|}.arity)
|
||||
|
@ -58,7 +58,7 @@ class TestProc < Test::Unit::TestCase
|
|||
assert_equal(-1, proc{|*x|}.arity)
|
||||
assert_equal(-1, proc{|*|}.arity)
|
||||
|
||||
assert_arity(-1) {}
|
||||
assert_arity(0) {}
|
||||
assert_arity(0) {||}
|
||||
assert_arity(1) {|x|}
|
||||
assert_arity(2) {|x, y|}
|
||||
|
|
Loading…
Reference in a new issue