stub: implement a stubbing mechanism

To stub arbitrary function calls with predefined values.