I have a function \Foo
that I test against what I think it should expand to for given arguments. Two problems: 1/ I can't 'log' the fully expanded version of \Foo{arg}
. 2/ even when the expansion seems right by looking at the pdf output, tests based on \str_if_eq:p
fail.
Here is an excerpt of the log file corresponding to Hook 1 in the code:
\l_tmpa_tl=\Foo {A,B,C}.
I expected on the RHS of =
an expanded version thereof. Why is it not, and can it be done?
Here's the output corresponding to Hook 2 in the code:
FAIL is the result of testing for the equality of the expansion \Foo {A,B,C}
, shown on the LHS of the middle +
, against the RHS. Where does the disagreement come from?
\documentclass{l3doc}
\usepackage{xparse}
\ExplSyntaxOn
\cs_new_protected:Nn \foo_str_compare:nn
{
\exp_args:NNx \tl_set:Nn \l_tmpa_tl {#1}
\tl_log:N \l_tmpa_tl % Hook 1
\exp_last_unbraced:Nf % Hook 2
\str_if_eq:nnTF
{
{\l_tmpa_tl}
{#2}
{PASS}
{FAIL+#1+#2+}
}
}
\NewDocumentCommand{\Foo}
{m}
{
\seq_gset_from_clist:Nn \foo_seq {#1}
\seq_use:Nnnn \foo_seq{,~}{,~}{~and~}
}
\NewDocumentCommand{\Test}{}
{
\foo_str_compare:nn{\Foo{A,B,C}}{A,~B~and~C}
}
\ExplSyntaxOff
\begin{document}
\Test
\end{document}
\Foo
nor\seq_gset_from_clist:Nn
is expandable.