Sorry for the LISP reference, but it's probably the best example.
For example, if I write:
Commute[Times[x_,y_]] := Times[y_,x_]
And I want to test this on Times[1,2], is there any input I can give to get the response Times[2,1]?
If I say Commute[Times[1,2]] then 1*2 is evaluated first and Commute does not run because the pattern does not match.
If I say Commute[Unevaluated[Times[1,2]] then Commute runs properly but Times[2,1] is evaluated inside Commute and 2 is returned.
If I say Unevaluated[Commute[Times[1,2]]] then Commute is not evaluated and I just get the same expression back again.
I know I can test it by using unassigned variables, so that the Times expression cannot be evaluated, but is there a way to do so without needing to worry about that?
Commute[Times[x_, y_]] := HoldForm[Times[y, x]]
Thanks, but I don't want to change the definition of Commute. That makes it into a function that can only ever return that form, whereas I just want to return the unevaluated form this once for testing/debugging purposes (which is what macroexpand-1 does)
It is possible mucking about with holdform could yield something, but I can't work out how I'd go about that I'm afraid.
If you get desperate you could overload Commute with specific debug procedures.