test[x_, y_] = x > y
is equivalent to test[x_, y_] = False
. i.e. you are not passing in the symbols unevaluated. So then the anonymous function associated with this would just be a function that always returns false. You don't need a function for that, there's no point in a function that always returns the same thing. But if you want it you can do f = With[{xx = x, yy = y}, Function[{}, xx > yy]]
.