Published on :

Macro Scope Test with mp_assertscope

This code is also available in: Deutsch Español Français
This script initializes a witness variable, captures the state of macro variables (snapshot) via %mp_assertscope, executes the %example macro, then compares the final state with the initial state to ensure that no macro variables have been unexpectedly created or modified (scope leak).
Data Analysis

Type : CREATION_INTERNE


No external data source used. The test relies solely on the management of macro symbol tables.

1 Code Block
MACRO VARIABLE
Explanation :
Definition of a test macro variable to establish an initial state.
Copied!
1%let testvar=this is a test;
2 Code Block
MACRO
Explanation :
Call to the %mp_assertscope utility in 'SNAPSHOT' mode to record the current state of macro variables.
Copied!
1%mp_assertscope(SNAPSHOT)
3 Code Block
MACRO
Explanation :
Execution of the %example macro (the subject of the test) with a parameter.
Copied!
1%example(some message)
4 Code Block
MACRO
Explanation :
Call to %mp_assertscope in 'COMPARE' mode to check for differences with the snapshot and validate code cleanliness.
Copied!
1%mp_assertscope(COMPARE,desc=Checking macro variables against previous snapshot)
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.