I find the following test so far adequate for my need. The only type of input I consider is typified by the following
which, for example, has been supplied directly by the user for parsing on a callback. So
catcode-12 tokens are not expected as part of the input, but it is easy to accommodate such tokens. I also can accommodate
\dimendef'd registers through the tests at Test if a given control sequence is a length register. In the intended applications, I don't need to test for
\skip'd registers. The problem is actually with internal dimensions, but they aren't expected to be part of the above type of user input.
% Also test for number (without unit)
\csname @\csname if#1\endcsname first\else second\fi oftwo\endcsname
first\else second\fi oftwo\endcsname
% Check for a valid unit.
% Is 'pt' 0pt or 1pt? Make it invalid input in revised code: