Skip to content

Instantly share code, notes, and snippets.

@Groogy
Last active February 7, 2016 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Groogy/0b952d2d279b740fdbcb to your computer and use it in GitHub Desktop.
Save Groogy/0b952d2d279b740fdbcb to your computer and use it in GitHub Desktop.
class Foobar
{
public:
Foobar(float val) { myVal = val; }
float func1(float x)
{
REQUIRES(x > 0);
return sqrt(myVal + x);
}
float func2(float x)
{
REQUIRES(x != myVal);
ENSURES(x > 0);
return myVal + x;
}
private:
BEGIN_INVARIANT(Foobar)
INVARIANT(self.myVal > 0)
END_INVARIANT()
float myVal;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment