From: Mauricio Fernandez Date: 2007-04-26T18:45:34+09:00 Subject: Re: [patch] Re: test/unit inconsistencies between 1.9 and 1.8 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&view=markup 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://eigenclass.org - singular Ruby ** Latest postings ** On GC and finalizers in Ruby, corrected weak hash table implementations http://eigenclass.org/hiki/deferred-finalizers-in-Ruby simplefold: better vim folding (Ruby, Objective Caml, Perl, PHP, Java) http://eigenclass.org/hiki/simplefold