Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: [patch] Re: test/unit inconsistencies between 1.9 and 1.8
Mauricio Fernández
4/26/2007 9:46:00 AM
On Thu, Apr 26, 2007 at 03:56:25PM +0900, Adam Bozanich wrote:
> I located the problem, below is a small patch ( copy & paste from
> 1.8sources ).
>
> It appears that a block/proc with no arguments has arity -1.
>
> irb(main):001:0> proc { }.arity
> => -1
> irb(main):002:0> proc {|| }.arity
> => -1
>
> and that somebody forgot about that below.
>
> -Adam
>
> Index: lib/test/unit/testcase.rb
> ===================================================================
> --- lib/test/unit/testcase.rb (revision 12221)
> +++ lib/test/unit/testcase.rb (working copy)
[...]
?
AFAIK #arity was redefined in 1.9 to return 0 for Procs with no arguments.
That patch was applied to 1.8 three years ago but it's not supposed to be
needed on 1.9, see [ruby-core:2829].
Also,
RUBY_VERSION # => "1.9.0"
RUBY_RELEASE_DATE # => "2007-02-07"
proc{}.arity # => 0
proc{||}.arity # => 0
Proc.new{}.arity # => 0
require 'test/unit'
class TC < Test::Unit::TestCase
define_method("test_foo"){ assert true }
end
# >> Loaded suite -
# >> Started
# >> .
# >> Finished in 0.001363 seconds.
# >>
# >> 1 tests, 1 assertions, 0 failures, 0 errors
I can't see any recent reference to arity in the Changelog, and
proc_arity is identical to the one in my build:
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/proc.c?revision=12212&v...
Has this really changed in the last couple months? If so, there's a bug,
either in the Rdoc documentation or the code.
--
Mauricio Fernandez -
http://eige...
- singular Ruby
** Latest postings **
On GC and finalizers in Ruby, corrected weak hash table implementations
http://eige...
/hiki/deferred-finalizers-in-Ruby
simplefold: better vim folding (Ruby, Objective Caml, Perl, PHP, Java)
http://eige...
/hiki/simplefold
1 Answer
Mauricio Fernández
4/26/2007 10:29:00 AM
0
On Thu, Apr 26, 2007 at 06:56:45PM +0900, Adam Bozanich wrote:
> On 4/26/07, Mauricio Fernandez <mfp@acm.org> wrote:
> >RUBY_VERSION # => "1.9.0"
> >RUBY_RELEASE_DATE # => "2007-02-07"
> >proc{}.arity # => 0
> >proc{||}.arity # => 0
> >Proc.new{}.arity # => 0
>
> Strange, must be a regression.
>
> irb(main):001:0> RUBY_VERSION
> => "1.9.0"
> irb(main):002:0> RUBY_RELEASE_DATE
> => "2007-04-26"
> irb(main):003:0> proc{}.arity
> => -1
> irb(main):004:0> proc{||}.arity
> => -1
> irb(main):005:0> Proc.new{}.arity
> => -1
Yes, I've traced it back to this:
Wed Mar 21 20:05:07 2007 Koichi Sasada <ko1@atdot.net>
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
I've sent a bug report to ruby-core.
--
Mauricio Fernandez -
http://eige...
- singular Ruby
** Latest postings **
On GC and finalizers in Ruby, corrected weak hash table implementations
http://eige...
/hiki/deferred-finalizers-in-Ruby
simplefold: better vim folding (Ruby, Objective Caml, Perl, PHP, Java)
http://eige...
/hiki/simplefold
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: [patch] Re: test/unit inconsistencies between 1.9 and 1.8
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password