I want to test if two macro have identical definition. My naive attempt to use \detokenize does not seem to work in this simple case. However, I have used a similar approach before and it seems to have worked on a much more complicated case, but now that it fails with this simple test case I am a bit confused:
Since the \meaning of \iff and \MyIffWithDotsbNonStar is identical I would have expected them to match.
Related (but different):
MWE
\documentclass{article}
\usepackage{mathtools}
\usepackage{xstring}
\usepackage{xcolor}
\usepackage{bm}% only for highlighting thre cross
\usepackage{amssymb}% only for checkmark symbol
\usepackage[paperwidth=10in]{geometry}% for better display of output
\newcommand{\MyIffWithDotsbNonStar}{\DOTSB;\Longleftrightarrow ;}
\newcommand{\MyIffWithoutDotsbNonStar}{;\Longleftrightarrow ;}
\newcommand{\MyIffWithDotsbStar}{\DOTSB;\Longleftrightarrow ;}
\newcommand{\MyIffWithoutDotsbStar}{;\Longleftrightarrow ;}
\newcommand{\OK}{\textcolor{blue}{\checkmark}}
\newcommand{\NotOK}{\textcolor{red}{\pmb{$\times$}}}
\newcommand{\MacrosHaveSameDefintiion}[4]{%
% #1 = macros 1
% #2 = macros 2
% #3 = code to execute if macros are identical
% #4 = code to execute if macros differ
Macros \texttt{\string#1} and \texttt{\string#2} are
\IfStrEq{\detokenize{#1}}{\detokenize{#2}}{#3}{#4}%
}%
\begin{document}
\par \verb|\iff|: \texttt{\meaning\iff}
\par \verb|\MyIffWithDotsbNonStar|: \texttt{\meaning\MyIffWithDotsbNonStar}
\medskip
\par\MacrosHaveSameDefintiion{\iff}{\iff}{identical}{different} \OK
\par\MacrosHaveSameDefintiion{\iff}{\MyIffWithDotsbNonStar}{identical}{different} \NotOK
\par\MacrosHaveSameDefintiion{\iff}{\MyIffWithoutDotsbNonStar}{identical}{different} \OK
\par\MacrosHaveSameDefintiion{\iff}{\MyIffWithDotsbStar}{identical}{different} \OK
\par\MacrosHaveSameDefintiion{\iff}{\MyIffWithoutDotsbStar}{identical}{different} \OK
\end{document}


\ifxcompares the first level expansion of two macros, but only after checking if they have the same status with respect to\long. – egreg Jan 02 '16 at 10:35\detokenize{\iff}with the result of\detokenize{\MyIffWithDotsbNonStar}, which are clearly different. You need\detokenize\expandafter{#1}– egreg Jan 02 '16 at 10:48