From: TRANS Date: 2005-09-22T14:37:20+09:00 Subject: Re: Difference between class declarations On 9/22/05, nobuyoshi nakada wrote: > Hi, > > At Thu, 22 Sep 2005 13:03:15 +0900, > TRANS wrote in [ruby-core:05881]: > > So how can one get around this? I need to do so for my #testcase. i.e. > > > > testcase :TestName do > > ... > > end > > > > to have the same scoping as > > > > class TestName < Test::Unit::TestCase > > ... > > end > > What do you want to get around, precisely? Do you want a > constant defined in testcase block to be block-local? Yes. Here's the current code, in toplevel: def testcase(name=nil, &block) tc = Class.new(Test::Unit::TestCase) #self.class.const_set("TC_#{(name||$TCGEN.succ!)}", tc) $TC << tc tc.class_eval &block end A testcase needs to keep it's contents separate from other testcases, just as it would if I were explicitly suclassing Test::Unit::TestCase. (Note too the remark, how do I set the constant name at the toplevel?) Thanks, T.