public static void TestInferredParameter(int x, int y) { PointStruct p = new PointStruct(x, y); InferParamInvariant(p); Contract.Assert(p.X > 0); Contract.Assert(p.y > 0); }
public static void Test(int x, int y) { Contract.Requires(x >= 0); Contract.Requires(y >= 0); PointStruct p = new PointStruct(x, y); Contract.Assert(p.X >= 0); Contract.Assert(p.Y >= 0); Contract.Assert(p.SquareDistance >= 0); }
public static void Test_Wrong() { PointStruct p = new PointStruct(5, 10); Contract.Assert(p.X == 5); Contract.Assert(p.SquareDistance == 125); p.Move(2); Contract.Assert(p.X == 5); // False Contract.Assert(p.Y == 11); // Unreached }
public static void Test_OK() { PointStruct p = new PointStruct(5, 10); Contract.Assert(p.X == 5); Contract.Assert(p.SquareDistance == 125); p.Move(2); Contract.Assert(p.X == 7); Contract.Assert(p.Y == 12); }
public static void InferParamInvariant(PointStruct a) { Contract.Assume(a.X > 0); Contract.Assume(a.y > 0); }