mirror of
https://github.com/sasjs/core.git
synced 2025-12-10 22:14:35 +00:00
fix: update resetoption and adding test
This commit is contained in:
@@ -21,15 +21,19 @@ https://blogs.sas.com/content/sastraining/2012/08/14/jedi-sas-tricks-reset-sas-s
|
|||||||
%macro mp_resetoption(option /* the option to reset */
|
%macro mp_resetoption(option /* the option to reset */
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
data _null_;
|
%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do;
|
||||||
length code $1500;
|
data _null_;
|
||||||
startup=getoption("&option",'startupvalue');
|
length code $1500;
|
||||||
current=getoption("&option");
|
startup=getoption("&option",'startupvalue');
|
||||||
if startup ne current then do;
|
current=getoption("&option");
|
||||||
code =cat('OPTIONS ',getoption("&option",'keyword','startupvalue'),';');
|
if startup ne current then do;
|
||||||
putlog "NOTE: Resetting system option: " code ;
|
code =cat('OPTIONS ',getoption("&option",'keyword','startupvalue'),';');
|
||||||
call execute(code );
|
putlog "NOTE: Resetting system option: " code ;
|
||||||
end;
|
call execute(code );
|
||||||
run;
|
end;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
%put &sysmacroname: reset option feature unavailable on &sysvlong;
|
||||||
|
%end;
|
||||||
%mend mp_resetoption;
|
%mend mp_resetoption;
|
||||||
31
tests/crossplatform/mp_resetoption.test.sas
Normal file
31
tests/crossplatform/mp_resetoption.test.sas
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_resetoption macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
@li mp_resetoption.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
%let orig=%sysfunc(getoption(obs));
|
||||||
|
|
||||||
|
options obs=30;
|
||||||
|
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
%mp_resetoption(OBS)
|
||||||
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
|
%let new=%sysfunc(ifc(
|
||||||
|
"%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5",
|
||||||
|
%sysfunc(getoption(obs)), /* test it worked */
|
||||||
|
&orig /* cannot test as option unavailable */
|
||||||
|
));
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&new=&orig),
|
||||||
|
desc=Checking option was reset (if reset option available),
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user