RCR: $INCLUDED global var

“Phil Tomson” ptkwt@shell1.aracnet.com wrote in message

Sure I do. Right now I do:

Yes, I know … I was only being sarcastic.

With this suggestion it would change to:

TEST {
require ‘testunit’
#do unit testing
}

And that will be even better !

Sure I do. Right now I do:

if $0 == FILE
require ‘testunit’

#do unit testing
end

Actually, I do:

if $0 == FILE or defined? Test::Unit::TestCase
require ‘test/unit’

do unit testing

end

This gives me ability both to test the file individually (:!ruby % in
vi) as well as to include it in a project test suite where I put:

require ‘test/unit’

require ‘.rb’
require ‘.rb’

require ‘.rb’

Gennady.

dblack@superlink.net wrote in message news:Pine.LNX.4.44.0305170101001.2373-100000@candle.superlink.net

Actually, I like MAIN - it has a lot of precedent.

Precedent, baggage, whatever :slight_smile: My problem with MAIN is that it’s not
a good fit, in the sense that usually what gets put at the bottom is
test code, typically in files that really aren’t designed to be run by
themselves. So the closest equivalent to “main” is probably in
another file (i.e., one that 'require’s this file).

Good point. I don’t like TEST or DEMO because they’re too restrictive.
How about LOCAL? That even sounds like a scoping directive, which is
effectively what it is.

class MyLib



end

LOCAL {
test code
}

martin

···

On Sat, 17 May 2003, Martin DeMello wrote:

“Gennady” bystr@mac.com wrote in message

if $0 == FILE or defined? Test::Unit::TestCase
require ‘test/unit’

do unit testing

end

This gives me ability both to test the file individually (:!ruby % in
vi) as well as to include it in a project test suite where I put:

Hmmm … good idea !
I will start using it now on … thanks for sharing the tip.
– shanko

“Martin DeMello” martindemello@yahoo.com wrote in message news:42f186e.0305181137.49c123ad@posting.google.com

dblack@superlink.net wrote in message news:Pine.LNX.4.44.0305170101001.2373-100000@candle.superlink.net

Actually, I like MAIN - it has a lot of precedent.

Precedent, baggage, whatever :slight_smile: My problem with MAIN is that it’s not
a good fit, in the sense that usually what gets put at the bottom is
test code, typically in files that really aren’t designed to be run by
themselves. So the closest equivalent to “main” is probably in
another file (i.e., one that 'require’s this file).

Good point. I don’t like TEST or DEMO because they’re too restrictive.
How about LOCAL? That even sounds like a scoping directive, which is
effectively what it is.

class MyLib
.
.
.
end

LOCAL {
test code
}

martin

Attractive :wink:

local { }

daz

···

On Sat, 17 May 2003, Martin DeMello wrote: