Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_islibds.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mf_islibds macro
4
5 %put %mf_islibds(work.something)=1;
6 %put %mf_islibds(nolib)=0;
7 %put %mf_islibds(badlibref.ds)=0;
8 %put %mf_islibds(w.t.f)=0;
9
10 <h4> SAS Macros </h4>
11 @li mf_islibds.sas
12 @li mp_assert.sas
13 @li mp_assertscope.sas
14
15**/
16
17data _null_;
18 call symput('lf_libds','work.table'||byte(10));
19run;
20%mp_assertscope(SNAPSHOT)
21%put mf_islibds LF result: %mf_islibds(%superq(lf_libds));
22%mp_assertscope(COMPARE,
23 desc=mf_islibds does not leak macro variables,
24 outds=work.test_results
25)
26/* An unquoted trailing LF is stripped during macro argument handling, so
27 the value that reaches validation is work.table and the call is accepted. */
28%mp_assert(
29 iftrue=(%mf_islibds(&lf_libds)=1),
30 desc=Unquoted trailing LF is stripped from the macro argument,
31 outds=work.test_results
32)
33/* Macro quoting preserves the LF as a masked byte, which no longer matches
34 the libds expression, so the call is rejected. */
35%mp_assert(
36 iftrue=(%mf_islibds(%superq(lf_libds))=0),
37 desc=Reject a macro-quoted libds ending in LF,
38 outds=work.test_results
39)
40
41%mp_assert(
42 iftrue=(
43 %mf_islibds(work.something)=1
44 ),
45 desc=%str(Checking mf_islibds(work.something)=1),
46 outds=work.test_results
47)
48
49%mp_assert(
50 iftrue=(
51 %mf_islibds(nolib)=0
52 ),
53 desc=%str(Checking mf_islibds(nolib)=0),
54 outds=work.test_results
55)
56
57%mp_assert(
58 iftrue=(
59 %mf_islibds(badlibref.ds)=0
60 ),
61 desc=%str(Checking mf_islibds(badlibref.ds)=0),
62 outds=work.test_results
63)
64
65%mp_assert(
66 iftrue=(
67 %mf_islibds(w.t.f)=0
68 ),
69 desc=%str(Checking mf_islibds(w.t.f)=0),
70 outds=work.test_results
71)
72
73%mp_assert(
74 iftrue=(
75 %mf_islibds(abcdefgh.ds)=1
76 ),
77 desc=Accept 8-character libref,
78 outds=work.test_results
79)
80
81%mp_assert(
82 iftrue=(
83 %mf_islibds(1lib.ds)=0
84 ),
85 desc=Reject libref starting with a digit,
86 outds=work.test_results
87)
88
89%mp_assert(
90 iftrue=(
91 %mf_islibds(work.1data)=0
92 ),
93 desc=Reject dataset name starting with a digit,
94 outds=work.test_results
95)
96
97%mp_assert(
98 iftrue=(
99 %mf_islibds(work.st_mods)=1
100 ),
101 desc=Accept underscore in dataset name,
102 outds=work.test_results
103)
104
105%mp_assert(
106 iftrue=(
107 %mf_islibds(lib_ref.data)=1
108 ),
109 desc=Accept underscore in libref,
110 outds=work.test_results
111)
112
113%mp_assert(
114 iftrue=(
115 %mf_islibds(WORK.DATA)=1
116 ),
117 desc=Accept uppercase libref and dataset name,
118 outds=work.test_results
119)
120
121%mp_assert(
122 iftrue=(
123 %mf_islibds(w.abcdefghijklmnopqrstuvwxyz123456)=1
124 ),
125 desc=Accept 32-character dataset name,
126 outds=work.test_results
127)
128
129%mp_assert(
130 iftrue=(
131 %mf_islibds(w.abcdefghijklmnopqrstuvwxyz1234567)=0
132 ),
133 desc=Reject 33-character dataset name,
134 outds=work.test_results
135)