I'm trying to define an environment test that stores its contents unexpanded in a macro \testcontents.
For example, the code
\newcommand{\cmd}{bad}
\begin{test}
\cmd
\end{test}
\renewcommand{\cmd}{okay}
\testcontents
should print out "okay".
How would I define such an environment? I know that the environ package could be used to store the contents after expansion, but I need them unexpanded.