The underlying idea here is a contract system, first pioneered by Bertrand Meyer in the programming language Eiffel[1] and then augmented with the ability to describe higher-order functions by Robby Findler[2]. PLT also strongly advocated the use of blame with contracts -- the ability to blame the responsible party (function) when a contract fails. My Masters thesis under Robby Findler was on guided random testing using higher-order contracts.
I should note that an ordinary contract system does not delete your code...
[1] http://en.wikipedia.org/wiki/Eiffel_(programming_language)#D...
[2] http://www.eecs.northwestern.edu/~robby/pubs/papers/ho-contr...