\documentclass{article}
\newcounter{result}[section]%
\def\theresult{\thesection.\arabic{result}}%
\gdef\testif#1{\par\noindent\refstepcounter{result}\theresult: #1true\else false\fi ; evaluated: \detokenize{#1}\par}%
\def\testerx#1#2{%
\refstepcounter{result}%
\par\noindent\theresult
\detokenize{ #1 vs #2}
(ifx)\space
\ifx#1#2T\else F\fi\space
\expandafter\ifx\noexpand#1#2T\else F\fi\space
\expandafter\ifx\expandafter#1\noexpand#2T\else F\fi\space
\expandafter\expandafter\expandafter\ifx\expandafter\noexpand\expandafter#1\noexpand#2T\else F\fi
.
}
\def\tester#1#2{%
\refstepcounter{result}%
\par\noindent\theresult
\detokenize{ #1 vs #2}
(ifx)\space
\ifx#1#2T\else F\fi\space
\expandafter\ifx\noexpand#1#2T\else F\fi\space
\expandafter\ifx\expandafter#1\noexpand#2T\else F\fi\space
\expandafter\expandafter\expandafter\ifx\expandafter\noexpand\expandafter#1\noexpand#2T\else F\fi
;
(if)\space
\if#1#2T\else F\fi\space
\if\noexpand#1#2T\else F\fi\space
\if#1\noexpand#2T\else F\fi\space
\if\noexpand#1\noexpand#2T\else F\fi
;
(ifcat)\space
\ifcat#1#2T\else F\fi\space
\ifcat\noexpand#1#2T\else F\fi\space
\ifcat#1\noexpand#2T\else F\fi\space
\ifcat\noexpand#1\noexpand#2T\else F\fi
.
}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\foo{FOO}
\def\footoo{FOO}
\let\letfoo=\foo
\def\usefoo{\foo}%
\expandafter\let\expandafter\letnxfoo\noexpand\foo
\expandafter\def\expandafter\eafoo\expandafter{\noexpand\foo}
\newcount\ctr
\newcount\four\four=4
\newcount\fourtoo\fourtoo=4
\countdef\ctrx=999\relax
\countdef\ctry=999\relax
Tests are: direct comparison, noexpand first, noexpand second, noexpand both.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\catcode`*=\active
\def*{STAR}
\section{Definitions}
\tester{\foo}{\foo}
\tester{\foo}{\footoo}
\tester{\foo}{\letfoo}
\tester{\foo}{\usefoo}
\tester{\foo}{\letnxfoo}
\tracingmacros=0\relax
\tracingcommands=0\relax
\tester{\foo}{\eafoo}
\tester{\relax}{\letnxfoo}
\tester{\relax}{\eafoo}
{
\testerx{\isnotdefined}{\isnotdefined}
\testerx{\isnotdefinedA}{\isnotdefinedB}
\testerx{\foo}{\isnotdefinedC}
}
\section{Counters}
\tester{\ctr}{\ctr}
\tester{\ctr}{\four}
\tester{\four}{\fourtoo}
\tester{\ctr}{\ctrx}
\tester{\ctrx}{\ctry}
}
\section{Active Chars}
{\catcode`[=\active \catcode`]=\active
\def[{@}\def]{_}
\tester{x}{x}
\tester{\foo}{x}
\tester{x}{*}
\tester{\foo}{*}
\tester{*}{*}
\tester{[}{]}
\tester{[}{[}
\tester{]}{]}
\tester{[}{@}
\tester{^}{@}
\let\letA=A
\tester{A}{\letA}
}
\end{document}