Even worse:
In[1]:= f[x_] := Boole[IntervalMemberQ[Interval[{0, 1}], x]]
In[2]:= Table[f[x], {x, 0, 2, .1}]
Out[2]= {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
In[3]:= NIntegrate[f[x], {x, 0, 2}, "MinRecursion" -> 9]
During evaluation of In[3]:= NIntegrate::izero: Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.
Out[3]= 0.
Trace shows that NIntegrate evaluates the function before performing the integration.