Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_dropmembers.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_dropmembers macro
4
5 <h4> SAS Macros </h4>
6 @li mp_dropmembers.sas
7 @li mf_existds.sas
8 @li mp_reseterror.sas
9 @li mp_assert.sas
10 @li mp_assertscope.sas
11
12**/
13
14data work.drop_scope work.drop_a work.drop_b work.drop_keep1
15 work.drop_keep2;
16 x=1;
17 output;
18run;
19
20/* mp_dropmembers emits statements, so it is called in open code rather
21 than inside a %put */
22%mp_assertscope(SNAPSHOT)
23%mp_dropmembers(list=drop_scope)
24%mp_assertscope(COMPARE,
25 desc=Checking that mp_dropmembers does not leak scope,
26 outds=work.test_results
27)
28
29%mp_dropmembers(list=drop_a)
30
31%mp_assert(
32 iftrue=(%mf_existds(work.drop_a)=0),
33 desc=Checking that a listed dataset is dropped,
34 outds=work.test_results
35)
36
37%mp_assert(
38 iftrue=(%mf_existds(work.drop_b)=1),
39 desc=Checking that an unlisted dataset is kept,
40 outds=work.test_results
41)
42
43/* a view is dropped by the /mtype=view pass, so the data-file pass has
44 nothing to delete - clear that expected message before asserting */
45proc sql;
46 create view work.drop_view as select * from work.drop_b;
47quit;
48
49%mp_dropmembers(list=drop_view)
50%mp_reseterror()
51
52%mp_assert(
53 iftrue=(%mf_existds(work.drop_view)=0),
54 desc=Checking that a listed view is dropped,
55 outds=work.test_results
56)
57
58/* a false condition leaves the library untouched */
59%mp_dropmembers(list=drop_keep1,iftrue=(1=0))
60%mp_assert(
61 iftrue=(%mf_existds(work.drop_keep1)=1),
62 desc=Checking that a false iftrue condition drops nothing,
63 outds=work.test_results
64)
65
66/* a true condition still drops the member */
67%mp_dropmembers(list=drop_keep2,iftrue=(1=1))
68%mp_assert(
69 iftrue=(%mf_existds(work.drop_keep2)=0),
70 desc=Checking that a true iftrue condition drops the member,
71 outds=work.test_results
72)