[#6363] Re: rescue clause affecting IO loop behavior — ts <decoux@...>

>>>>> "D" == David Alan Black <dblack@candle.superlink.net> writes:

17 messages 2000/11/14
[#6367] Re: rescue clause affecting IO loop behavior — David Alan Black <dblack@...> 2000/11/14

Hello again --

[#6582] best way to interleaf arrays? — David Alan Black <dblack@...>

Hello --

15 messages 2000/11/26

[#6646] RE: Array Intersect (&) question — Aleksi Niemel<aleksi.niemela@...>

Ross asked something about widely known and largely ignored language (on

23 messages 2000/11/29
[#6652] RE: Array Intersect (&) question — rpmohn@... (Ross Mohn) 2000/11/29

aleksi.niemela@cinnober.com (Aleksi Niemel) wrote in

[#6723] Re: Array Intersect (&) question — Mathieu Bouchard <matju@...> 2000/12/01

> >Use a hash. Here's code to do both and more. It assumes that

[#6656] printing/accessing arrays and hashes — raja@... (Raja S.)

I'm coming to Ruby with a Python & Common Lisp background.

24 messages 2000/11/30

[ruby-talk:5996] Re: More RubyUnit questions.

From: Hugh Sasse Staff Elec Eng <hgs@...>
Date: 2000-11-02 15:15:48 UTC
List: ruby-talk #5996
On 15 Aug 2000, Dave Thomas wrote:

> Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
> 
> > module RUNIT
      class TestCase
> >     def TestCase.suite
> >       TestSuite.new(self)
> >     end
> >   end
> > end
> > 
> > def TestCase.suite looks like the definition of a singleton method, but it
> > is not because it is not defining a method of a particular instance. What
> > is this?
> 
> You are right, it _is_ a singleton method, but of class
> RUNIT::TestCase.
> 
> The rule here is straightforward, but gets confusing because of all
> the weird terminology.
> 
>   "If a method is defined as
> 
>       def x.y
>       end
> 
>    then 'y' must be called with a received of 'x' (or a subclass of x)."

OK...
> 
> So:
> 
>    def TestCase.suite
>    end
> 
> must be called as  TestCase.suite(....), and
> 
>    d = Dave.new
>    def d.getSomeSleep
>    end
> 
> must be called with a receiver of 'd'.

Hmmm, so why is this being done *inside* the class definition of TestCase,
because non-singleton methods defined there can only have receivers of
TestCase anyway? What extras do you get?  Doing this outside has its use
like your getSomeSleep example; I can see that.
> 
> 
> 
> So, back to the TestSuite thing. The 'suite' method is used to return
> a list of the tests to be run. The default behavior is to construct a
> list of all the methods in the receiver whose names begin with
> 'test_'. However, you can override this if you want.
> 
Oh. Ok I will explore this some more....
> 
>      require 'runit/testcase'
>      require 'runit/cui/testrunner'
> 
>      class TestCoffee < RUNIT::TestCase
>        def setup
>          @pot = brew
>        end
>        def test_full
>          assert(@pot.full)
>          assert(@pot.temperature > 80)
>        end
>        def test_aroma
>          sniffer = Nose.new
>          assert_equal("rich, dark aroma", sniffer.sniff(@pot))
>        end
>        # and so on
>      end
> 
>      # build a list of tests, and run them
>      RUNIT::CUI::TestRunner.run(TestCoffee.suite)

Yes, that is nice to have.
> 
> Regards
> 
> 
> Dave
> 
	Thank you,
	Hugh
	hgs@dmu.ac.uk



In This Thread