Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
ml_json.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing ml_json macro
4 @details ml_json writes json.lua to the work directory and includes it, so a
5 test needs no Lua source of its own: the artefact is the file. The suite
6 runs with options lrecl=80, which is narrow enough to truncate the
7 library's wider lines as they are written, so a file that keeps records
8 longer than 80 characters proves the write ran under the wide LRECL the
9 macro sets, and a clean syscc proves the include worked.
10
11 <h4> SAS Macros </h4>
12 @li mf_getuniquefileref.sas
13 @li ml_json.sas
14 @li mp_assert.sas
15 @li mp_assertscope.sas
16
17**/
18
19/* ml_json writes a 375-line DATA step, and echoing it (plus MPRINT from the
20 suite's _debug URL) fills the engine's job log past its limit - the job is
21 then aborted before the term program returns a result. Quiet the source
22 echo for this file; the assertions are PUT output, which is unaffected. */
23options nosource nomprint;
24
25%let luapath=%sysfunc(pathname(work))/ml_json.lua;
26%let lua_exists=0;
27%let lua_marker=0;
28%let lua_syscc=0;
29
30%mp_assertscope(SNAPSHOT)
31%ml_json()
32%let lua_syscc=&syscc;
33%mp_assertscope(COMPARE,
34 desc=ml_json does not leak scope,
35 ignorelist=LUA_SYSCC,
36 outds=work.test_results
37)
38
39%let lua_exists=%sysfunc(fileexist(&luapath));
40%let fref=%mf_getuniquefileref();
41filename &fref "&luapath";
42data _null_;
43 infile &fref lrecl=1024 end=eof;
44 input line $char1024.;
45 /* a record longer than 80 characters cannot exist in a file written under
46 lrecl=80, so finding one proves the wide setting was in force */
47 if length(line)>80 then call symputx('lua_marker',1,'l');
48run;
49
50%mp_assert(
51 iftrue=(&lua_exists=1),
52 desc=Check json.lua was written to the work directory
53)
54%mp_assert(
55 iftrue=(&lua_marker=1),
56 desc=Check the file keeps records wider than 80 characters
57)
58%mp_assert(
59 iftrue=(&lua_syscc=0),
60 desc=Check including the lua file leaves syscc clean
61)