From: Wesley J Landaker Date: 2003-12-05T12:53:43+09:00 Subject: Re: Generalized break? --Boundary-02=_FFA0/BoiQtxYKOV Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline On Thursday 04 December 2003 6:59 pm, David A. Black wrote: > Yeah, I don't think the solutions where the code comes after __END__ > are really viable. I tend to use DATA to feed to tests, so I don't > want DATA to *be* the tests. It would be nice to be able to do this in a Ruby file: # main code __TEST__ # code that will be used if called directly __END__ # stuff for DATA Hmmm... on the other hand, most of my ruby files that have unit tests=20 look like this: if $0 =3D=3D __FILE__ or defined? Test::Unit require 'test/unit' =20 class SomeTest < Test::Unit::TestCase # whatever end end Then, I have something like this in a Makefile: RUNTESTS=3D-rtest/unit -e 'Dir["*.rb"].each { |f| require f }' test: @ruby $(RUNTESTS) This lets me call a file directly to test it, or have them batched for=20 regression test running very easily. I'm not sure a mechanism like __TEST__ would help me in this case=20 (although, it wouldn't *hurt*). =2D-=20 Wesley J. Landaker - wjl@icecavern.net OpenPGP FP: 4135 2A3B 4726 ACC5 9094 0097 F0A9 8A4C 4CD6 E3D2 --Boundary-02=_FFA0/BoiQtxYKOV Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQA/0AFF8KmKTEzW49IRAizYAJsE67uLOqYZUsC3usvgQeeoE5J/3gCfcZk/ XTyUAn6izlVvkKrmm5VlaGI= =a9XU -----END PGP SIGNATURE----- --Boundary-02=_FFA0/BoiQtxYKOV--