From: Jean-Hugues ROBERT Date: 2004-06-07T23:29:57+09:00 Subject: Re: Check assertion in Ruby At 17:18 07/06/2004 +0900, you wrote: >"Jean-Hugues ROBERT" schrieb im Newsbeitrag >news:6.0.1.1.0.20040605205551.01e159b0@pop.mail.yahoo.com... > >> >Seriously, who needs CPP when there is Ruby? >> > >> >def load_special(file) >> > if DEBUG >> > load file >> > else >> > Object.new.instance_eval File.read(file).gsub(/^\s*assert\b/m, >'#' ) >> > end >> >end >> >Regards >> > robert >> >> Cool ! >> Now. What about multi-lines asserts ? > >Can't be done with the simple code above. > >> If that helps I may concede a end-of-xxx marker. > >Well, the proper way would be to write a parser for a macro language. You >can get quite far with a simple hack like the one attached, although that >does only support nested macro invocations without using () for sub >macros. (Reason is that you can't parse nested brackets with regular >expressions.) > >Have fun > > robert Perfect fro me. Thanks a lot. Ruby is amazing. Yours, JeanHuguesRobert ------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17