Macros for SAS Application Developers
https://github.com/sasjs/core
mp_assertscope.test.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Testing mp_assertscope macro
4 
5  <h4> SAS Macros </h4>
6  @li mf_getvalue.sas
7  @li mp_assert.sas
8  @li mp_assertscope.sas
9 
10 
11 **/
12 
13 %macro dostuff(action);
14  %if &action=ADD %then %do;
15  %global NEWVAR1 NEWVAR2;
16  %end;
17  %else %if &action=DEL %then %do;
18  %symdel NEWVAR1 NEWVAR2;
19  %end;
20  %else %if &action=MOD %then %do;
21  %let NEWVAR1=Let us pray..;
22  %end;
23  %else %if &action=NOTHING %then %do;
24  %local a b c d e;
25  %end;
26 %mend dostuff;
27 
28 
29 /* check for adding variables */
30 %mp_assertscope(SNAPSHOT)
31 %dostuff(ADD)
32 %mp_assertscope(COMPARE,outds=work.testing_the_tester1)
33 %mp_assert(
34  iftrue=(
35  "%mf_getvalue(work.testing_the_tester1,test_comments)"
36  ="Mod:() Add:(NEWVAR1 NEWVAR2) Del:()"
37  ),
38  desc=Checking result when vars added,
39  outds=work.test_results
40 )
41 
42 
43 /* check for modifying variables */
44 %mp_assertscope(SNAPSHOT)
45 %dostuff(MOD)
46 %mp_assertscope(COMPARE,outds=work.testing_the_tester2)
47 %mp_assert(
48  iftrue=(
49  "%mf_getvalue(work.testing_the_tester2,test_comments)"
50  ="Mod:(NEWVAR1) Add:() Del:()"
51  ),
52  desc=Checking result when vars modified,
53  outds=work.test_results
54 )
55 
56 /* check for deleting variables */
57 %mp_assertscope(SNAPSHOT)
58 %dostuff(DEL)
59 %mp_assertscope(COMPARE,outds=work.testing_the_tester3)
60 %mp_assert(
61  iftrue=(
62  "%mf_getvalue(work.testing_the_tester3,test_comments)"
63  ="Mod:() Add:() Del:(NEWVAR1 NEWVAR2)"
64  ),
65  desc=Checking result when vars deleted,
66  outds=work.test_results
67 )
68 
69 /* check for doing nothing */
70 %mp_assertscope(SNAPSHOT)
71 %dostuff(NOTHING)
72 %mp_assertscope(COMPARE,outds=work.testing_the_tester4)
73 %mp_assert(
74  iftrue=(
75  "%mf_getvalue(work.testing_the_tester4,test_comments)"
76  ="GLOBAL Variables Unmodified"
77  ),
78  desc=Checking results when nothing created,
79  outds=work.test_results
80 )