public static void Test() { TestStruct c = new TestStruct(5); Contract.Assert(c.x == 5); }
public static void Test4(ref TestStruct s) { int oldx = s.x; int result = HasEnsures4(ref s); Contract.Assert(oldx == result); Contract.Assert(s.x == oldx + 1); }
public static void Test3(TestStruct s) { int result = HasEnsures3(s); Contract.Assert(s.x == result); }
public static int HasEnsures4(ref TestStruct s) { Contract.Ensures(Contract.Result<int>() == Contract.OldValue(s.x)); Contract.Ensures(s.x == Contract.OldValue(s.x) + 1); var old = s.x; s.x++; return old; }
public static int HasEnsures3(TestStruct s) { Contract.Ensures(Contract.Result<int>() == s.x); return s.x; }