Loading...
Searching...
No Matches
mpe_action.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mpe_action macro
4
5 <h4> SAS Macros </h4>
6 @li mp_assert.sas
7 @li mpe_action.sas
8
9 @author 4GL Apps Ltd
10 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
11 and may not be re-distributed or re-sold without the express permission of
12 4GL Apps Ltd.
13
14 @sasjslint {"maxLineLength": 80}
15
16**/
17
18/**
19 * Test 1 - an ACTION column of the input table is used
20 */
21data work.fromjs;
22 length action $10;
23 action='DIRLIST';
24run;
25%let action=;
26%mpe_action()
27%mp_assert(
28 iftrue=("&action"="DIRLIST"),
29 desc=The action column is used,
30 outds=work.test_results
31)
32
33/**
34 * Test 2 - the value is upcased, so a lower case column value still matches
35 */
36data work.fromjs;
37 length action $10;
38 action='writecheck';
39run;
40%mpe_action()
41%mp_assert(
42 iftrue=("&action"="WRITECHECK"),
43 desc=The action column is upcased,
44 outds=work.test_results
45)
46
47/**
48 * Test 3 - the column wins over an incoming macro variable, which is what a
49 * URL parameter becomes
50 */
51data work.fromjs;
52 length action $10;
53 action='MAKEDATA';
54run;
55%let action=DIRLIST;
56%mpe_action()
57%mp_assert(
58 iftrue=("&action"="MAKEDATA"),
59 desc=The action column wins over an incoming value,
60 outds=work.test_results
61)
62
63/**
64 * Test 4 - with no input table the incoming macro variable is read. This is
65 * the regression the capture exists for: a default assigned before the read
66 * would overwrite it, and this assertion is what catches that.
67 */
68proc datasets lib=work nolist nowarn;
69 delete fromjs;
70quit;
71%let action=WRITECHECK;
72%mpe_action()
73%mp_assert(
74 iftrue=("&action"="WRITECHECK"),
75 desc=An incoming value is read when there is no input table,
76 outds=work.test_results
77)
78
79/**
80 * Test 5 - nothing supplied at all is MISSING, not a default
81 */
82%let action=;
83%mpe_action()
84%mp_assert(
85 iftrue=("&action"="MISSING"),
86 desc=An absent action is reported as missing,
87 outds=work.test_results
88)
89
90/**
91 * Test 6 - a value outside the closed list is BAD, so the caller refuses it
92 * rather than resolving it as anything
93 */
94data work.fromjs;
95 length action $10;
96 action='NONSENSE';
97run;
98%mpe_action()
99%mp_assert(
100 iftrue=("&action"="BAD"),
101 desc=An unrecognised action is reported as bad,
102 outds=work.test_results
103)
104
105/**
106 * Test 7 - and the same through the macro variable route
107 */
108proc datasets lib=work nolist nowarn;
109 delete fromjs;
110quit;
111%let action=NONSENSE;
112%mpe_action()
113%mp_assert(
114 iftrue=("&action"="BAD"),
115 desc=An unrecognised incoming value is reported as bad,
116 outds=work.test_results
117)