LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 19 Apr 2004 16:02:31 -0400
Reply-To:     "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Subject:      tip program TestMacro to execute test of macro with test suite in
              comments
Content-Type: text/plain; charset="us-ascii"

Re: Translating SAS code to a C extensionmoduleforPython

> >Not common but not rare either for Python > >(or other object-oriented language) programmers. > >Python comes with a comprehensive unit testing > >framework (based on the Java JUnit framework), > >as well as facilities > >to allow higher-level (functional) tests > >to be embedded in comment blocks in the code. > >Both can then be run automatically at installation > >or each time code or data changes.

an interesting idea

I am currently testing such a program which will read a macro and execute the test suite at the end of the macro within slash-asterisk comments

Ron Fehd the macro testing maven CDC Atlanta GA USA RJF2@cdc.gov

OpSys: Win_Pro Ver: 9.1 (TS M0)

RTFM: I'm an engineer, I don't get paid to know, I get paid to automate testing

macros written with this template:

- - - SomeMacro.sas - - - %Macro SomeMacro...;%Mend; /*testmacro run; *test suite goes here; run; /* *** */ - - - SomeMacro.sas end - - -

see SymChkIf for an example http://www.listserv.uga.edu/cgi-bin/wa?S2=sas-l&q=TESTmacro&0=S&s=&f=RJF 2&a=JAN+2004&b=

/*TestMacro program which executes test suite at end of macro in comments input : batch : SysParm session: mVar Macro process: read &macro. till '/*testmacro' write test suite to external file execute output : &Macro..log &Macro..lst note : must disable all %Let Macro = FileName; for batch use of SysParm note : at end of macro after %Mend; need these two comment lines: /*testmacro <---<<< line 1 run; <---<<< line 2 because PrintTo needs a step boundary RJF2 04Mar01 note: autoexecSite defines SASautos otherwise: filename SASautos ".";%*current program directory; %*containing macros to be tested; *** ............................... */ options mlogic mlogicnest mprint;%*v9; options nomlogic nomlogicnest nomprint;%*v9; options nomlogic nomprint;%*v8; OPTIONS notes source source2 noxwait; %Let Macro = &SysParm.;%*for batch usage; %*else provide: ; %Let Macro = array; *Let Macro = clock; *Let Macro = Invalid; %Let Macro = Nobs; *Let Macro = put_; *Let Macro = proglist; %Let Macro = SymChkIf;

*if macro is stored and compiled update Work.SASmacro catalog:; *Inc SASautos(&Macro.) /nosource2; %*local usage; %Let FileName = zXtext.sas; %Let LrecL = 72;

DATA _Null_; file "&FileName."; retain ExecTest 0; do until(EndoFile); infile SASautos(&Macro..sas) lrecl = &LrecL. pad end = EndoFile; input @1 Line $char&LrecL..; select(ExecTest); when(0) ExecTest = index(upcase(Line) ,'/*TESTMACRO') ge 1; when(1) put Line $char&LrecL..; otherwise; end; end;%*do until(EndoFile); stop;run;

PROC PrintTo log = "&Macro..log" print = "&Macro..lst" new; %Inc "&FileName." /source2; run; PROC PrintTo; %*off; run; x del &FileName.; run;


Back to: Top of message | Previous page | Main SAS-L page