My guess:
f(x)<0, f(y)>=0 and |x-y|<eps does not imply |f(x)|<eps - think about functions woth a big slope.
So your test possibly prints no solution even if you have actually found one.
With the for loop you are determining x with a precision of 2^{-50} (or machine precision, whichever is bigger), smaller than the 10-9 of the while loop. In this case |x-y|\leq 2^{-50} seems to be small enough to imply |f(x)|<eps for the testcases