# Testing for nontrivial evaluation

How can I tell programmatically if a function has evaluated in a nontrivial way?

I'd like to do, essentially, something along the lines of f[x]===HoldForm[f[x]], a test that returns true if f[x] just evaluates to f[x] because it's not defined, or else false if f[x] actually does something. Of course, that example code doesn't work - my guess is that the HoldForm is printing itself or something.

f[x] === HoldForm[f[x]] does not provide the desired result, because HoldForm stays attached to f[x] on the right side of the expression. Thus, the left and right sides never are identical. Instead use,

f[x] === Unevaluated[f[x]]
(* True *)


And, when the function does something,

g[x_] := x^2
g[x] === Unevaluated[g[x]]
(* False *)


Unevaluated prevents evaluation only on a single line, then goes away, so it works for this purpose.