mirror of
https://github.com/sasjs/core.git
synced 2026-01-08 18:00:06 +00:00
chore(docs): assertscope
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Used to capture scope leakage of macro variables
|
@brief Used to capture scope leakage of macro variables
|
||||||
@details A common 'difficult to detect' bug in macros is where a nested
|
@details
|
||||||
macro over-writes variables in a higher level macro.
|
|
||||||
|
|
||||||
This assertion takes a snapshot of the macro variables before and after
|
A common 'difficult to detect' bug in macros is where a nested macro
|
||||||
a macro invocation. This makes it easy to detect whether any macro
|
over-writes variables in a higher level macro.
|
||||||
variables were modified or changed.
|
|
||||||
|
|
||||||
Currently, the macro only checks for global scope variables. In the future
|
This assertion takes a snapshot of the macro variables before and after
|
||||||
it may be extended to work at multiple levels of nesting.
|
a macro invocation. Differences are captured in the `&outds` table. This
|
||||||
|
makes it easy to detect whether any macro variables were modified or
|
||||||
|
changed.
|
||||||
|
|
||||||
If you would like this feature, feel free to contribute / raise an issue /
|
If you would like this feature, feel free to contribute / raise an issue /
|
||||||
engage the SASjs team directly.
|
engage the SASjs team directly.
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
|
|
||||||
@@ -24,6 +24,9 @@
|
|||||||
desc=Checking macro variables against previous snapshot
|
desc=Checking macro variables against previous snapshot
|
||||||
)
|
)
|
||||||
|
|
||||||
|
This macro is designed to work alongside `sasjs test` - for more information
|
||||||
|
about this facility, visit [cli.sasjs.io/test](https://cli.sasjs.io/test).
|
||||||
|
|
||||||
@param [in] action (SNAPSHOT) The action to take. Valid values:
|
@param [in] action (SNAPSHOT) The action to take. Valid values:
|
||||||
@li SNAPSHOT - take a copy of the current macro variables
|
@li SNAPSHOT - take a copy of the current macro variables
|
||||||
@li COMPARE - compare the current macro variables against previous values
|
@li COMPARE - compare the current macro variables against previous values
|
||||||
|
|||||||
41
tests/crossplatform/mp_stackdiffs.test.sas
Normal file
41
tests/crossplatform/mp_stackdiffs.test.sas
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_storediffs macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertcolvals.sas
|
||||||
|
@li mp_assertdsobs.sas
|
||||||
|
@li mp_stackdiffs.sas
|
||||||
|
@li mp_storediffs.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
/* first, make some data */
|
||||||
|
|
||||||
|
data work.orig work.deleted work.changed work.appended;
|
||||||
|
set sashelp.electric;
|
||||||
|
if _n_ le 10 then do;
|
||||||
|
output work.orig work.deleted;
|
||||||
|
end;
|
||||||
|
else if _n_ le 20 then do;
|
||||||
|
output work.orig;
|
||||||
|
age=99;
|
||||||
|
output work.changed;
|
||||||
|
end;
|
||||||
|
else if _n_ le 30 then do;
|
||||||
|
year=_n_;
|
||||||
|
output work.appended;
|
||||||
|
end;
|
||||||
|
else stop;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_storediffs(sashelp.electric,work.orig,CUSTOMER YEAR
|
||||||
|
,delds=work.deleted
|
||||||
|
,modds=work.changed
|
||||||
|
,appds=work.appended
|
||||||
|
,outds=work.final
|
||||||
|
,mdebug=1
|
||||||
|
)
|
||||||
|
|
||||||
|
/* now, stack it back */
|
||||||
Reference in New Issue
Block a user