();
+
+ return null;
+ }
}
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/ArrayForAll.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/ArrayForAll.cs
index d12547f8..7a3de56e 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/ArrayForAll.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/ArrayForAll.cs
@@ -15,137 +15,148 @@
using System;
using System.Text;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
+
using System.Collections.Generic;
-class Test {
+internal class Test
+{
[ClousotRegressionTest]
- private static void MikesTest(string filename) {
- Contract.Requires(!string.IsNullOrEmpty(filename));
- var lines = System.IO.File.ReadAllLines(filename);
- var result = ParseLines(lines);
+ private static void MikesTest(string filename)
+ {
+ Contract.Requires(!string.IsNullOrEmpty(filename));
+ var lines = System.IO.File.ReadAllLines(filename);
+ var result = ParseLines(lines);
}
[ClousotRegressionTest]
- private static string ParseLines(string[] lines) {
- Contract.Requires(lines != null);
- Contract.Requires(Array.TrueForAll(lines,l => l != null));
- foreach (var line in lines) {
- int index = line.IndexOf('=');
- if (index >= 0) {
- string name = line.Substring(0, index);
- if (name == "Foo") {
- string value = line.Substring(index + 1);
- return value;
- }
+ private static string ParseLines(string[] lines)
+ {
+ Contract.Requires(lines != null);
+ Contract.Requires(Array.TrueForAll(lines, l => l != null));
+ foreach (var line in lines)
+ {
+ int index = line.IndexOf('=');
+ if (index >= 0)
+ {
+ string name = line.Substring(0, index);
+ if (name == "Foo")
+ {
+ string value = line.Substring(index + 1);
+ return value;
+ }
+ }
}
- }
- return null;
+ return null;
}
[ClousotRegressionTest]
private static string CSharpColorizePre(string text)
{
- Contract.Requires(text != null);
- var split = text.Split(new string[] { "", " " }, StringSplitOptions.None);
- if (split.Length == 0) return text;
- Contract.Assume(Array.TrueForAll(split, s => s != null));
- var result = new StringBuilder();
- result.Append(split[0]);
- var index = 1;
- while (index < split.Length)
- {
- result.Append("");
- result.Append(CSharpColorize(split[index++]));
- result.Append(" ");
- if (index < split.Length)
+ Contract.Requires(text != null);
+ var split = text.Split(new[] {"", " "}, StringSplitOptions.None);
+ if (split.Length == 0)
+ return text;
+ Contract.Assume(Array.TrueForAll(split, s => s != null));
+ var result = new StringBuilder();
+ result.Append(split[0]);
+ var index = 1;
+ while (index < split.Length)
{
- result.Append(split[index++]);
+ result.Append("");
+ result.Append(CSharpColorize(split[index++]));
+ result.Append(" ");
+ if (index < split.Length)
+ {
+ result.Append(split[index++]);
+ }
}
- }
- return result.ToString();
+ return result.ToString();
}
[ClousotRegressionTest]
- private static string CSharpColorize(string text) {
- Contract.Requires(text != null);
- Contract.Ensures(Contract.Result() != null);
-
- var result = text;
- result = System.Text.RegularExpressions.Regex.Replace(result, "(bool|new|throw|public|interface|abstract|class|typeof|get|return|default|if|void|string|null)", "$& ");
- result = System.Text.RegularExpressions.Regex.Replace(result, "Contract[a-zA-Z]*", "$& ");
- result = System.Text.RegularExpressions.Regex.Replace(result, "//.*", "$& ");
- return result;
+ private static string CSharpColorize(string text)
+ {
+ Contract.Requires(text != null);
+ Contract.Ensures(Contract.Result() != null);
+
+ var result = text;
+ result = System.Text.RegularExpressions.Regex.Replace(result, "(bool|new|throw|public|interface|abstract|class|typeof|get|return|default|if|void|string|null)", "$& ");
+ result = System.Text.RegularExpressions.Regex.Replace(result, "Contract[a-zA-Z]*", "$& ");
+ result = System.Text.RegularExpressions.Regex.Replace(result, "//.*", "$& ");
+ return result;
}
}
-public static class FrancescoTest {
- [Pure]
- [ClousotRegressionTest]
- public static T[] AssumeAllNonNull(this T[] sequence) where T : class
- {
- Contract.Requires(sequence != null);
- Contract.Ensures(Contract.Result>() != null);
- Contract.Ensures(Array.TrueForAll(Contract.Result(), e => e != null));
- Contract.Assume(Array.TrueForAll(sequence, e => e != null));
- return sequence;
- }
- [ClousotRegressionTest]
- public static void Test1(Object[] x)
- {
- Contract.Requires(x != null);
-
- foreach (var e in x.AssumeAllNonNull())
+public static class FrancescoTest
+{
+ [Pure]
+ [ClousotRegressionTest]
+ public static T[] AssumeAllNonNull(this T[] sequence) where T : class
{
- Contract.Assert(e != null);
+ Contract.Requires(sequence != null);
+ Contract.Ensures(Contract.Result>() != null);
+ Contract.Ensures(Array.TrueForAll(Contract.Result(), e => e != null));
+ Contract.Assume(Array.TrueForAll(sequence, e => e != null));
+ return sequence;
}
- }
- [ClousotRegressionTest]
- public static void Test2(Object[] x)
- {
- Contract.Requires(x != null);
- Contract.Requires(Array.TrueForAll(x, el => el != null));
-
- foreach (var e in x)
+
+ [ClousotRegressionTest]
+ public static void Test1(object[] x)
{
- Contract.Assert(e != null);
+ Contract.Requires(x != null);
+
+ foreach (var e in x.AssumeAllNonNull())
+ {
+ Contract.Assert(e != null);
+ }
}
- }
+ [ClousotRegressionTest]
+ public static void Test2(object[] x)
+ {
+ Contract.Requires(x != null);
+ Contract.Requires(Array.TrueForAll(x, el => el != null));
+
+ foreach (var e in x)
+ {
+ Contract.Assert(e != null);
+ }
+ }
}
-public class MaFTests {
-
- [Pure]
- public static void Check(string[] arg)
- {
- Contract.Requires(arg == null || Contract.ForAll(arg, p => p != null));
-
- }
-
- [ClousotRegressionTest]
- public static void Test(string[] args1, string[] args2)
- {
- Contract.Requires(args1 == null || Contract.ForAll(args1, p => p != null));
- Contract.Requires(args2 == null || Contract.ForAll(args2, p => p != null));
-
- Check(args1);
- Check(args2);
- }
-
- [ClousotRegressionTest]
- public void MafRepro(string text)
- {
- Contract.Requires(text != null);
-
- var lines = text.Split(new string[] { Environment.NewLine, }, StringSplitOptions.RemoveEmptyEntries);
-
- if (lines.Length < 5) return;
-
- var firstLine = lines[0];
-
- Contract.Assert(firstLine != null);
- }
+public class MaFTests
+{
+ [Pure]
+ public static void Check(string[] arg)
+ {
+ Contract.Requires(arg == null || Contract.ForAll(arg, p => p != null));
+ }
-}
+ [ClousotRegressionTest]
+ public static void Test(string[] args1, string[] args2)
+ {
+ Contract.Requires(args1 == null || Contract.ForAll(args1, p => p != null));
+ Contract.Requires(args2 == null || Contract.ForAll(args2, p => p != null));
+
+ Check(args1);
+ Check(args2);
+ }
+
+ [ClousotRegressionTest]
+ public void MafRepro(string text)
+ {
+ Contract.Requires(text != null);
+
+ var lines = text.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
+
+ if (lines.Length < 5)
+ return;
+
+ var firstLine = lines[0];
+
+ Contract.Assert(firstLine != null);
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/AssumeInvariant.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/AssumeInvariant.cs
index 540623db..00576fb4 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/AssumeInvariant.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/AssumeInvariant.cs
@@ -17,11 +17,12 @@
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
namespace AssumeInvariant
{
- class C
+ internal class C
{
public int field;
@@ -38,15 +39,15 @@ public C()
}
}
- class Test
+ internal class Test
{
[Pure]
- static void AssumeInvariant(T o) { }
-
- static void Main(string[] args)
+ private static void AssumeInvariant(T o)
{
+ }
-
+ private static void Main(string[] args)
+ {
var p = new C();
TestMe1(p);
@@ -54,73 +55,70 @@ static void Main(string[] args)
}
[ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="assert unproven",PrimaryILOffset=10,MethodILOffset=0)]
- static void TestMe1(C p) {
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "assert unproven", PrimaryILOffset = 10, MethodILOffset = 0)]
+ private static void TestMe1(C p)
+ {
Contract.Assert(p.field > 0);
}
[ClousotRegressionTest]
- static void TestMe2(C p)
+ private static void TestMe2(C p)
{
AssumeInvariant(p);
Contract.Assert(p.field > 0);
-
}
}
-
}
-namespace AssumeInvariantOldIssue {
- using System.Collections;
+namespace AssumeInvariantOldIssue
+{
+ using System.Collections;
- public class Host
- {
- public string Name = "";
-
- [ContractInvariantMethod]
- void ObjectInvariant()
+ public class Host
{
- Contract.Invariant(Name != null);
- }
- }
+ public string Name = "";
- class InvariantAtCallAndOldHandling {
- public static class ContractHelpers
- {
- [ContractVerification(false)]
- public static void AssumeInvariant(T o)
- {
- }
+ [ContractInvariantMethod]
+ private void ObjectInvariant()
+ {
+ Contract.Invariant(Name != null);
+ }
}
- [ClousotRegressionTest]
- static void AssumeInvariantTrue()
+ internal class InvariantAtCallAndOldHandling
{
- foreach (Host h in new ArrayList())
- {
- Contract.Assume(h != null);
-
- ContractHelpers.AssumeInvariant(h);
+ public static class ContractHelpers
+ {
+ [ContractVerification(false)]
+ public static void AssumeInvariant(T o)
+ {
+ }
+ }
- Contract.Assert(h.Name != null);
- }
+ [ClousotRegressionTest]
+ private static void AssumeInvariantTrue()
+ {
+ foreach (Host h in new ArrayList())
+ {
+ Contract.Assume(h != null);
- }
+ ContractHelpers.AssumeInvariant(h);
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="assert unproven",PrimaryILOffset=53,MethodILOffset=0)]
- static void AssumeInvariantUnproven()
- {
- foreach (Host h in new ArrayList())
- {
- Contract.Assume(h != null);
+ Contract.Assert(h.Name != null);
+ }
+ }
- Contract.Assert(h.Name != null);
- }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "assert unproven", PrimaryILOffset = 53, MethodILOffset = 0)]
+ private static void AssumeInvariantUnproven()
+ {
+ foreach (Host h in new ArrayList())
+ {
+ Contract.Assume(h != null);
+ Contract.Assert(h.Name != null);
+ }
+ }
}
-
- }
-
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/ClassWithProtocolFinal.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/ClassWithProtocolFinal.cs
index 03821d86..56b9fa03 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/ClassWithProtocolFinal.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/ClassWithProtocolFinal.cs
@@ -1,157 +1,159 @@
-// CodeContracts
-//
-// Copyright (c) Microsoft Corporation
-//
-// All rights reserved.
-//
-// MIT License
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-using System;
-using System.IO;
-using System.Diagnostics.Contracts;
-using Microsoft.Research.ClousotRegression;
-
-namespace Protocols
-{
- ///
- /// Example class with a protocol.
- ///
- public class ClassWithProtocol
- {
- ///
- /// The possible states of the protocol instance.
- ///
- public enum S
- {
- ///
- /// Object has not been initialized
- ///
- NotReady,
- ///
- /// Object is initialized and Data is available
- ///
- Initialized,
- ///
- /// Computed data is now available.
- ///
- Computed
- }
-
- private S _state;
-
- ///
- /// The current state of the protocol instance.
- ///
- public S State
- {
- [ClousotRegressionTest]
- get
- {
- //Contract.Ensures(Contract.Result() == _state);
-
- return _state;
- }
- }
-
- ///
- /// Object invariant method.
- ///
- [ContractInvariantMethod]
- void ObjectInvariant()
- {
- Contract.Invariant(_state != S.Computed || _computedData != null);
- }
-
- ///
- /// Create a new protocol class
- ///
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 15, MethodILOffset = 27)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 24, MethodILOffset = 27)]
- public ClassWithProtocol()
- {
- Contract.Ensures(this.State == S.NotReady);
- _state = S.NotReady;
- }
-
- string _data;
-
- ///
- /// Initializes the protocol instance so that the Compute method becomes valid.
- /// Furthermore, the Data property becomes accessible as well.
- ///
- /// string value used to initialize Data property
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 23, MethodILOffset = 42)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 24, MethodILOffset = 42)]
- public void Initialize(string data)
- {
- Contract.Requires(State == S.NotReady);
- Contract.Ensures(State == S.Initialized);
-
- this._data = data;
- _state = S.Initialized;
- }
-
- ///
- /// Further initializes the protocol instance into its final state.
- /// Now the ComputedData property becomes valid, provided the method returns true.
- ///
- /// Used to initialize the computed data
- /// true if transition succeeds. Upon a false return, the instance stays in the Initialized state
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 64, MethodILOffset = 95)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 24, MethodILOffset = 95)]
- public bool Compute(string prefix)
- {
- Contract.Requires(prefix != null);
- Contract.Requires(State == S.Initialized);
- Contract.Ensures(Contract.Result() && State == S.Computed ||
- !Contract.Result() && State == S.Initialized);
-
- this._computedData = prefix + _data;
- _state = S.Computed;
-
- return true;
- }
-
- ///
- /// The data value of the protocol instance.
- ///
- public string Data
- {
- get
- {
- Contract.Requires(State != S.NotReady);
-
- return _data;
- }
- }
-
-
- string _computedData;
- ///
- /// The computed data value. Available when state is Computed.
- ///
- public string ComputedData
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 35, MethodILOffset = 46)]
- get
- {
- Contract.Requires(State == S.Computed, "object must be in Computed state");
- Contract.Ensures(Contract.Result() != null, "result is non-null");
-
- return _computedData;
- }
- }
-
-
- }
-}
+// CodeContracts
+//
+// Copyright (c) Microsoft Corporation
+//
+// All rights reserved.
+//
+// MIT License
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.IO;
+using System.Diagnostics.Contracts;
+
+using Microsoft.Research.ClousotRegression;
+
+namespace Protocols
+{
+ ///
+ /// Example class with a protocol.
+ ///
+ public class ClassWithProtocol
+ {
+ ///
+ /// The possible states of the protocol instance.
+ ///
+ public enum S
+ {
+ ///
+ /// Object has not been initialized
+ ///
+ NotReady,
+
+ ///
+ /// Object is initialized and Data is available
+ ///
+ Initialized,
+
+ ///
+ /// Computed data is now available.
+ ///
+ Computed
+ }
+
+ private S _state;
+
+ ///
+ /// The current state of the protocol instance.
+ ///
+ public S State
+ {
+ [ClousotRegressionTest]
+ get
+ {
+ //Contract.Ensures(Contract.Result() == _state);
+
+ return _state;
+ }
+ }
+
+ ///
+ /// Object invariant method.
+ ///
+ [ContractInvariantMethod]
+ private void ObjectInvariant()
+ {
+ Contract.Invariant(_state != S.Computed || _computedData != null);
+ }
+
+ ///
+ /// Create a new protocol class
+ ///
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 15, MethodILOffset = 27)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 24, MethodILOffset = 27)]
+ public ClassWithProtocol()
+ {
+ Contract.Ensures(State == S.NotReady);
+ _state = S.NotReady;
+ }
+
+ private string _data;
+
+ ///
+ /// Initializes the protocol instance so that the Compute method becomes valid.
+ /// Furthermore, the Data property becomes accessible as well.
+ ///
+ /// string value used to initialize Data property
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 23, MethodILOffset = 42)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 24, MethodILOffset = 42)]
+ public void Initialize(string data)
+ {
+ Contract.Requires(State == S.NotReady);
+ Contract.Ensures(State == S.Initialized);
+
+ _data = data;
+ _state = S.Initialized;
+ }
+
+ ///
+ /// Further initializes the protocol instance into its final state.
+ /// Now the ComputedData property becomes valid, provided the method returns true.
+ ///
+ /// Used to initialize the computed data
+ /// true if transition succeeds. Upon a false return, the instance stays in the Initialized state
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 64, MethodILOffset = 95)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 24, MethodILOffset = 95)]
+ public bool Compute(string prefix)
+ {
+ Contract.Requires(prefix != null);
+ Contract.Requires(State == S.Initialized);
+ Contract.Ensures(Contract.Result() && State == S.Computed ||
+ !Contract.Result() && State == S.Initialized);
+
+ _computedData = prefix + _data;
+ _state = S.Computed;
+
+ return true;
+ }
+
+ ///
+ /// The data value of the protocol instance.
+ ///
+ public string Data
+ {
+ get
+ {
+ Contract.Requires(State != S.NotReady);
+
+ return _data;
+ }
+ }
+
+
+ private string _computedData;
+
+ ///
+ /// The computed data value. Available when state is Computed.
+ ///
+ public string ComputedData
+ {
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 35, MethodILOffset = 46)]
+ get
+ {
+ Contract.Requires(State == S.Computed, "object must be in Computed state");
+ Contract.Ensures(Contract.Result() != null, "result is non-null");
+
+ return _computedData;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/Decimal.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/Decimal.cs
index 58804d43..0a381a5d 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/Decimal.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/Decimal.cs
@@ -15,31 +15,29 @@
using System;
using System.Configuration;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
-class Test
+internal class Test
{
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven: first != 0",PrimaryILOffset=13,MethodILOffset=17)]
- [RegressionOutcome(Outcome=ProofOutcome.False,Message="requires is false: second != 0",PrimaryILOffset=31,MethodILOffset=17)]
- public static void Main(string[] args)
- {
- Decimal first = 5;
- Decimal second = 0;
-
- Console.WriteLine(Add(first, second));
- }
-
- [ClousotRegressionTest]
- public static Decimal Add(Decimal first, Decimal second)
- {
- Contract.Requires(first != 0);
- Contract.Requires(second != 0);
- Contract.Ensures(Contract.Result() == first + second);
-
- return first + second;
- }
-
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "requires unproven: first != 0", PrimaryILOffset = 13, MethodILOffset = 17)]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = "requires is false: second != 0", PrimaryILOffset = 31, MethodILOffset = 17)]
+ public static void Main(string[] args)
+ {
+ decimal first = 5;
+ decimal second = 0;
+
+ Console.WriteLine(Add(first, second));
+ }
-}
+ [ClousotRegressionTest]
+ public static decimal Add(decimal first, decimal second)
+ {
+ Contract.Requires(first != 0);
+ Contract.Requires(second != 0);
+ Contract.Ensures(Contract.Result() == first + second);
+ return first + second;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/DoubleZero.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/DoubleZero.cs
index 24def1ba..1f8620e9 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/DoubleZero.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/DoubleZero.cs
@@ -15,30 +15,28 @@
using System;
using System.Configuration;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
-class Test
+internal class Test
{
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=16,MethodILOffset=23)]
- [RegressionOutcome(Outcome=ProofOutcome.False,Message=@"requires is false: second != 0",PrimaryILOffset=37,MethodILOffset=23)]
- public static void Main(string[] args)
- {
- double first = 5;
- double second = 0;
-
- Console.WriteLine(Add(first, second));
- }
-
- public static double Add(double first, double second)
- {
- Contract.Requires(first != 0);
- Contract.Requires(second != 0);
- Contract.Ensures(Contract.Result() == first + second);
-
- return first + second;
- }
-
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 16, MethodILOffset = 23)]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"requires is false: second != 0", PrimaryILOffset = 37, MethodILOffset = 23)]
+ public static void Main(string[] args)
+ {
+ double first = 5;
+ double second = 0;
+
+ Console.WriteLine(Add(first, second));
+ }
-}
+ public static double Add(double first, double second)
+ {
+ Contract.Requires(first != 0);
+ Contract.Requires(second != 0);
+ Contract.Ensures(Contract.Result() == first + second);
+ return first + second;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/EnumerableAll.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/EnumerableAll.cs
index fc57a165..24a9c82e 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/EnumerableAll.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/EnumerableAll.cs
@@ -16,77 +16,84 @@
using System.Text;
using System.Linq;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
+
using System.Collections.Generic;
-class Test {
+internal class Test
+{
[ClousotRegressionTest]
private static string CSharpColorizePre(string text)
{
- Contract.Requires(text != null);
- var split = text.Split(new string[] { "", " " }, StringSplitOptions.None);
- if (split.Length == 0) return text;
- Contract.Assume(Enumerable.All(split, s => s != null));
- var result = new StringBuilder();
- result.Append(split[0]);
- var index = 1;
- while (index < split.Length)
- {
- result.Append("");
- result.Append(CSharpColorize(split[index++]));
- result.Append(" ");
- if (index < split.Length)
+ Contract.Requires(text != null);
+ var split = text.Split(new[] {"", " "}, StringSplitOptions.None);
+ if (split.Length == 0)
+ return text;
+ Contract.Assume(split.All(s => s != null));
+ var result = new StringBuilder();
+ result.Append(split[0]);
+ var index = 1;
+ while (index < split.Length)
{
- result.Append(split[index++]);
+ result.Append("");
+ result.Append(CSharpColorize(split[index++]));
+ result.Append(" ");
+ if (index < split.Length)
+ {
+ result.Append(split[index++]);
+ }
}
- }
- return result.ToString();
+ return result.ToString();
}
[ClousotRegressionTest]
- private static string CSharpColorize(string text) {
- Contract.Requires(text != null);
- Contract.Ensures(Contract.Result() != null);
+ private static string CSharpColorize(string text)
+ {
+ Contract.Requires(text != null);
+ Contract.Ensures(Contract.Result() != null);
- var result = text;
- result = System.Text.RegularExpressions.Regex.Replace(result, "(bool|new|throw|public|interface|abstract|class|typeof|get|return|default|if|void|string|null)", "$& ");
- result = System.Text.RegularExpressions.Regex.Replace(result, "Contract[a-zA-Z]*", "$& ");
- result = System.Text.RegularExpressions.Regex.Replace(result, "//.*", "$& ");
- return result;
+ var result = text;
+ result = System.Text.RegularExpressions.Regex.Replace(result, "(bool|new|throw|public|interface|abstract|class|typeof|get|return|default|if|void|string|null)", "$& ");
+ result = System.Text.RegularExpressions.Regex.Replace(result, "Contract[a-zA-Z]*", "$& ");
+ result = System.Text.RegularExpressions.Regex.Replace(result, "//.*", "$& ");
+ return result;
}
}
-public static class FrancescoTest {
- [Pure]
- [ClousotRegressionTest]
- public static IEnumerable AssumeAllNonNull(this IEnumerable sequence) where T : class
- {
- Contract.Requires(sequence != null);
- Contract.Ensures(Contract.Result>() != null);
- Contract.Ensures(Enumerable.All(Contract.Result>(), e => e != null));
- Contract.Assume(Enumerable.All(sequence, e => e != null));
- return sequence;
- }
- [ClousotRegressionTest]
- public static void Test1(IEnumerable x)
- {
- Contract.Requires(x != null);
-
- foreach (var e in x.AssumeAllNonNull())
+public static class FrancescoTest
+{
+ [Pure]
+ [ClousotRegressionTest]
+ public static IEnumerable AssumeAllNonNull(this IEnumerable sequence) where T : class
{
- Contract.Assert(e != null);
+ Contract.Requires(sequence != null);
+ Contract.Ensures(Contract.Result>() != null);
+ Contract.Ensures(Contract.Result>().All(e => e != null));
+ Contract.Assume(sequence.All(e => e != null));
+ return sequence;
}
- }
- [ClousotRegressionTest]
- public static void Test2(IEnumerable x)
- {
- Contract.Requires(x != null);
- Contract.Requires(Enumerable.All(x, el => el != null));
-
- foreach (var e in x)
+
+ [ClousotRegressionTest]
+ public static void Test1(IEnumerable x)
{
- Contract.Assert(e != null);
+ Contract.Requires(x != null);
+
+ foreach (var e in x.AssumeAllNonNull())
+ {
+ Contract.Assert(e != null);
+ }
}
- }
-}
+ [ClousotRegressionTest]
+ public static void Test2(IEnumerable x)
+ {
+ Contract.Requires(x != null);
+ Contract.Requires(x.All(el => el != null));
+
+ foreach (var e in x)
+ {
+ Contract.Assert(e != null);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/ForAll.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/ForAll.cs
index e5ad59eb..f0d492a8 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/ForAll.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/ForAll.cs
@@ -15,104 +15,108 @@
using System;
using System.Text;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
+
using System.Collections.Generic;
-class Test {
+internal class Test
+{
[ClousotRegressionTest]
private static string CSharpColorizePre(string text)
{
- Contract.Requires(text != null);
- var split = text.Split(new string[] { "", " " }, StringSplitOptions.None);
- if (split.Length == 0) return text;
- Contract.Assume(Contract.ForAll(split, s => s != null));
- var result = new StringBuilder();
- result.Append(split[0]);
- var index = 1;
- while (index < split.Length)
- {
- result.Append("");
- result.Append(CSharpColorize(split[index++]));
- result.Append(" ");
- if (index < split.Length)
+ Contract.Requires(text != null);
+ var split = text.Split(new[] {"", " "}, StringSplitOptions.None);
+ if (split.Length == 0)
+ return text;
+ Contract.Assume(Contract.ForAll(split, s => s != null));
+ var result = new StringBuilder();
+ result.Append(split[0]);
+ var index = 1;
+ while (index < split.Length)
{
- result.Append(split[index++]);
+ result.Append("");
+ result.Append(CSharpColorize(split[index++]));
+ result.Append(" ");
+ if (index < split.Length)
+ {
+ result.Append(split[index++]);
+ }
}
- }
- return result.ToString();
+ return result.ToString();
}
[ClousotRegressionTest]
- private static string CSharpColorize(string text) {
- Contract.Requires(text != null);
- Contract.Ensures(Contract.Result() != null);
-
- var result = text;
- result = System.Text.RegularExpressions.Regex.Replace(result, "(bool|new|throw|public|interface|abstract|class|typeof|get|return|default|if|void|string|null)", "$& ");
- result = System.Text.RegularExpressions.Regex.Replace(result, "Contract[a-zA-Z]*", "$& ");
- result = System.Text.RegularExpressions.Regex.Replace(result, "//.*", "$& ");
- return result;
+ private static string CSharpColorize(string text)
+ {
+ Contract.Requires(text != null);
+ Contract.Ensures(Contract.Result() != null);
+
+ var result = text;
+ result = System.Text.RegularExpressions.Regex.Replace(result, "(bool|new|throw|public|interface|abstract|class|typeof|get|return|default|if|void|string|null)", "$& ");
+ result = System.Text.RegularExpressions.Regex.Replace(result, "Contract[a-zA-Z]*", "$& ");
+ result = System.Text.RegularExpressions.Regex.Replace(result, "//.*", "$& ");
+ return result;
}
}
-public static class FrancescoTest {
- [Pure]
- [ClousotRegressionTest]
- public static IEnumerable AssumeAllNonNull(this IEnumerable sequence) where T : class
- {
- Contract.Requires(sequence != null);
- Contract.Ensures(Contract.Result>() != null);
- Contract.Ensures(Contract.ForAll(Contract.Result>(), e => e != null));
- Contract.Assume(Contract.ForAll(sequence, e => e != null));
- return sequence;
- }
- [ClousotRegressionTest]
- public static void Test1(IEnumerable x)
- {
- Contract.Requires(x != null);
-
- foreach (var e in x.AssumeAllNonNull())
+public static class FrancescoTest
+{
+ [Pure]
+ [ClousotRegressionTest]
+ public static IEnumerable AssumeAllNonNull(this IEnumerable sequence) where T : class
{
- Contract.Assert(e != null);
+ Contract.Requires(sequence != null);
+ Contract.Ensures(Contract.Result>() != null);
+ Contract.Ensures(Contract.ForAll(Contract.Result>(), e => e != null));
+ Contract.Assume(Contract.ForAll(sequence, e => e != null));
+ return sequence;
}
- }
- [ClousotRegressionTest]
- public static void Test2(IEnumerable x)
- {
- Contract.Requires(x != null);
- Contract.Requires(Contract.ForAll(x, el => el != null));
-
- foreach (var e in x)
+
+ [ClousotRegressionTest]
+ public static void Test1(IEnumerable x)
{
- Contract.Assert(e != null);
+ Contract.Requires(x != null);
+
+ foreach (var e in x.AssumeAllNonNull())
+ {
+ Contract.Assert(e != null);
+ }
}
- }
+ [ClousotRegressionTest]
+ public static void Test2(IEnumerable x)
+ {
+ Contract.Requires(x != null);
+ Contract.Requires(Contract.ForAll(x, el => el != null));
+
+ foreach (var e in x)
+ {
+ Contract.Assert(e != null);
+ }
+ }
}
public class Class1 where TValue : class
{
-
[ClousotRegressionTest]
public ICollection ValuesAsCollection()
{
- Contract.Ensures(Contract.Result>() != null);
- Contract.Ensures(Contract.ForAll(Contract.Result>(), v => v != null));
-
- ICollection values = _inner.Values;
-
- Contract.Assume(Contract.ForAll(values, v => v != null));
-
- return values;
+ Contract.Ensures(Contract.Result>() != null);
+ Contract.Ensures(Contract.ForAll(Contract.Result>(), v => v != null));
+
+ ICollection values = _inner.Values;
+
+ Contract.Assume(Contract.ForAll(values, v => v != null));
+
+ return values;
}
-
+
[ContractInvariantMethod]
private void ObjectInvariant()
{
- Contract.Invariant(_inner != null);
+ Contract.Invariant(_inner != null);
}
-
- private readonly Dictionary _inner = new Dictionary();
-}
-
+ private readonly Dictionary _inner = new Dictionary();
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/HeapCrash.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/HeapCrash.cs
index a224d200..61d6a6ab 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/HeapCrash.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/HeapCrash.cs
@@ -14,28 +14,28 @@
using System.Configuration;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
-class Test
+internal class Test
{
- public static string Bug
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="Possibly calling a method on a null reference 'value'",PrimaryILOffset=32,MethodILOffset=0)]
- get
+ public static string Bug
{
- string value = ConfigurationManager.AppSettings["bug"];
- while (value.StartsWith("/"))
- {
- value = value.Substring(1);
- }
- while (value.EndsWith("/"))
- {
- value = value.Substring(0, value.Length - 1);
- }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference 'value'", PrimaryILOffset = 32, MethodILOffset = 0)]
+ get
+ {
+ string value = ConfigurationManager.AppSettings["bug"];
+ while (value.StartsWith("/"))
+ {
+ value = value.Substring(1);
+ }
+ while (value.EndsWith("/"))
+ {
+ value = value.Substring(0, value.Length - 1);
+ }
- return value;
+ return value;
+ }
}
- }
-}
-
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/Herman.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/Herman.cs
index 6e550d68..b74e2935 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/Herman.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/Herman.cs
@@ -14,107 +14,129 @@
using System;
using System.Diagnostics.Contracts;
-using Microsoft.Research.ClousotRegression;
- public class HashSet : MiniSet where Element : class,MiniValue {
+using Microsoft.Research.ClousotRegression;
- System.Collections.Generic.HashSet hashSet = new System.Collections.Generic.HashSet();
+public class HashSet : MiniSet where Element : class, MiniValue
+{
+ private readonly System.Collections.Generic.HashSet hashSet = new System.Collections.Generic.HashSet();
[ContractInvariantMethod]
- private void ObjectInvariant() {
- Contract.Invariant(this.hashSet != null);
+ private void ObjectInvariant()
+ {
+ Contract.Invariant(hashSet != null);
}
+
///
- /// Returns true if the set contains the given element. If the element is null or undefined, the result is always false.
+ /// Returns true if the set contains the given element. If the element is null or undefined, the result is always
+ /// false.
///
[ClousotRegressionTest]
- public bool Contains(Element element) {
- if (element == null || !element.IsDefined) return false;
- var result = this.hashSet.Contains(element);
- return result;
+ public bool Contains(Element element)
+ {
+ if (element == null || !element.IsDefined)
+ return false;
+ var result = hashSet.Contains(element);
+ return result;
}
[ClousotRegressionTest]
- public bool Contains1(Element element) {
- if (element == null) return false;
- //var result = this.hashSet.Contains(element);
- return true;
+ public bool Contains1(Element element)
+ {
+ if (element == null)
+ return false;
+ //var result = this.hashSet.Contains(element);
+ return true;
}
[ClousotRegressionTest]
- public bool Contains2(Element element) {
- if (!element.IsDefined) return false;
- // var result = this.hashSet.Contains(element);
- return true;
+ public bool Contains2(Element element)
+ {
+ if (!element.IsDefined)
+ return false;
+ // var result = this.hashSet.Contains(element);
+ return true;
}
///
- /// True if the value is not the special undefined value for its type.
- /// Every type has an undefined value and all operations involving one or more undefined arguments result in undefined.
+ /// True if the value is not the special undefined value for its type.
+ /// Every type has an undefined value and all operations involving one or more undefined arguments result in undefined.
///
- public bool IsDefined {
- get { return true; }
+ public bool IsDefined
+ {
+ get
+ {
+ return true;
+ }
}
-
-
- }
-
- ///
- /// A set of elements of type Element.
- ///
- ///
- [ContractClass(typeof(MiniSetContract<>))]
- public interface MiniSet : MiniValue where Element : class, MiniValue {
-
+}
+
+///
+/// A set of elements of type Element.
+///
+///
+[ContractClass(typeof (MiniSetContract<>))]
+public interface MiniSet : MiniValue where Element : class, MiniValue
+{
///
- /// Returns true if the set contains the given element. If the element is null or undefined, the result is always false.
+ /// Returns true if the set contains the given element. If the element is null or undefined, the result is always
+ /// false.
///
bool Contains(Element element);
bool Contains1(Element element);
bool Contains2(Element element);
+}
- }
-
- #region MiniSet contract binding
- [ContractClassFor(typeof(MiniSet<>))]
- abstract class MiniSetContract : MiniSet where Element : class,MiniValue {
+#region MiniSet contract binding
- public bool Contains(Element element) {
- Contract.Ensures(element != null && element.IsDefined || !Contract.Result());
+[ContractClassFor(typeof (MiniSet<>))]
+internal abstract class MiniSetContract : MiniSet where Element : class, MiniValue
+{
+ public bool Contains(Element element)
+ {
+ Contract.Ensures(element != null && element.IsDefined || !Contract.Result());
- throw new NotImplementedException();
+ throw new NotImplementedException();
}
- public bool Contains1(Element element) {
- Contract.Ensures(element != null || !Contract.Result());
+ public bool Contains1(Element element)
+ {
+ Contract.Ensures(element != null || !Contract.Result());
- throw new NotImplementedException();
+ throw new NotImplementedException();
}
- public bool Contains2(Element element) {
- Contract.Ensures(element.IsDefined || !Contract.Result());
+ public bool Contains2(Element element)
+ {
+ Contract.Ensures(element.IsDefined || !Contract.Result());
- throw new NotImplementedException();
+ throw new NotImplementedException();
}
- public bool IsDefined {
- get { throw new NotImplementedException(); }
+ public bool IsDefined
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
}
+}
- }
- #endregion
-
- ///
- /// All values in Mini implement this interface.
- ///
- public interface MiniValue {
+#endregion
+///
+/// All values in Mini implement this interface.
+///
+public interface MiniValue
+{
///
- /// True if the value is not the special undefined value for its type.
- /// Every type has an undefined value and all operations involving one or more undefined arguments result in undefined.
+ /// True if the value is not the special undefined value for its type.
+ /// Every type has an undefined value and all operations involving one or more undefined arguments result in undefined.
///
- bool IsDefined { get; }
-
- }
+ bool IsDefined
+ {
+ get;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/IOperations.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/IOperations.cs
index 1ac0b700..7603efd9 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/IOperations.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/IOperations.cs
@@ -14,69 +14,74 @@
using System;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
namespace RaphaelSchweizer
{
- class Program
- {
- static void Main()
- {
- new OpA().Do("Item", 3);
- }
-
- [ContractClass(typeof(OperationConstraint))]
- public interface IOperation
+ internal class Program
{
- Type[] Types { get; }
- double Do(params object[] operands);
- }
-
- [ContractClassFor(typeof(IOperation))]
- public abstract class OperationConstraint : IOperation
- {
- public Type[] Types
- {
- get
+ private static void Main()
{
- Contract.Ensures(Contract.Result() != null);
- return default(Type[]);
+ new OpA().Do("Item", 3);
}
- }
- public double Do(params object[] operands)
- {
- Contract.Requires(operands != null);
- Contract.Requires(operands.Length == Types.Length);
- Contract.Ensures(Contract.Result() >= 0);
- Contract.Ensures(Contract.Result() <= 1);
- return default(double);
- }
- }
+ [ContractClass(typeof (OperationConstraint))]
+ public interface IOperation
+ {
+ Type[] Types
+ {
+ get;
+ }
- public class OpA : IOperation
- {
- public Type[] Types
- {
- get
+ double Do(params object[] operands);
+ }
+
+ [ContractClassFor(typeof (IOperation))]
+ public abstract class OperationConstraint : IOperation
{
- Contract.Ensures(Contract.Result().Length == 2);
- return new[] { typeof(string), typeof(decimal) };
+ public Type[] Types
+ {
+ get
+ {
+ Contract.Ensures(Contract.Result() != null);
+ return default(Type[]);
+ }
+ }
+
+ public double Do(params object[] operands)
+ {
+ Contract.Requires(operands != null);
+ Contract.Requires(operands.Length == Types.Length);
+ Contract.Ensures(Contract.Result() >= 0);
+ Contract.Ensures(Contract.Result() <= 1);
+ return default(double);
+ }
}
- }
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="Lower bound access ok",PrimaryILOffset=8,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="Upper bound access ok",PrimaryILOffset=8,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="Lower bound access ok",PrimaryILOffset=11,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="Upper bound access ok",PrimaryILOffset=11,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="ensures is valid",PrimaryILOffset=52,MethodILOffset=36)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="ensures is valid",PrimaryILOffset=77,MethodILOffset=36)]
- public double Do(params object[] operands)
- {
- Console.Write(string.Format("We have {0} {1}s\n", operands[1], operands[0]));
- return 0;
- }
+ public class OpA : IOperation
+ {
+ public Type[] Types
+ {
+ get
+ {
+ Contract.Ensures(Contract.Result().Length == 2);
+ return new[] {typeof (string), typeof (decimal)};
+ }
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "Lower bound access ok", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "Upper bound access ok", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "Lower bound access ok", PrimaryILOffset = 11, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "Upper bound access ok", PrimaryILOffset = 11, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "ensures is valid", PrimaryILOffset = 52, MethodILOffset = 36)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "ensures is valid", PrimaryILOffset = 77, MethodILOffset = 36)]
+ public double Do(params object[] operands)
+ {
+ Console.Write("We have {0} {1}s\n", operands[1], operands[0]);
+ return 0;
+ }
+ }
}
- }
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/IfaceImplicitlyImplementedBug.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/IfaceImplicitlyImplementedBug.cs
index 40e13de0..3f112197 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/IfaceImplicitlyImplementedBug.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/IfaceImplicitlyImplementedBug.cs
@@ -12,49 +12,52 @@
//
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-namespace ClousotTests {
+namespace ClousotTests
+{
+ using System;
+ using System.Diagnostics.Contracts;
- using System;
- using System.Diagnostics.Contracts;
- using Microsoft.Research.ClousotRegression;
+ using Microsoft.Research.ClousotRegression;
- [ContractClass(typeof(JContracts))]
- public interface J
- {
- bool B();
- }
- [ContractClassFor(typeof(J))]
- public abstract class JContracts : J
- {
- public bool B()
+ [ContractClass(typeof (JContracts))]
+ public interface J
{
- Contract.Ensures(Contract.Result());
- throw new NotImplementedException();
+ bool B();
}
- }
- public interface K : J
- {
- new bool B();
- }
- public class Test
+ [ContractClassFor(typeof (J))]
+ public abstract class JContracts : J
{
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as receiver)", PrimaryILOffset = 15, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 20, MethodILOffset = 0)]
- public void M1(J j)
- {
- Contract.Requires(j != null);
- Contract.Assert(j.B());
- }
+ public bool B()
+ {
+ Contract.Ensures(Contract.Result());
+ throw new NotImplementedException();
+ }
+ }
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as receiver)", PrimaryILOffset = 15, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 20, MethodILOffset = 0)]
- public void M2(K k) {
- Contract.Requires(k != null);
- Contract.Assert(k.B());
- }
+ public interface K : J
+ {
+ new bool B();
+ }
+
+ public class Test
+ {
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as receiver)", PrimaryILOffset = 15, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 20, MethodILOffset = 0)]
+ public void M1(J j)
+ {
+ Contract.Requires(j != null);
+ Contract.Assert(j.B());
+ }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as receiver)", PrimaryILOffset = 15, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 20, MethodILOffset = 0)]
+ public void M2(K k)
+ {
+ Contract.Requires(k != null);
+ Contract.Assert(k.B());
+ }
}
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/Mulder.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/Mulder.cs
index a89555dc..f754dc72 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/Mulder.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/Mulder.cs
@@ -16,170 +16,169 @@
namespace ContractTest
{
- #region Usings
+ #region Usings
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading;
-
- #endregion
-
- ///
- /// enumerator joiner base.
- ///
-
- internal class EnumeratorJoinerBase : IEnumerator
- {
- #region Attributes
-
- ///
- /// ma x_ loc k_ wait.
- ///
- internal const int MAXLOCKWAIT = 10000; // milliseconds
-
- ///
- /// if null, the state of the enumeratorjoiner is invalid (ie it
- /// points to before the first item or after the last item).
- /// current enumerator.
- ///
- protected int? _currentEnumerator;
-
- ///
- /// current object.
- ///
- protected object _currentObject;
-
- ///
- /// rw lock.
- ///
- protected ReaderWriterLock _rwLock;
-
- ///
- /// enumerators.
- ///
- private readonly IList _enumerators;
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
#endregion
- #region Constructors
-
///
- /// Initializes a new instance of the class.
+ /// enumerator joiner base.
///
- ///
- /// The rw lock.
- ///
- ///
- /// The enumerators.
- ///
- [ClousotRegressionTest]
- internal EnumeratorJoinerBase(ReaderWriterLock rwLock, params IEnumerator[] enumerators)
+ internal class EnumeratorJoinerBase : IEnumerator
{
- this._rwLock = rwLock;
- this._enumerators = new List(enumerators);
- }
-
- #endregion
-
- #region Properties
-
- ///
- /// Gets Current.
- ///
- ///
- ///
- public virtual object Current
- {
- [ClousotRegressionTest]
- get
- {
- // TODO: detect modification of the collection
- switch (this._currentEnumerator)
+ #region Attributes
+
+ ///
+ /// ma x_ loc k_ wait.
+ ///
+ internal const int MAXLOCKWAIT = 10000; // milliseconds
+
+ ///
+ /// if null, the state of the enumeratorjoiner is invalid (ie it
+ /// points to before the first item or after the last item).
+ /// current enumerator.
+ ///
+ protected int? _currentEnumerator;
+
+ ///
+ /// current object.
+ ///
+ protected object _currentObject;
+
+ ///
+ /// rw lock.
+ ///
+ protected ReaderWriterLock _rwLock;
+
+ ///
+ /// enumerators.
+ ///
+ private readonly IList _enumerators;
+
+ #endregion
+
+ #region Constructors
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// The rw lock.
+ ///
+ ///
+ /// The enumerators.
+ ///
+ [ClousotRegressionTest]
+ internal EnumeratorJoinerBase(ReaderWriterLock rwLock, params IEnumerator[] enumerators)
{
- case null:
- throw new InvalidOperationException("Current object accessed before MoveNext() was called.");
- case -1:
- throw new InvalidOperationException("Enumerator is past the end of the collection.");
- default:
- return this._currentObject;
+ _rwLock = rwLock;
+ _enumerators = new List(enumerators);
}
- }
- }
- #endregion
+ #endregion
- #region Methods
+ #region Properties
- ///
- /// move next.
- ///
- ///
- /// The move next.
- ///
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="Possibly calling a method on a null reference 'this._rwLock'",PrimaryILOffset=11,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="Possibly calling a method on a null reference 'this._enumerators'. The static checker determined that the condition 'this._enumerators != null' should hold on entry. Nevertheless, the condition may be too strong for the callers. If you think it is ok, add an object invariant or an assumption at entry to document it: Contract.Invariant(this._enumerators != null);",PrimaryILOffset=64,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="Possibly calling a method on a null reference",PrimaryILOffset=69,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="Possibly calling a method on a null reference 'this._enumerators'. The static checker determined that the condition 'this._enumerators != null' should hold on entry. Nevertheless, the condition may be too strong for the callers. If you think it is ok, add an object invariant or an assumption at entry to document it: Contract.Invariant(this._enumerators != null);",PrimaryILOffset=100,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="Possibly calling a method on a null reference",PrimaryILOffset=105,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="Possibly calling a method on a null reference 'this._rwLock'",PrimaryILOffset=284,MethodILOffset=290)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven: index < this.Count. The static checker determined that the condition '0 < this._enumerators.Count' should hold on entry. Nevertheless, the condition may be too strong for the callers. If you think it is ok, add an explicit assumption at entry to document it: Contract.Assume(0 < this._enumerators.Count);",PrimaryILOffset=33,MethodILOffset=64)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven: index >= 0",PrimaryILOffset=13,MethodILOffset=100)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven: index < this.Count",PrimaryILOffset=33,MethodILOffset=100)]
- public virtual bool MoveNext()
- {
- this._rwLock.AcquireReaderLock(MAXLOCKWAIT);
- try
- {
- switch (this._currentEnumerator)
+ ///
+ /// Gets Current.
+ ///
+ ///
+ ///
+ public virtual object Current
{
- case null:
- this._currentEnumerator = 0;
- this._enumerators[0].Reset();
- break;
- case -1:
- return false;
+ [ClousotRegressionTest]
+ get
+ {
+ // TODO: detect modification of the collection
+ switch (_currentEnumerator)
+ {
+ case null:
+ throw new InvalidOperationException("Current object accessed before MoveNext() was called.");
+ case -1:
+ throw new InvalidOperationException("Enumerator is past the end of the collection.");
+ default:
+ return _currentObject;
+ }
+ }
}
- if (this._enumerators[this._currentEnumerator.Value].MoveNext())
+ #endregion
+
+ #region Methods
+
+ ///
+ /// move next.
+ ///
+ ///
+ /// The move next.
+ ///
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference 'this._rwLock'", PrimaryILOffset = 11, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference 'this._enumerators'. The static checker determined that the condition 'this._enumerators != null' should hold on entry. Nevertheless, the condition may be too strong for the callers. If you think it is ok, add an object invariant or an assumption at entry to document it: Contract.Invariant(this._enumerators != null);", PrimaryILOffset = 64, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference", PrimaryILOffset = 69, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference 'this._enumerators'. The static checker determined that the condition 'this._enumerators != null' should hold on entry. Nevertheless, the condition may be too strong for the callers. If you think it is ok, add an object invariant or an assumption at entry to document it: Contract.Invariant(this._enumerators != null);", PrimaryILOffset = 100, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference", PrimaryILOffset = 105, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference 'this._rwLock'", PrimaryILOffset = 284, MethodILOffset = 290)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "requires unproven: index < this.Count. The static checker determined that the condition '0 < this._enumerators.Count' should hold on entry. Nevertheless, the condition may be too strong for the callers. If you think it is ok, add an explicit assumption at entry to document it: Contract.Assume(0 < this._enumerators.Count);", PrimaryILOffset = 33, MethodILOffset = 64)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "requires unproven: index >= 0", PrimaryILOffset = 13, MethodILOffset = 100)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "requires unproven: index < this.Count", PrimaryILOffset = 33, MethodILOffset = 100)]
+ public virtual bool MoveNext()
{
- this._currentObject = this._enumerators[this._currentEnumerator.Value].Current;
- return true;
+ _rwLock.AcquireReaderLock(MAXLOCKWAIT);
+ try
+ {
+ switch (_currentEnumerator)
+ {
+ case null:
+ _currentEnumerator = 0;
+ _enumerators[0].Reset();
+ break;
+ case -1:
+ return false;
+ }
+
+ if (_enumerators[_currentEnumerator.Value].MoveNext())
+ {
+ _currentObject = _enumerators[_currentEnumerator.Value].Current;
+ return true;
+ }
+ else
+ {
+ // We've hit the last item of the current enumerator;
+ if (_currentEnumerator == _enumerators.Count - 1)
+ {
+ // We're also on the last enumerator. State is now invalid.
+ _currentEnumerator = -1;
+ _currentObject = null;
+ return false;
+ }
+ else
+ {
+ _currentEnumerator++;
+ return MoveNext();
+ }
+ }
+ }
+ finally
+ {
+ _rwLock.ReleaseReaderLock();
+ }
}
- else
+
+ ///
+ /// reset.
+ ///
+ [ClousotRegressionTest]
+ public virtual void Reset()
{
- // We've hit the last item of the current enumerator;
- if (this._currentEnumerator == this._enumerators.Count - 1)
- {
- // We're also on the last enumerator. State is now invalid.
- this._currentEnumerator = -1;
- this._currentObject = null;
- return false;
- }
- else
- {
- this._currentEnumerator++;
- return this.MoveNext();
- }
+ _currentEnumerator = null;
+ _currentObject = null;
}
- }
- finally
- {
- this._rwLock.ReleaseReaderLock();
- }
- }
- ///
- /// reset.
- ///
- [ClousotRegressionTest]
- public virtual void Reset()
- {
- this._currentEnumerator = null;
- this._currentObject = null;
+ #endregion
}
-
- #endregion
- }
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/MultidimArrays.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/MultidimArrays.cs
index ae3167d3..30582569 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/MultidimArrays.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/MultidimArrays.cs
@@ -14,12 +14,14 @@
using System;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
-class Test {
+internal class Test
+{
[ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=17,MethodILOffset=0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 17, MethodILOffset = 0)]
public static void Bug1(int x, int y)
{
var myval = new double[x, 100];
@@ -27,10 +29,10 @@ public static void Bug1(int x, int y)
}
[ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=21,MethodILOffset=0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 21, MethodILOffset = 0)]
public static void Bug2(int x, int y)
{
- var myval = new double[234, 100];
- Contract.Assert(myval != null);
+ var myval = new double[234, 100];
+ Contract.Assert(myval != null);
}
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/NoUpHavocMethods.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/NoUpHavocMethods.cs
index d9c225cf..8544f403 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/NoUpHavocMethods.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/NoUpHavocMethods.cs
@@ -16,39 +16,39 @@
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
namespace UserFeedback
{
- class Iterators
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=69,MethodILOffset=0)]
- static void AsList()
+ internal class Iterators
{
- var xs = new List() { 1, 2, 3 };
-
- Contract.Assume(xs.Count > 0);
-
- foreach (var x in xs) // struct enumerator
- {
- Contract.Assert(xs.Count > 0);
- }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 69, MethodILOffset = 0)]
+ private static void AsList()
+ {
+ var xs = new List {1, 2, 3};
+
+ Contract.Assume(xs.Count > 0);
+
+ foreach (var x in xs) // struct enumerator
+ {
+ Contract.Assert(xs.Count > 0);
+ }
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 68, MethodILOffset = 0)]
+ private static void AsCollection()
+ {
+ ICollection xs = new List {1, 2, 3};
+
+ Contract.Assume(xs.Count > 0);
+
+ foreach (var x in xs) // IEnumerator enumerator
+ {
+ Contract.Assert(xs.Count > 0);
+ }
+ }
}
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=68,MethodILOffset=0)]
- static void AsCollection()
- {
- ICollection xs = new List() { 1, 2, 3 };
-
- Contract.Assume(xs.Count > 0);
-
- foreach (var x in xs) // IEnumerator enumerator
- {
- Contract.Assert(xs.Count > 0);
- }
- }
-
- }
-
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/OperatorOverloading.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/OperatorOverloading.cs
index 8a3a7b20..74231c52 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/OperatorOverloading.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/OperatorOverloading.cs
@@ -17,22 +17,23 @@
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
namespace OperatorOverloading
{
- class Program
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=8,MethodILOffset=11)]
- static void Main(string[] args)
- {
- Work((string)new Class());
- }
+ internal class Program
+ {
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 8, MethodILOffset = 11)]
+ private static void Main(string[] args)
+ {
+ Work((string) new Class());
+ }
- private static void Work(string p)
- {
- Contract.Requires(p != null);
- }
- }
-}
+ private static void Work(string p)
+ {
+ Contract.Requires(p != null);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/TypeSpecializations.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/TypeSpecializations.cs
index f776395b..809d5d0f 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/TypeSpecializations.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/TypeSpecializations.cs
@@ -14,199 +14,201 @@
using System;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
namespace FrancescoGenericRepro
{
- class Program
- {
- static void Main(string[] args)
+ internal class Program
{
+ private static void Main(string[] args)
+ {
+ }
}
- }
-
-
- #region I contract binding
- [ContractClass(typeof(IContract<>))]
- public partial interface I
- {
- void M(T t);
- }
+ #region I contract binding
- [ContractClassFor(typeof(I<>))]
- abstract class IContract : I
- {
- public void M(T t)
+ [ContractClass(typeof (IContract<>))]
+ public interface I
{
- Contract.Requires(t != null);
+ void M(T t);
}
- }
- #endregion
-
- class C : I
- where X : class
- {
- public void M(T t2)
+ [ContractClassFor(typeof (I<>))]
+ internal abstract class IContract : I
{
+ public void M(T t)
+ {
+ Contract.Requires(t != null);
+ }
}
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=12,MethodILOffset=19)]
- public void Test(T t3)
+ #endregion
+
+ internal class C : I
+ where X : class
{
- Contract.Assume(t3 != null);
+ public void M(T t2)
+ {
+ }
- M(t3);
- }
- }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 12, MethodILOffset = 19)]
+ public void Test(T t3)
+ {
+ Contract.Assume(t3 != null);
+ M(t3);
+ }
+ }
- #region J contract binding
- [ContractClass(typeof(JContract))]
- public partial interface J
- {
- void M(T x);
- }
+ #region J contract binding
- [ContractClassFor(typeof(J))]
- abstract class JContract : J
- {
- public void M(T x2)
+ [ContractClass(typeof (JContract))]
+ public interface J
{
- Contract.Requires(x2 != null);
+ void M(T x);
}
- }
- #endregion
- class D : J
- where X:class
- {
- public void M(T x3)
+ [ContractClassFor(typeof (J))]
+ internal abstract class JContract : J
{
+ public void M(T x2)
+ {
+ Contract.Requires(x2 != null);
+ }
}
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=12,MethodILOffset=19)]
- public void Test(X x4)
- {
- Contract.Assume(x4 != null);
+ #endregion
- M(x4);
- }
- }
+ internal class D : J
+ where X : class
+ {
+ public void M(T x3)
+ {
+ }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 12, MethodILOffset = 19)]
+ public void Test(X x4)
+ {
+ Contract.Assume(x4 != null);
- class A
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=33,MethodILOffset=39)]
- public virtual X M(X x1)
- {
- Contract.Requires(x1 != null);
- Contract.Ensures(Contract.Result() != null);
- return x1;
- }
- }
-
- class B : A
- where Y : class
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=33,MethodILOffset=1)]
- public override X M(X x1)
- {
- return x1;
+ M(x4);
+ }
}
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=12,MethodILOffset=19)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=37,MethodILOffset=0)]
- public void Test(X x2)
+
+ internal class A
{
- Contract.Assume(x2 != null);
- var result = M(x2);
- Contract.Assert(result != null);
- }
- }
-
- class C : B
- where Y:class
- where Z:class
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=12,MethodILOffset=2)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=33,MethodILOffset=9)]
- public override X M(X x1)
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 33, MethodILOffset = 39)]
+ public virtual X M(X x1)
+ {
+ Contract.Requires(x1 != null);
+ Contract.Ensures(Contract.Result() != null);
+ return x1;
+ }
+ }
+
+ internal class B : A
+ where Y : class
{
- var result = base.M(x1);
- return result;
- }
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=12,MethodILOffset=19)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=37,MethodILOffset=0)]
- new public void Test(X x2)
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 33, MethodILOffset = 1)]
+ public override X M(X x1)
+ {
+ return x1;
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 12, MethodILOffset = 19)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 37, MethodILOffset = 0)]
+ public void Test(X x2)
+ {
+ Contract.Assume(x2 != null);
+ var result = M(x2);
+ Contract.Assert(result != null);
+ }
+ }
+
+ internal class C : B
+ where Y : class
+ where Z : class
{
- Contract.Assume(x2 != null);
-
- var result = M(x2);
- Contract.Assert(result != null);
- }
- }
-
- class D : C
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=12,MethodILOffset=15)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=33,MethodILOffset=22)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=8,MethodILOffset=22)]
- public override int M(int x1)
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 12, MethodILOffset = 2)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 33, MethodILOffset = 9)]
+ public override X M(X x1)
+ {
+ var result = base.M(x1);
+ return result;
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 12, MethodILOffset = 19)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 37, MethodILOffset = 0)]
+ public new void Test(X x2)
+ {
+ Contract.Assume(x2 != null);
+
+ var result = M(x2);
+ Contract.Assert(result != null);
+ }
+ }
+
+ internal class D : C
{
- Contract.Ensures(Contract.Result() > 0);
-
- var result = base.M(x1);
- return 1;
- }
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=12,MethodILOffset=11)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=21,MethodILOffset=0)]
- new public void Test(int x2)
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 12, MethodILOffset = 15)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 33, MethodILOffset = 22)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 8, MethodILOffset = 22)]
+ public override int M(int x1)
+ {
+ Contract.Ensures(Contract.Result() > 0);
+
+ var result = base.M(x1);
+ return 1;
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 12, MethodILOffset = 11)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 21, MethodILOffset = 0)]
+ public new void Test(int x2)
+ {
+ Contract.Requires(x2 == 0);
+
+ var result = M(x2);
+ // ensures specialization needs to kick in
+ Contract.Assert(result > 0);
+ }
+ }
+
+
+ internal class Recursive
+ where This : Recursive
{
- Contract.Requires(x2 == 0);
-
- var result = M(x2);
- // ensures specialization needs to kick in
- Contract.Assert(result > 0);
- }
- }
-
-
- class Recursive
- where This : Recursive {
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=16,MethodILOffset=27)]
- This GetInstance() {
- Contract.Ensures(Contract.Result() != null);
- return (This)this;
- }
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=32,MethodILOffset=0)]
- public void Test() {
- var result = GetInstance();
-
- result.AddSomething();
-
- Contract.Assert(result != null);
- }
-
- void AddSomething() {
- }
-
- }
-
-}
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 16, MethodILOffset = 27)]
+ private This GetInstance()
+ {
+ Contract.Ensures(Contract.Result() != null);
+ return (This) this;
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 32, MethodILOffset = 0)]
+ public void Test()
+ {
+ var result = GetInstance();
+
+ result.AddSomething();
+
+ Contract.Assert(result != null);
+ }
+
+ private void AddSomething()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/Z3Test1.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/Z3Test1.cs
index 48e6968d..a3c4cc54 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/Z3Test1.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/Z3Test1.cs
@@ -13,13 +13,14 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-
-public static class Test {
+using Microsoft.Research.ClousotRegression;
- [ClousotRegressionTest]
- public static void M() {
- }
-}
+public static class Test
+{
+ [ClousotRegressionTest]
+ public static void M()
+ {
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3Test2.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3Test2.cs
index afde1653..4fd60b71 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3Test2.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3Test2.cs
@@ -13,17 +13,19 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
-public static class Test {
+using Microsoft.Research.ClousotRegression;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.False,Message=@"ensures (always false) may be reachable: false",PrimaryILOffset=2,MethodILOffset=13)]
- public static int M(int x) {
- Contract.Ensures(false);
+using System.Diagnostics.Contracts;
- return x;
- }
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"ensures (always false) may be reachable: false", PrimaryILOffset = 2, MethodILOffset = 13)]
+ public static int M(int x)
+ {
+ Contract.Ensures(false);
-}
+ return x;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test10.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test10.cs
index b289c5b1..2fdffdf8 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test10.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test10.cs
@@ -13,24 +13,28 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
+
using Microsoft.Research.ClousotRegression;
+
using System.Diagnostics.Contracts;
-public static class Test {
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Bottom, Message = @"ensures unreachable", PrimaryILOffset = 2, MethodILOffset = 46)]
+ public static int M(int x)
+ {
+ Contract.Ensures(false);
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.Bottom,Message=@"ensures unreachable",PrimaryILOffset=2,MethodILOffset=46)]
- public static int M(int x) {
- Contract.Ensures(false);
+ if (x == 0)
+ {
+ throw new Exception();
+ }
+ if (x != 0)
+ {
+ throw new Exception();
+ }
- if (x == 0) {
- throw new Exception();
- }
- if (x != 0) {
- throw new Exception();
+ return 0;
}
-
- return 0;
- }
-
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test11.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test11.cs
index 03974eb8..c9c0c172 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test11.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test11.cs
@@ -13,30 +13,35 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
+
using Microsoft.Research.ClousotRegression;
+
using System.Diagnostics.Contracts;
-public struct S {
- public int a;
+public struct S
+{
+ public int a;
}
-public static class Test {
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 34, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 10, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Bottom, Message = @"ensures unreachable", PrimaryILOffset = 2, MethodILOffset = 58)]
+ public static int M(S x)
+ {
+ Contract.Ensures(false);
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=34,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=10,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Bottom,Message=@"ensures unreachable",PrimaryILOffset=2,MethodILOffset=58)]
- public static int M(S x) {
- Contract.Ensures(false);
+ if (x.a == 0)
+ {
+ throw new Exception();
+ }
+ if (x.a != 0)
+ {
+ throw new Exception();
+ }
- if (x.a == 0) {
- throw new Exception();
- }
- if (x.a != 0) {
- throw new Exception();
+ return 0;
}
-
- return 0;
- }
-
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test12.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test12.cs
index 5959d444..c398b30a 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test12.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test12.cs
@@ -13,30 +13,35 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
+
using Microsoft.Research.ClousotRegression;
+
using System.Diagnostics.Contracts;
-public struct S {
- public int a;
+public struct S
+{
+ public int a;
}
-public static class Test {
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 2, MethodILOffset = 56)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 32, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 9, MethodILOffset = 0)]
+ public static int M(ref S x)
+ {
+ Contract.Ensures(false);
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=2,MethodILOffset=56)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=32,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=9,MethodILOffset=0)]
- public static int M(ref S x) {
- Contract.Ensures(false);
+ if (x.a > 0)
+ {
+ throw new Exception();
+ }
+ if (x.a <= 0)
+ {
+ throw new Exception();
+ }
- if (x.a > 0) {
- throw new Exception();
- }
- if (x.a <= 0) {
- throw new Exception();
+ return 0;
}
-
- return 0;
- }
-
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test13.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test13.cs
index 92f43205..bab9ed1b 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test13.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test13.cs
@@ -13,27 +13,32 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
+
using Microsoft.Research.ClousotRegression;
+
using System.Diagnostics.Contracts;
-public struct S {
- public int a;
+public struct S
+{
+ public int a;
}
-public static class Test {
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=2,MethodILOffset=55)]
- public static int M(uint x) {
- Contract.Ensures(false);
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 2, MethodILOffset = 55)]
+ public static int M(uint x)
+ {
+ Contract.Ensures(false);
- if (x > 1000) throw new Exception();
+ if (x > 1000)
+ throw new Exception();
- uint y = x + 1;
+ uint y = x + 1;
- if (y > x) throw new Exception();
+ if (y > x)
+ throw new Exception();
- return 0;
- }
-
-}
+ return 0;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test14.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test14.cs
index 5465d2ef..297b8808 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test14.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test14.cs
@@ -13,25 +13,28 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
+
using Microsoft.Research.ClousotRegression;
+
using System.Diagnostics.Contracts;
-public struct S {
- public int a;
+public struct S
+{
+ public int a;
}
-public static class Test {
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=23,MethodILOffset=0)]
- public static int M(uint x) {
- Contract.Requires(x < 1000);
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 23, MethodILOffset = 0)]
+ public static int M(uint x)
+ {
+ Contract.Requires(x < 1000);
- uint y = x + 1;
+ uint y = x + 1;
- Contract.Assert(y > x);
+ Contract.Assert(y > x);
- return 0;
- }
-
-}
+ return 0;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test15.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test15.cs
index 7e1cdd35..ec821bd4 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test15.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test15.cs
@@ -13,24 +13,26 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
+using Microsoft.Research.ClousotRegression;
-public static class Test {
+using System.Diagnostics.Contracts;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (in unbox)",PrimaryILOffset=35,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=21,MethodILOffset=46)]
- public static int M(int x) {
- Contract.Requires(x < 50);
- Contract.Ensures(Contract.Result() < 50);
- var o = (object)(x);
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (in unbox)", PrimaryILOffset = 35, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 21, MethodILOffset = 46)]
+ public static int M(int x)
+ {
+ Contract.Requires(x < 50);
+ Contract.Ensures(Contract.Result() < 50);
- var y = (int)o;
+ var o = (object) (x);
- return y;
- }
+ var y = (int) o;
-}
+ return y;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test16.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test16.cs
index 11ef6443..7c95dd78 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test16.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test16.cs
@@ -13,37 +13,40 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
+using Microsoft.Research.ClousotRegression;
-public static class Test {
+using System.Diagnostics.Contracts;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=37,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=48,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=75,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=89,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=103,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=117,MethodILOffset=0)]
- public static void M(int x) {
- Contract.Requires(x < 50);
- int y;
- if (x > 25) {
- y = x - 24;
- Contract.Assert( y >= 0);
- Contract.Assert( y < 50);
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 37, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 48, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 75, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 89, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 103, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 117, MethodILOffset = 0)]
+ public static void M(int x)
+ {
+ Contract.Requires(x < 50);
+
+ int y;
+ if (x > 25)
+ {
+ y = x - 24;
+ Contract.Assert(y >= 0);
+ Contract.Assert(y < 50);
+ }
+ else
+ {
+ y = x + 25;
+ Contract.Assert(y >= 0, "not true if x < -25");
+ Contract.Assert(y <= 50);
+ }
+
+ Contract.Assert(y >= 0);
+ Contract.Assert(y <= 50);
}
- else {
- y = x + 25;
- Contract.Assert( y >= 0, "not true if x < -25");
- Contract.Assert( y <= 50);
- }
-
- Contract.Assert( y >= 0);
- Contract.Assert( y <= 50);
-
- }
-
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test17.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test17.cs
index 8bbbc2ab..da3d2937 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test17.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test17.cs
@@ -13,36 +13,39 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
+using Microsoft.Research.ClousotRegression;
-public static class Test {
+using System.Diagnostics.Contracts;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=42,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=54,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=84,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=99,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=114,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=129,MethodILOffset=0)]
- public static void M(ref int x, ref int y) {
- Contract.Requires(x < 50);
- if (x > 25) {
- y = x - 24;
- Contract.Assert( y >= 0);
- Contract.Assert( y < 50);
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 42, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 54, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 84, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 99, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 114, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 129, MethodILOffset = 0)]
+ public static void M(ref int x, ref int y)
+ {
+ Contract.Requires(x < 50);
+
+ if (x > 25)
+ {
+ y = x - 24;
+ Contract.Assert(y >= 0);
+ Contract.Assert(y < 50);
+ }
+ else
+ {
+ y = x + 25;
+ Contract.Assert(y >= 0, "not true if x < -25");
+ Contract.Assert(y <= 50);
+ }
+
+ Contract.Assert(y >= 0);
+ Contract.Assert(y <= 50);
}
- else {
- y = x + 25;
- Contract.Assert( y >= 0, "not true if x < -25");
- Contract.Assert( y <= 50);
- }
-
- Contract.Assert( y >= 0);
- Contract.Assert( y <= 50);
-
- }
-
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test18.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test18.cs
index 9d95cdce..2717f713 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test18.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test18.cs
@@ -13,37 +13,43 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
+using Microsoft.Research.ClousotRegression;
-public static class Test {
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=84,MethodILOffset=0)]
+using System.Diagnostics.Contracts;
- public static void M(int x, int y) {
- int a;
- if (x > 0) {
- if (y > 0) {
- a = 1;
- }
- else {
- a = 2;
- }
- }
- else {
- if (y > 0) {
- a = 3;
- }
- else {
- a = 4;
- }
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 84, MethodILOffset = 0)]
+ public static void M(int x, int y)
+ {
+ int a;
+ if (x > 0)
+ {
+ if (y > 0)
+ {
+ a = 1;
+ }
+ else
+ {
+ a = 2;
+ }
+ }
+ else
+ {
+ if (y > 0)
+ {
+ a = 3;
+ }
+ else
+ {
+ a = 4;
+ }
+ }
+
+ Contract.Assume(x <= 0 || y > 0);
+ Contract.Assert(a != 2);
}
-
- Contract.Assume(x <= 0 || y > 0);
- Contract.Assert(a != 2);
- }
-
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test19.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test19.cs
index 56126f62..715ae999 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test19.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test19.cs
@@ -13,23 +13,25 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
+using Microsoft.Research.ClousotRegression;
-public static class Test {
+using System.Diagnostics.Contracts;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=16,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=33,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=25,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=37,MethodILOffset=0)]
- public static void M(int[] x, int y) {
- Contract.Requires(x != null);
- int a = x[y];
- Contract.Assert(y >= 0);
- Contract.Assert(y < x.Length);
- }
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 16, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 33, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 25, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 37, MethodILOffset = 0)]
+ public static void M(int[] x, int y)
+ {
+ Contract.Requires(x != null);
-}
+ int a = x[y];
+ Contract.Assert(y >= 0);
+ Contract.Assert(y < x.Length);
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test20.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test20.cs
index d0b2c360..db84985e 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test20.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test20.cs
@@ -13,24 +13,25 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
+using Microsoft.Research.ClousotRegression;
-public static class Test {
+using System.Diagnostics.Contracts;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=40,MethodILOffset=0)]
- public static void M(int x, int y) {
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 40, MethodILOffset = 0)]
+ public static void M(int x, int y)
+ {
+ Contract.Requires(y > 50);
- Contract.Requires(y > 50);
+ for (int i = x; i > 0; i--)
+ {
+ x--;
+ }
- for (int i = x; i > 0; i--) {
- x--;
+ Contract.Assert(y > 50);
}
-
- Contract.Assert(y > 50);
- }
-
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test21.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test21.cs
index bca4ad7c..7d9f7616 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test21.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test21.cs
@@ -13,24 +13,25 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
-
-public class ConstructorTestDerived {
+using Microsoft.Research.ClousotRegression;
- object data;
+using System.Diagnostics.Contracts;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=34,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=15,MethodILOffset=39)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=26,MethodILOffset=39)]
- public void M(object obj) {
- Contract.Requires(obj != null);
- Contract.Ensures(this.data != null);
- this.data = obj;
+public class ConstructorTestDerived
+{
+ private object data;
- }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 34, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 15, MethodILOffset = 39)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 26, MethodILOffset = 39)]
+ public void M(object obj)
+ {
+ Contract.Requires(obj != null);
+ Contract.Ensures(data != null);
-}
+ data = obj;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test22.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test22.cs
index 8e7a5f0b..c5aff4b6 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test22.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test22.cs
@@ -13,25 +13,28 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
+
using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
+using System.Diagnostics.Contracts;
-public class ConstructorTestDerived {
- object data;
+public class ConstructorTestDerived
+{
+ private object data;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"ensures unproven: this.data != null",PrimaryILOffset=26,MethodILOffset=49)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=43,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as field receiver)",PrimaryILOffset=15,MethodILOffset=49)]
- public void M(object obj, bool flag) {
- Contract.Requires(obj != null);
- Contract.Ensures(this.data != null);
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"ensures unproven: this.data != null", PrimaryILOffset = 26, MethodILOffset = 49)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 43, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 15, MethodILOffset = 49)]
+ public void M(object obj, bool flag)
+ {
+ Contract.Requires(obj != null);
+ Contract.Ensures(data != null);
- if (flag) {
- this.data = obj;
+ if (flag)
+ {
+ data = obj;
+ }
}
- }
-
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test23.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test23.cs
index 9ce46f76..90626a12 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test23.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test23.cs
@@ -13,31 +13,34 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
+using Microsoft.Research.ClousotRegression;
-public class ConstructorTestDerived {
-
- ConstructorTestDerived next;
+using System.Diagnostics.Contracts;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=35,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=21,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=61,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=74,MethodILOffset=0)]
- public void M(ConstructorTestDerived obj) {
- Contract.Requires(obj != null);
- Contract.Assert(this != null);
- var last = obj;
- while (obj != null) {
- last = obj;
- obj = obj.next;
+public class ConstructorTestDerived
+{
+ private ConstructorTestDerived next;
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 35, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 21, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 61, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 74, MethodILOffset = 0)]
+ public void M(ConstructorTestDerived obj)
+ {
+ Contract.Requires(obj != null);
+ Contract.Assert(this != null);
+
+ var last = obj;
+ while (obj != null)
+ {
+ last = obj;
+ obj = obj.next;
+ }
+
+ Contract.Assert(last != null);
+ Contract.Assert(this != null);
}
-
- Contract.Assert(last != null);
- Contract.Assert(this != null);
- }
-
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test3.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test3.cs
index 9c8d20e9..68d84886 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test3.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test3.cs
@@ -13,17 +13,19 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
-public static class Test {
+using Microsoft.Research.ClousotRegression;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.False,Message=@"ensures (always false) may be reachable: false",PrimaryILOffset=2,MethodILOffset=15)]
- public static int M(int x) {
- Contract.Ensures(false);
+using System.Diagnostics.Contracts;
- return x + 5;
- }
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"ensures (always false) may be reachable: false", PrimaryILOffset = 2, MethodILOffset = 15)]
+ public static int M(int x)
+ {
+ Contract.Ensures(false);
-}
+ return x + 5;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test4.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test4.cs
index 5367ca79..604f60db 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test4.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test4.cs
@@ -13,17 +13,19 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
-public static class Test {
+using Microsoft.Research.ClousotRegression;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.False,Message=@"ensures (always false) may be reachable: false",PrimaryILOffset=2,MethodILOffset=15)]
- public static int M(int x) {
- Contract.Ensures(false);
+using System.Diagnostics.Contracts;
- return x - 5;
- }
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"ensures (always false) may be reachable: false", PrimaryILOffset = 2, MethodILOffset = 15)]
+ public static int M(int x)
+ {
+ Contract.Ensures(false);
-}
+ return x - 5;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test5.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test5.cs
index 5c78239d..929a42eb 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test5.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test5.cs
@@ -13,17 +13,19 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
-public static class Test {
+using Microsoft.Research.ClousotRegression;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.False,Message=@"ensures (always false) may be reachable: false",PrimaryILOffset=2,MethodILOffset=15)]
- public static int M(int x) {
- Contract.Ensures(false);
+using System.Diagnostics.Contracts;
- return x * 5;
- }
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"ensures (always false) may be reachable: false", PrimaryILOffset = 2, MethodILOffset = 15)]
+ public static int M(int x)
+ {
+ Contract.Ensures(false);
-}
+ return x*5;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test6.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test6.cs
index 6d6e2195..cdb3b71b 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test6.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test6.cs
@@ -13,16 +13,18 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
-public static class Test {
+using Microsoft.Research.ClousotRegression;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.False,Message=@"ensures (always false) may be reachable: false",PrimaryILOffset=2,MethodILOffset=15)]
- public static int M(int x) {
- Contract.Ensures(false);
- return x / 5;
- }
+using System.Diagnostics.Contracts;
-}
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"ensures (always false) may be reachable: false", PrimaryILOffset = 2, MethodILOffset = 15)]
+ public static int M(int x)
+ {
+ Contract.Ensures(false);
+ return x/5;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test7.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test7.cs
index f43a00ea..66fe58f4 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test7.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test7.cs
@@ -13,16 +13,18 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
-public static class Test {
+using Microsoft.Research.ClousotRegression;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.False,Message=@"ensures (always false) may be reachable: false",PrimaryILOffset=2,MethodILOffset=15)]
- public static int M(int x) {
- Contract.Ensures(false);
- return x % 5;
- }
+using System.Diagnostics.Contracts;
-}
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"ensures (always false) may be reachable: false", PrimaryILOffset = 2, MethodILOffset = 15)]
+ public static int M(int x)
+ {
+ Contract.Ensures(false);
+ return x%5;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test8.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test8.cs
index 2ed2939f..92351809 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test8.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test8.cs
@@ -13,18 +13,20 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
-public static class Test {
+using Microsoft.Research.ClousotRegression;
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.False,Message=@"ensures (always false) may be reachable: false",PrimaryILOffset=2,MethodILOffset=17)]
- public static int M(int x) {
- Contract.Ensures(false);
+using System.Diagnostics.Contracts;
- int y = x;
- return y % 5;
- }
+public static class Test
+{
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"ensures (always false) may be reachable: false", PrimaryILOffset = 2, MethodILOffset = 17)]
+ public static int M(int x)
+ {
+ Contract.Ensures(false);
-}
+ int y = x;
+ return y%5;
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test9.cs b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test9.cs
index a6758ff9..51824f65 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test9.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/Sources/z3test9.cs
@@ -13,17 +13,19 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using Microsoft.Research.ClousotRegression;
-using System.Diagnostics.Contracts;
-public static class Test {
+using Microsoft.Research.ClousotRegression;
- [ClousotRegressionTest]
- // no proof obligation as it isn't reachable in the CFG already
- public static int M(int x) {
- Contract.Ensures(false);
+using System.Diagnostics.Contracts;
- throw new Exception();
- }
+public static class Test
+{
+ [ClousotRegressionTest]
+ // no proof obligation as it isn't reachable in the CFG already
+ public static int M(int x)
+ {
+ Contract.Ensures(false);
-}
+ throw new Exception();
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/TestDriver.cs b/Microsoft.Research/RegressionTest/ClousotTests/TestDriver.cs
index df136027..d9abe2a2 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/TestDriver.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/TestDriver.cs
@@ -17,474 +17,488 @@
using System.Diagnostics;
using System.IO;
using System.Text;
+
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Tests
{
- public static class TestDriver
- {
- const string ReferenceDirRoot = @"Microsoft.Research\Imported\ReferenceAssemblies\";
- const string ContractReferenceDirRoot = @"Microsoft.Research\Contracts\bin\Debug\";
- const string ClousotExe = @"Microsoft.Research\Clousot\bin\debug\clousot.exe";
- const string Clousot2Exe = @"Microsoft.Research\Clousot2\bin\debug\clousot2.exe";
- const string Clousot2SExe = @"Microsoft.Research\Clousot2S\bin\debug\clousot2s.exe";
- const string Clousot2SlicingExe = @"Microsoft.Research\Clousot2_Queue\bin\debug\Clousot2_Queue.exe";
- const string ClousotServiceHostExe = @"Microsoft.Research\Clousot2_WCFServiceHost\bin\debug\Cloudot.exe";
- const string ToolsRoot = @"Microsoft.Research\Imported\Tools\";
-
- private static readonly Random randGenerator = new Random();
-
- internal static void Clousot(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
- {
- var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
- var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
- var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
- var absoluteSource = absoluteBinary;
- var libPathsString = FormLibPaths(contractreferencedir, options);
- var args = String.Format("{0} /regression /define:cci1only;clousot1 -framework:{4} -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString, options.Framework);
- WriteRSPFile(absoluteBinaryDir, options, args);
- if (options.Fast || System.Diagnostics.Debugger.IsAttached)
- {
- output.WriteLine("Calling CCI1Driver.Main with: {0}", args);
- // Use output to avoid Clousot from closing the Console
- Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.CCI1Driver.Main(args.Split(' '), output));
- }
- else
- RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(ClousotExe), args, output, options.TestName);
- }
- internal static void Clousot2(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
- {
- var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
- var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
- var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
- var absoluteSource = absoluteBinary;
- var libPathsString = FormLibPaths(contractreferencedir, options) + " /libpaths:.";
- var args = String.Format("{0} /show progress /regression /define:cci2only;clousot2 -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString);
- WriteRSPFile(absoluteBinaryDir, options, args);
- if (options.Fast || System.Diagnostics.Debugger.IsAttached)
- {
- output.WriteLine("Calling CCI2Driver.Main with: {0}", args);
- // Use output to avoid Clousot2 from closing the Console
- Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.CCI2Driver.Main(args.Split(' '), output));
- }
- else
- RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(Clousot2Exe), args, output);
- }
- private static void WriteRSPFile(string dir, Options options, string args)
+ public static class TestDriver
{
- using (var file = new StreamWriter(Path.Combine(dir, options.TestName + ".rsp")))
- {
- file.WriteLine(args);
- file.Close();
- }
- }
+ private const string ReferenceDirRoot = @"Microsoft.Research\Imported\ReferenceAssemblies\";
+ private const string ContractReferenceDirRoot = @"Microsoft.Research\Contracts\bin\Debug\";
+ private const string ClousotExe = @"Microsoft.Research\Clousot\bin\debug\clousot.exe";
+ private const string Clousot2Exe = @"Microsoft.Research\Clousot2\bin\debug\clousot2.exe";
+ private const string Clousot2SExe = @"Microsoft.Research\Clousot2S\bin\debug\clousot2s.exe";
+ private const string Clousot2SlicingExe = @"Microsoft.Research\Clousot2_Queue\bin\debug\Clousot2_Queue.exe";
+ private const string ClousotServiceHostExe = @"Microsoft.Research\Clousot2_WCFServiceHost\bin\debug\Cloudot.exe";
+ private const string ToolsRoot = @"Microsoft.Research\Imported\Tools\";
+
+ private static readonly Random randGenerator = new Random();
+
+ internal static void Clousot(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
+ {
+ var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
+ var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
+ var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
+ var absoluteSource = absoluteBinary;
+ var libPathsString = FormLibPaths(contractreferencedir, options);
+ var args = string.Format("{0} /regression /define:cci1only;clousot1 -framework:{4} -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString, options.Framework);
+ WriteRSPFile(absoluteBinaryDir, options, args);
+ if (options.Fast || Debugger.IsAttached)
+ {
+ output.WriteLine("Calling CCI1Driver.Main with: {0}", args);
+ // Use output to avoid Clousot from closing the Console
+ Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.CCI1Driver.Main(args.Split(' '), output));
+ }
+ else
+ RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(ClousotExe), args, output, options.TestName);
+ }
- internal static void Clousot1Slicing(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
- {
- var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
- var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
- var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
- var absoluteSource = absoluteBinary;
- var libPathsString = FormLibPaths(contractreferencedir, options) + " /libpaths:.";
- var args = String.Format("{0} -cci1 /regression /define:cci1only;clousot1 -framework:{4} -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString, options.Framework);
- if (options.Fast || System.Diagnostics.Debugger.IsAttached)
- {
- output.WriteLine("Calling NewCCI2Driver.Main with: {0}", args);
- // Use output to avoid Clousot from closing the Console
- Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.NewCCI2Driver.Main(args.Split(' '), output));
- }
- else
- RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(Clousot2SlicingExe), args, output);
- }
- internal static void Clousot2Slicing(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
- {
- var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
- var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
- var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
- var absoluteSource = absoluteBinary;
- var libPathsString = FormLibPaths(contractreferencedir, options) + " /libpaths:.";
- var args = String.Format("{0} /show progress /regression /define:cci2only;clousot2 -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString);
- if (options.Fast || System.Diagnostics.Debugger.IsAttached)
- {
- output.WriteLine("Calling NewCCI2Driver.Main with: {0}", args);
- // Use output to avoid Clousot2 from closing the Console
- Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.NewCCI2Driver.Main(args.Split(' '), output));
- }
- else
- RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(Clousot2SlicingExe), args, output);
- }
- internal static void Clousot2S(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
- {
- EnsureService(options);
- var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
- var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
- var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
- var absoluteSource = absoluteBinary;
- var libPathsString = FormLibPaths(contractreferencedir, options) + " /libpaths:.";
- var args = String.Format("{0} /show progress /regression /define:cci2only;clousot2 -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString);
- if (options.Fast || System.Diagnostics.Debugger.IsAttached)
- {
- output.WriteLine("Calling SDriver.Main with: {0}", args);
- // Use output to avoid Clousot2S from closing the Console
- Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.SDriver.Main(args.Split(' '), output));
- }
- else
- RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(Clousot2SExe), args, output);
- }
+ internal static void Clousot2(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
+ {
+ var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
+ var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
+ var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
+ var absoluteSource = absoluteBinary;
+ var libPathsString = FormLibPaths(contractreferencedir, options) + " /libpaths:.";
+ var args = string.Format("{0} /show progress /regression /define:cci2only;clousot2 -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString);
+ WriteRSPFile(absoluteBinaryDir, options, args);
+ if (options.Fast || Debugger.IsAttached)
+ {
+ output.WriteLine("Calling CCI2Driver.Main with: {0}", args);
+ // Use output to avoid Clousot2 from closing the Console
+ Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.CCI2Driver.Main(args.Split(' '), output));
+ }
+ else
+ RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(Clousot2Exe), args, output);
+ }
- private static int RunProcess(string cwd, string tool, string arguments, Output output, string writeBatchFile = null)
- {
- ProcessStartInfo i = new ProcessStartInfo(tool, arguments);
- output.WriteLine("Running '{0}'", i.FileName);
- output.WriteLine(" {0}", i.Arguments);
- i.RedirectStandardOutput = true;
- i.RedirectStandardError = true;
- i.UseShellExecute = false;
- i.CreateNoWindow = true;
- i.WorkingDirectory = cwd;
- i.ErrorDialog = false;
- if (writeBatchFile != null)
- {
- var file = new StreamWriter(Path.Combine(cwd, writeBatchFile + ".bat"));
- file.WriteLine("\"{0}\" {1} %1 %2 %3 %4 %5", i.FileName, i.Arguments);
- file.Close();
- }
-
- using (Process p = Process.Start(i))
- {
- p.OutputDataReceived += output.OutputDataReceivedEventHandler;
- p.ErrorDataReceived += output.ErrDataReceivedEventHandler;
- p.BeginOutputReadLine();
- p.BeginErrorReadLine();
-
- Assert.IsTrue(p.WaitForExit(200000), "{0} timed out", i.FileName);
- if (p.ExitCode != 0)
+ private static void WriteRSPFile(string dir, Options options, string args)
{
- Assert.AreEqual(0, p.ExitCode, "{0} returned an errorcode of {1}.", i.FileName, p.ExitCode);
+ using (var file = new StreamWriter(Path.Combine(dir, options.TestName + ".rsp")))
+ {
+ file.WriteLine(args);
+ file.Close();
+ }
}
- return p.ExitCode;
- }
- }
- static string FormLibPaths(string contractReferenceDir, Options options)
- {
- // MB: do not change CurrentDirectory because it makes parallel tests fail
-
- if (options.LibPaths == null)
- return "";
-
- StringBuilder sb = null;
- if (options.UseContractReferenceAssemblies)
- sb = new StringBuilder("/libpaths:").Append(contractReferenceDir);
-
- foreach (var path in options.LibPaths)
- {
- if (sb == null)
- sb = new StringBuilder("/libpaths:");
- else
- sb.Append(';');
-
- sb.Append(options.MakeAbsolute(Path.Combine(path, options.ContractFramework)));
- }
- if (sb == null)
- return "";
- return sb.ToString();
- }
+ internal static void Clousot1Slicing(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
+ {
+ var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
+ var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
+ var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
+ var absoluteSource = absoluteBinary;
+ var libPathsString = FormLibPaths(contractreferencedir, options) + " /libpaths:.";
+ var args = string.Format("{0} -cci1 /regression /define:cci1only;clousot1 -framework:{4} -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString, options.Framework);
+ if (options.Fast || Debugger.IsAttached)
+ {
+ output.WriteLine("Calling NewCCI2Driver.Main with: {0}", args);
+ // Use output to avoid Clousot from closing the Console
+ Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.NewCCI2Driver.Main(args.Split(' '), output));
+ }
+ else
+ RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(Clousot2SlicingExe), args, output);
+ }
+ internal static void Clousot2Slicing(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
+ {
+ var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
+ var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
+ var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
+ var absoluteSource = absoluteBinary;
+ var libPathsString = FormLibPaths(contractreferencedir, options) + " /libpaths:.";
+ var args = string.Format("{0} /show progress /regression /define:cci2only;clousot2 -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString);
+ if (options.Fast || Debugger.IsAttached)
+ {
+ output.WriteLine("Calling NewCCI2Driver.Main with: {0}", args);
+ // Use output to avoid Clousot2 from closing the Console
+ Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.NewCCI2Driver.Main(args.Split(' '), output));
+ }
+ else
+ RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(Clousot2SlicingExe), args, output);
+ }
- internal static string Build(Options options, string extraCompilerOptions, Output output, out string absoluteSourceDir)
- {
- var sourceFile = options.MakeAbsolute(options.SourceFile);
- var compilerpath = options.MakeAbsolute(Path.Combine(ToolsRoot, options.BuildFramework, options.Compiler));
- var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.BuildFramework));
- var sourcedir = absoluteSourceDir = Path.GetDirectoryName(sourceFile);
- var outputdir = Path.Combine(sourcedir, "bin", options.BuildFramework);
- var extension = options.UseExe ? ".exe" : ".dll";
- var targetKind = options.UseExe ? "exe" : "library";
- var suffix = "_" + options.TestInstance;
- if (options.GenerateUniqueOutputName)
- suffix += "." + randGenerator.Next(0x10000).ToString("X4"); // enables concurrent tests on the same source file
- var targetfile = Path.Combine(outputdir, Path.GetFileNameWithoutExtension(sourceFile) + suffix + extension);
- // add Microsoft.Contracts reference if needed
- if (!options.BuildFramework.Contains("v4."))
- {
- options.References.Add("Microsoft.Contracts.dll");
- }
-
- // MB: do not modify the CurrentDirectory, that could cause parallel tests to fail
-
- var resolvedReferences = ResolveReferences(options);
- var referenceString = ReferenceOptions(resolvedReferences);
- if (!Directory.Exists(outputdir))
- {
- Directory.CreateDirectory(outputdir);
- }
- var args = String.Format("/debug /t:{4} /out:{0} {5} {3} {2} {1}", targetfile, sourceFile, referenceString, options.CompilerOptions(resolvedReferences), targetKind, extraCompilerOptions);
- var exitCode = RunProcess(sourcedir, compilerpath, args, output);
- if (exitCode != 0)
- {
- return null;
- }
- //CopyReferenceAssemblies(resolvedReferences, outputdir);
-
- return targetfile;
- }
+ internal static void Clousot2S(string absoluteSourceDir, string absoluteBinary, Options options, Output output)
+ {
+ EnsureService(options);
+ var referencedir = options.MakeAbsolute(Path.Combine(ReferenceDirRoot, options.BuildFramework));
+ var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ContractFramework));
+ var absoluteBinaryDir = Path.GetDirectoryName(absoluteBinary);
+ var absoluteSource = absoluteBinary;
+ var libPathsString = FormLibPaths(contractreferencedir, options) + " /libpaths:.";
+ var args = string.Format("{0} /show progress /regression /define:cci2only;clousot2 -libpaths:{2} {3} {1}", options.ClousotOptions, absoluteSource, referencedir, libPathsString);
+ if (options.Fast || Debugger.IsAttached)
+ {
+ output.WriteLine("Calling SDriver.Main with: {0}", args);
+ // Use output to avoid Clousot2S from closing the Console
+ Assert.AreEqual(0, Microsoft.Research.CodeAnalysis.SDriver.Main(args.Split(' '), output));
+ }
+ else
+ RunProcess(absoluteBinaryDir, options.GetFullExecutablePath(Clousot2SExe), args, output);
+ }
- private static void CopyReferenceAssemblies(List resolvedReferences, string outputdir)
- {
- foreach (var r in resolvedReferences)
- {
- try
+ private static int RunProcess(string cwd, string tool, string arguments, Output output, string writeBatchFile = null)
{
- var fileName = Path.Combine(outputdir, Path.GetFileName(r));
- if (File.Exists(fileName))
- {
- try
+ ProcessStartInfo i = new ProcessStartInfo(tool, arguments);
+ output.WriteLine("Running '{0}'", i.FileName);
+ output.WriteLine(" {0}", i.Arguments);
+ i.RedirectStandardOutput = true;
+ i.RedirectStandardError = true;
+ i.UseShellExecute = false;
+ i.CreateNoWindow = true;
+ i.WorkingDirectory = cwd;
+ i.ErrorDialog = false;
+ if (writeBatchFile != null)
{
- File.SetAttributes(fileName, FileAttributes.Normal);
+ var file = new StreamWriter(Path.Combine(cwd, writeBatchFile + ".bat"));
+ file.WriteLine("\"{0}\" {1} %1 %2 %3 %4 %5", i.FileName, i.Arguments);
+ file.Close();
+ }
+
+ using (Process p = Process.Start(i))
+ {
+ p.OutputDataReceived += output.OutputDataReceivedEventHandler;
+ p.ErrorDataReceived += output.ErrDataReceivedEventHandler;
+ p.BeginOutputReadLine();
+ p.BeginErrorReadLine();
+
+ Assert.IsTrue(p.WaitForExit(200000), "{0} timed out", i.FileName);
+ if (p.ExitCode != 0)
+ {
+ Assert.AreEqual(0, p.ExitCode, "{0} returned an errorcode of {1}.", i.FileName, p.ExitCode);
+ }
+ return p.ExitCode;
}
- catch { }
- }
- File.Copy(r, fileName, true);
}
- catch { }
- }
- }
- private static List ResolveReferences(Options options)
- {
- var result = new List();
- foreach (var r in options.References)
- {
- foreach (var root in options.LibPaths)
+
+ private static string FormLibPaths(string contractReferenceDir, Options options)
{
- var dir = options.MakeAbsolute(Path.Combine(root, options.BuildFramework));
-
- var path = Path.Combine(dir, r);
- if (File.Exists(path))
- {
- result.Add(path);
- break;
- }
+ // MB: do not change CurrentDirectory because it makes parallel tests fail
+
+ if (options.LibPaths == null)
+ return "";
+
+ StringBuilder sb = null;
+ if (options.UseContractReferenceAssemblies)
+ sb = new StringBuilder("/libpaths:").Append(contractReferenceDir);
+
+ foreach (var path in options.LibPaths)
+ {
+ if (sb == null)
+ sb = new StringBuilder("/libpaths:");
+ else
+ sb.Append(';');
+
+ sb.Append(options.MakeAbsolute(Path.Combine(path, options.ContractFramework)));
+ }
+ if (sb == null)
+ return "";
+ return sb.ToString();
}
- foreach (var root in new[] { ReferenceDirRoot, ContractReferenceDirRoot })
+
+
+ internal static string Build(Options options, string extraCompilerOptions, Output output, out string absoluteSourceDir)
{
- var dir = options.MakeAbsolute(Path.Combine(root, options.BuildFramework));
-
- var path = Path.Combine(dir, r);
- if (File.Exists(path))
- {
- result.Add(path);
- break;
- }
+ var sourceFile = options.MakeAbsolute(options.SourceFile);
+ var compilerpath = options.MakeAbsolute(Path.Combine(ToolsRoot, options.BuildFramework, options.Compiler));
+ var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.BuildFramework));
+ var sourcedir = absoluteSourceDir = Path.GetDirectoryName(sourceFile);
+ var outputdir = Path.Combine(sourcedir, "bin", options.BuildFramework);
+ var extension = options.UseExe ? ".exe" : ".dll";
+ var targetKind = options.UseExe ? "exe" : "library";
+ var suffix = "_" + options.TestInstance;
+ if (options.GenerateUniqueOutputName)
+ suffix += "." + randGenerator.Next(0x10000).ToString("X4"); // enables concurrent tests on the same source file
+ var targetfile = Path.Combine(outputdir, Path.GetFileNameWithoutExtension(sourceFile) + suffix + extension);
+ // add Microsoft.Contracts reference if needed
+ if (!options.BuildFramework.Contains("v4."))
+ {
+ options.References.Add("Microsoft.Contracts.dll");
+ }
+
+ // MB: do not modify the CurrentDirectory, that could cause parallel tests to fail
+
+ var resolvedReferences = ResolveReferences(options);
+ var referenceString = ReferenceOptions(resolvedReferences);
+ if (!Directory.Exists(outputdir))
+ {
+ Directory.CreateDirectory(outputdir);
+ }
+ var args = string.Format("/debug /t:{4} /out:{0} {5} {3} {2} {1}", targetfile, sourceFile, referenceString, options.CompilerOptions(resolvedReferences), targetKind, extraCompilerOptions);
+ var exitCode = RunProcess(sourcedir, compilerpath, args, output);
+ if (exitCode != 0)
+ {
+ return null;
+ }
+ //CopyReferenceAssemblies(resolvedReferences, outputdir);
+
+ return targetfile;
}
- }
- return result;
- }
- private static string ReferenceOptions(List references)
- {
- var sb = new StringBuilder();
- foreach (var r in references)
- {
- sb.Append(String.Format(@"/r:{0} ", r));
- }
- return sb.ToString();
- }
+ private static void CopyReferenceAssemblies(List resolvedReferences, string outputdir)
+ {
+ foreach (var r in resolvedReferences)
+ {
+ try
+ {
+ var fileName = Path.Combine(outputdir, Path.GetFileName(r));
+ if (File.Exists(fileName))
+ {
+ try
+ {
+ File.SetAttributes(fileName, FileAttributes.Normal);
+ }
+ catch
+ {
+ }
+ }
+ File.Copy(r, fileName, true);
+ }
+ catch
+ {
+ }
+ }
+ }
- public static void BuildAndAnalyze(Options options)
- {
- var output = Output.ConsoleOutputFor(options.TestName);
-
- string absoluteSourceDir;
- var target = Build(options, "/d:CLOUSOT1", output, out absoluteSourceDir);
- if (target != null)
- {
- Clousot(absoluteSourceDir, target, options, output);
- }
- }
+ private static List ResolveReferences(Options options)
+ {
+ var result = new List();
+ foreach (var r in options.References)
+ {
+ foreach (var root in options.LibPaths)
+ {
+ var dir = options.MakeAbsolute(Path.Combine(root, options.BuildFramework));
+
+ var path = Path.Combine(dir, r);
+ if (File.Exists(path))
+ {
+ result.Add(path);
+ break;
+ }
+ }
+ foreach (var root in new[] {ReferenceDirRoot, ContractReferenceDirRoot})
+ {
+ var dir = options.MakeAbsolute(Path.Combine(root, options.BuildFramework));
+
+ var path = Path.Combine(dir, r);
+ if (File.Exists(path))
+ {
+ result.Add(path);
+ break;
+ }
+ }
+ }
+ return result;
+ }
- public static void BuildAndAnalyze2(Options options)
- {
- if (options.SkipForCCI2)
- return;
+ private static string ReferenceOptions(List references)
+ {
+ var sb = new StringBuilder();
+ foreach (var r in references)
+ {
+ sb.Append(string.Format(@"/r:{0} ", r));
+ }
+ return sb.ToString();
+ }
- BuildAndAnalyze2(options, Output.ConsoleOutputFor(options.TestName));
- }
+ public static void BuildAndAnalyze(Options options)
+ {
+ var output = Output.ConsoleOutputFor(options.TestName);
- private static void BuildAndAnalyze2(Options options, Output output)
- {
- string absoluteSourceDir;
- var target = Build(options, "/d:CLOUSOT2", output, out absoluteSourceDir);
+ string absoluteSourceDir;
+ var target = Build(options, "/d:CLOUSOT1", output, out absoluteSourceDir);
+ if (target != null)
+ {
+ Clousot(absoluteSourceDir, target, options, output);
+ }
+ }
- if (target != null)
- Clousot2(absoluteSourceDir, target, options, output);
- }
+ public static void BuildAndAnalyze2(Options options)
+ {
+ if (options.SkipForCCI2)
+ return;
- public static void BuildAndAnalyze2S(Options options)
- {
- if (options.SkipForCCI2)
- return;
+ BuildAndAnalyze2(options, Output.ConsoleOutputFor(options.TestName));
+ }
- BuildAndAnalyze2S(options, Output.ConsoleOutputFor(options.TestName));
- }
-
- private static void BuildAndAnalyze2S(Options options, Output output)
- {
- string absoluteSourceDir;
- var target = Build(options, "/d:CLOUSOT2", output, out absoluteSourceDir);
+ private static void BuildAndAnalyze2(Options options, Output output)
+ {
+ string absoluteSourceDir;
+ var target = Build(options, "/d:CLOUSOT2", output, out absoluteSourceDir);
- if (target != null)
- Clousot2S(absoluteSourceDir, target, options, output);
- }
+ if (target != null)
+ Clousot2(absoluteSourceDir, target, options, output);
+ }
- public static void BuildAndAnalyze1Slicing(Options options)
- {
- BuildAndAnalyze1Slicing(options, Output.ConsoleOutputFor(options.TestName));
- }
+ public static void BuildAndAnalyze2S(Options options)
+ {
+ if (options.SkipForCCI2)
+ return;
- private static void BuildAndAnalyze1Slicing(Options options, Output output)
- {
- string absoluteSourceDir;
- var target = Build(options, "/d:CLOUSOT1", output, out absoluteSourceDir);
+ BuildAndAnalyze2S(options, Output.ConsoleOutputFor(options.TestName));
+ }
- if (target != null)
- Clousot1Slicing(absoluteSourceDir, target, options, output);
- }
+ private static void BuildAndAnalyze2S(Options options, Output output)
+ {
+ string absoluteSourceDir;
+ var target = Build(options, "/d:CLOUSOT2", output, out absoluteSourceDir);
- public static void BuildAndAnalyze2Slicing(Options options)
- {
- if (options.SkipForCCI2)
- return;
+ if (target != null)
+ Clousot2S(absoluteSourceDir, target, options, output);
+ }
- if (options.SkipSlicing)
- return;
+ public static void BuildAndAnalyze1Slicing(Options options)
+ {
+ BuildAndAnalyze1Slicing(options, Output.ConsoleOutputFor(options.TestName));
+ }
- BuildAndAnalyze2Slicing(options, Output.ConsoleOutputFor(options.TestName));
- }
+ private static void BuildAndAnalyze1Slicing(Options options, Output output)
+ {
+ string absoluteSourceDir;
+ var target = Build(options, "/d:CLOUSOT1", output, out absoluteSourceDir);
- private static void BuildAndAnalyze2Slicing(Options options, Output output)
- {
- string absoluteSourceDir;
- var target = Build(options, "/d:CLOUSOT2 /d:SLICING", output, out absoluteSourceDir);
+ if (target != null)
+ Clousot1Slicing(absoluteSourceDir, target, options, output);
+ }
- if (target != null)
- Clousot2Slicing(absoluteSourceDir, target, options, output);
- }
+ public static void BuildAndAnalyze2Slicing(Options options)
+ {
+ if (options.SkipForCCI2)
+ return;
- #region Parallel tests
+ if (options.SkipSlicing)
+ return;
- private const string DefaultBeginMessage = "Build and analysis launched. Look at End results.";
- private static bool SkipForCCI2(Options options) { return options.SkipForCCI2; }
+ BuildAndAnalyze2Slicing(options, Output.ConsoleOutputFor(options.TestName));
+ }
- public static readonly AsyncTestDriver AsyncFast2 = new AsyncTestDriver(BuildAndAnalyze2, SkipForCCI2, AsyncTestDriver.MaxWaitHandles_AllButOne) { BeginMessage = DefaultBeginMessage };
- public static readonly AsyncTestDriver Async2S = new AsyncTestDriver(BuildAndAnalyze2S, SkipForCCI2) { BeginMessage = DefaultBeginMessage };
+ private static void BuildAndAnalyze2Slicing(Options options, Output output)
+ {
+ string absoluteSourceDir;
+ var target = Build(options, "/d:CLOUSOT2 /d:SLICING", output, out absoluteSourceDir);
- #endregion
+ if (target != null)
+ Clousot2Slicing(absoluteSourceDir, target, options, output);
+ }
- #region Service actions
+ #region Parallel tests
- private static Process serviceProcess;
- private static Object serviceProcessLock = new Object();
+ private const string DefaultBeginMessage = "Build and analysis launched. Look at End results.";
- private static void EnsureService(Options options)
- {
- lock (serviceProcessLock) // prevent the service to be run twice at the same time
- {
- if (serviceProcess == null)
- StartService(options);
- Assert.IsFalse(serviceProcess.HasExited, "Service needed but service process already exited");
- }
- }
+ private static bool SkipForCCI2(Options options)
+ {
+ return options.SkipForCCI2;
+ }
- private static void StartService(Options options)
- {
- if (serviceProcess != null)
- StopService();
+ public static readonly AsyncTestDriver AsyncFast2 = new AsyncTestDriver(BuildAndAnalyze2, SkipForCCI2, AsyncTestDriver.MaxWaitHandles_AllButOne) {BeginMessage = DefaultBeginMessage};
+ public static readonly AsyncTestDriver Async2S = new AsyncTestDriver(BuildAndAnalyze2S, SkipForCCI2) {BeginMessage = DefaultBeginMessage};
- // First make sure another instance is not already running (because we don't know which version is running)
- foreach (var process in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ClousotServiceHostExe)))
- {
- process.CloseMainWindow();
- if (!process.WaitForExit(1000))
- process.Kill();
- }
+ #endregion
- var serviceHostDir = options.MakeAbsolute(Path.GetDirectoryName(ClousotServiceHostExe));
+ #region Service actions
- // note: we do not want to use ClousotServiceHostExe from the deployment directory because the app.config will be missing
- serviceProcess = StartServiceProcess(serviceHostDir, options.MakeAbsolute(ClousotServiceHostExe), "", Output.Ignore);
- }
+ private static Process serviceProcess;
+ private static readonly object serviceProcessLock = new object();
- public static void Cleanup()
- {
- KillRemainingClients();
- StopService();
- }
+ private static void EnsureService(Options options)
+ {
+ lock (serviceProcessLock) // prevent the service to be run twice at the same time
+ {
+ if (serviceProcess == null)
+ StartService(options);
+ Assert.IsFalse(serviceProcess.HasExited, "Service needed but service process already exited");
+ }
+ }
- private static void KillRemainingClients()
- {
- foreach (var process in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Clousot2SExe)))
- {
- process.CloseMainWindow();
- if (!process.WaitForExit(1000))
- process.Kill();
- }
- }
+ private static void StartService(Options options)
+ {
+ if (serviceProcess != null)
+ StopService();
- private static void StopService()
- {
- lock (serviceProcessLock)
- {
- if (serviceProcess == null)
- return;
+ // First make sure another instance is not already running (because we don't know which version is running)
+ foreach (var process in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ClousotServiceHostExe)))
+ {
+ process.CloseMainWindow();
+ if (!process.WaitForExit(1000))
+ process.Kill();
+ }
- serviceProcess.StandardInput.WriteLine();
- if (!serviceProcess.WaitForExit(2000))
+ var serviceHostDir = options.MakeAbsolute(Path.GetDirectoryName(ClousotServiceHostExe));
+
+ // note: we do not want to use ClousotServiceHostExe from the deployment directory because the app.config will be missing
+ serviceProcess = StartServiceProcess(serviceHostDir, options.MakeAbsolute(ClousotServiceHostExe), "", Output.Ignore);
+ }
+
+ public static void Cleanup()
{
- serviceProcess.Close();
- if (!serviceProcess.WaitForExit(2000))
- {
- serviceProcess.Kill();
- Assert.IsTrue(serviceProcess.WaitForExit(2000), "{0} did not want to exit");
- }
+ KillRemainingClients();
+ StopService();
}
- Assert.AreEqual(0, serviceProcess.ExitCode, "{0} returned an errorcode of {1}.", serviceProcess.StartInfo.FileName, serviceProcess.ExitCode);
- serviceProcess.Dispose();
- serviceProcess = null;
- }
- }
- private static Process StartServiceProcess(string cwd, string tool, string arguments, Output output, string writeBatchFile = null)
- {
- ProcessStartInfo i = new ProcessStartInfo(tool, arguments);
- output.WriteLine("Running '{0}'", i.FileName);
- output.WriteLine(" {0}", i.Arguments);
- i.RedirectStandardInput = true;
- i.RedirectStandardOutput = true;
- i.RedirectStandardError = true;
- i.UseShellExecute = false;
- i.CreateNoWindow = true;
- i.WorkingDirectory = cwd;
- i.ErrorDialog = false;
- if (writeBatchFile != null)
- {
- var file = new StreamWriter(Path.Combine(cwd, writeBatchFile + ".bat"));
- file.WriteLine("\"{0}\" {1} %1 %2 %3 %4 %5", i.FileName, i.Arguments);
- file.Close();
- }
-
- var p = Process.Start(i);
-
- p.OutputDataReceived += output.OutputDataReceivedEventHandler;
- p.ErrorDataReceived += output.ErrDataReceivedEventHandler;
- p.BeginOutputReadLine();
- p.BeginErrorReadLine();
-
- Assert.IsFalse(p.WaitForExit(1000), "{0} exited too quickly", i.FileName);
-
- return p;
- }
+ private static void KillRemainingClients()
+ {
+ foreach (var process in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Clousot2SExe)))
+ {
+ process.CloseMainWindow();
+ if (!process.WaitForExit(1000))
+ process.Kill();
+ }
+ }
+
+ private static void StopService()
+ {
+ lock (serviceProcessLock)
+ {
+ if (serviceProcess == null)
+ return;
+
+ serviceProcess.StandardInput.WriteLine();
+ if (!serviceProcess.WaitForExit(2000))
+ {
+ serviceProcess.Close();
+ if (!serviceProcess.WaitForExit(2000))
+ {
+ serviceProcess.Kill();
+ Assert.IsTrue(serviceProcess.WaitForExit(2000), "{0} did not want to exit");
+ }
+ }
+ Assert.AreEqual(0, serviceProcess.ExitCode, "{0} returned an errorcode of {1}.", serviceProcess.StartInfo.FileName, serviceProcess.ExitCode);
+ serviceProcess.Dispose();
+ serviceProcess = null;
+ }
+ }
- #endregion
- }
-}
+ private static Process StartServiceProcess(string cwd, string tool, string arguments, Output output, string writeBatchFile = null)
+ {
+ ProcessStartInfo i = new ProcessStartInfo(tool, arguments);
+ output.WriteLine("Running '{0}'", i.FileName);
+ output.WriteLine(" {0}", i.Arguments);
+ i.RedirectStandardInput = true;
+ i.RedirectStandardOutput = true;
+ i.RedirectStandardError = true;
+ i.UseShellExecute = false;
+ i.CreateNoWindow = true;
+ i.WorkingDirectory = cwd;
+ i.ErrorDialog = false;
+ if (writeBatchFile != null)
+ {
+ var file = new StreamWriter(Path.Combine(cwd, writeBatchFile + ".bat"));
+ file.WriteLine("\"{0}\" {1} %1 %2 %3 %4 %5", i.FileName, i.Arguments);
+ file.Close();
+ }
+
+ var p = Process.Start(i);
+
+ p.OutputDataReceived += output.OutputDataReceivedEventHandler;
+ p.ErrorDataReceived += output.ErrDataReceivedEventHandler;
+ p.BeginOutputReadLine();
+ p.BeginErrorReadLine();
+
+ Assert.IsFalse(p.WaitForExit(1000), "{0} exited too quickly", i.FileName);
+
+ return p;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/ClousotTests/v.cs b/Microsoft.Research/RegressionTest/ClousotTests/v.cs
index e626a16e..aaf03534 100644
--- a/Microsoft.Research/RegressionTest/ClousotTests/v.cs
+++ b/Microsoft.Research/RegressionTest/ClousotTests/v.cs
@@ -13,370 +13,365 @@
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using ClousotTests;
+
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Tests
{
- ///
- /// Summary description for RewriterTests
- ///
- [TestClass]
- public class ClousotTests
- {
- public ClousotTests()
- {
- //
- // TODO: Add constructor logic here
- //
- }
-
- private TestContext testContextInstance;
-
///
- ///Gets or sets the test context which provides
- ///information about and functionality for the current test run.
- ///
- public TestContext TestContext
+ /// Summary description for RewriterTests
+ ///
+ [TestClass]
+ public class ClousotTests
{
- get
- {
- return testContextInstance;
- }
- set
- {
- testContextInstance = value;
- }
- }
+ private TestContext testContextInstance;
- #region Additional test attributes
- //
- // You can use the following additional attributes as you write your tests:
- //
- // Use ClassInitialize to run code before running the first test in the class
- // [ClassInitialize()]
- // public static void MyClassInitialize(TestContext testContext) { }
- //
- // Use ClassCleanup to run code after all tests in a class have run
- // [ClassCleanup()]
- // public static void MyClassCleanup() { }
- //
- // Use TestInitialize to run code before running each test
- // [TestInitialize()]
- // public void MyTestInitialize() { }
- //
- //Use TestCleanup to run code after each test has run
- [TestCleanup()]
- public void MyTestCleanup() {
- if (TestContext.CurrentTestOutcome != UnitTestOutcome.Passed && CurrentGroupInfo != null && !System.Diagnostics.Debugger.IsAttached)
- {
- // record failing case
- CurrentGroupInfo.WriteFailure();
- }
- }
- #endregion
+ ///
+ /// Gets or sets the test context which provides
+ /// information about and functionality for the current test run.
+ ///
+ public TestContext TestContext
+ {
+ get
+ {
+ return testContextInstance;
+ }
+ set
+ {
+ testContextInstance = value;
+ }
+ }
- #region Regular tests
+ #region Additional test attributes
+
+ //
+ // You can use the following additional attributes as you write your tests:
+ //
+ // Use ClassInitialize to run code before running the first test in the class
+ // [ClassInitialize()]
+ // public static void MyClassInitialize(TestContext testContext) { }
+ //
+ // Use ClassCleanup to run code after all tests in a class have run
+ // [ClassCleanup()]
+ // public static void MyClassCleanup() { }
+ //
+ // Use TestInitialize to run code before running each test
+ // [TestInitialize()]
+ // public void MyTestInitialize() { }
+ //
+ //Use TestCleanup to run code after each test has run
+ [TestCleanup]
+ public void MyTestCleanup()
+ {
+ if (TestContext.CurrentTestOutcome != UnitTestOutcome.Passed && CurrentGroupInfo != null && !System.Diagnostics.Debugger.IsAttached)
+ {
+ // record failing case
+ CurrentGroupInfo.WriteFailure();
+ }
+ }
- [Timeout(3600000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot1")]
- public void Analyze1FromSourcesV35()
- {
- var options = GrabTestOptions("Analyze1FromSourcesV35");
- options.BuildFramework = @"v3.5";
- options.ContractFramework = @"v3.5";
- if (!options.Skip)
- TestDriver.BuildAndAnalyze(options);
- }
+ #endregion
- [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2")]
- public void Analyze2FromSourcesV35()
- {
- var options = GrabTestOptions("Analyze2FromSourcesV35");
- options.BuildFramework = @"v3.5";
- options.ContractFramework = @"v3.5";
- if (!options.Skip)
- TestDriver.BuildAndAnalyze2(options);
- }
+ #region Regular tests
- [Timeout(3600000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot1")]
- public void Analyze1FromSourcesV40()
- {
- var options = GrabTestOptions("Analyze1FromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- if (!options.Skip)
- TestDriver.BuildAndAnalyze(options);
- }
+ [Timeout(3600000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot1")]
+ public void Analyze1FromSourcesV35()
+ {
+ var options = GrabTestOptions("Analyze1FromSourcesV35");
+ options.BuildFramework = @"v3.5";
+ options.ContractFramework = @"v3.5";
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze(options);
+ }
- [Timeout(3600000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot1")]
- public void Analyze1FromSourcesV40AgainstV35Contracts()
- {
- var options = GrabTestOptions("Analyze1FromSourcesV40AgainstV35Contracts");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @"v3.5";
- if (!options.Skip)
- TestDriver.BuildAndAnalyze(options);
- }
+ [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2")]
+ public void Analyze2FromSourcesV35()
+ {
+ var options = GrabTestOptions("Analyze2FromSourcesV35");
+ options.BuildFramework = @"v3.5";
+ options.ContractFramework = @"v3.5";
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze2(options);
+ }
- #endregion
+ [Timeout(3600000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot1")]
+ public void Analyze1FromSourcesV40()
+ {
+ var options = GrabTestOptions("Analyze1FromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze(options);
+ }
- #region Fast Tests
+ [Timeout(3600000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot1")]
+ public void Analyze1FromSourcesV40AgainstV35Contracts()
+ {
+ var options = GrabTestOptions("Analyze1FromSourcesV40AgainstV35Contracts");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @"v3.5";
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze(options);
+ }
- [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Parallel")]
- public void Analyze2FastBeginParallelFromSourcesV40()
- {
- var options = GrabTestOptions("Analyze2FastBeginParallelFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.GenerateUniqueOutputName = true;
- options.Fast = true;
- if (!options.Skip)
- TestDriver.AsyncFast2.BeginTest(options);
- }
+ #endregion
- [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Parallel")]
- public void Analyze2FastEndParallelFromSourcesV40()
- {
- var options = GrabTestOptions("Analyze2FastEndParallelFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.GenerateUniqueOutputName = true;
- options.Fast = true;
- if (!options.Skip)
- TestDriver.AsyncFast2.EndTest(options);
- }
+ #region Fast Tests
- #endregion
+ [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Parallel")]
+ public void Analyze2FastBeginParallelFromSourcesV40()
+ {
+ var options = GrabTestOptions("Analyze2FastBeginParallelFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.GenerateUniqueOutputName = true;
+ options.Fast = true;
+ if (!options.Skip)
+ TestDriver.AsyncFast2.BeginTest(options);
+ }
- #region Service tests
+ [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Parallel")]
+ public void Analyze2FastEndParallelFromSourcesV40()
+ {
+ var options = GrabTestOptions("Analyze2FastEndParallelFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.GenerateUniqueOutputName = true;
+ options.Fast = true;
+ if (!options.Skip)
+ TestDriver.AsyncFast2.EndTest(options);
+ }
- [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Service")]
- public void Analyze2ServiceSequentialFromSourcesV40()
- {
- var options = GrabTestOptions("Analyze2ServiceSequentialFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- if (!options.Skip)
- TestDriver.BuildAndAnalyze2S(options);
- }
+ #endregion
- [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Service"), TestCategory("Parallel")]
- public void Analyze2ServiceBeginParallelFromSourcesV40()
- {
- var options = GrabTestOptions("Analyze2ServiceBeginParallelFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.GenerateUniqueOutputName = true;
- if (!options.Skip)
- TestDriver.Async2S.BeginTest(options);
- }
+ #region Service tests
- [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Service"), TestCategory("Parallel")]
- public void Analyze2ServiceEndParallelFromSourcesV40()
- {
- var options = GrabTestOptions("Analyze2ServiceEndParallelFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.GenerateUniqueOutputName = true;
- if (!options.Skip)
- TestDriver.Async2S.EndTest(options);
- }
+ [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Service")]
+ public void Analyze2ServiceSequentialFromSourcesV40()
+ {
+ var options = GrabTestOptions("Analyze2ServiceSequentialFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze2S(options);
+ }
- #endregion
+ [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Service"), TestCategory("Parallel")]
+ public void Analyze2ServiceBeginParallelFromSourcesV40()
+ {
+ var options = GrabTestOptions("Analyze2ServiceBeginParallelFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.GenerateUniqueOutputName = true;
+ if (!options.Skip)
+ TestDriver.Async2S.BeginTest(options);
+ }
- #region Slicing tests
+ [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Service"), TestCategory("Parallel")]
+ public void Analyze2ServiceEndParallelFromSourcesV40()
+ {
+ var options = GrabTestOptions("Analyze2ServiceEndParallelFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.GenerateUniqueOutputName = true;
+ if (!options.Skip)
+ TestDriver.Async2S.EndTest(options);
+ }
- [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
- public void Slice2SequentialFromSourcesV40()
- {
- var options = GrabTestOptions("Slice2SequentialFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.ClousotOptions += " -workers:0";
- if (!options.Skip)
- TestDriver.BuildAndAnalyze2Slicing(options);
- }
+ #endregion
- [Timeout(2700000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
- public void Slice2FastSequentialFromSourcesV40()
- {
- var options = GrabTestOptions("Slice2FastSequentialFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.ClousotOptions += " -workers:0";
- options.Fast = true;
- if (!options.Skip)
- TestDriver.BuildAndAnalyze2Slicing(options);
- }
+ #region Slicing tests
- [Timeout(4500000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot1"), TestCategory("Slicer")]
- public void Slice2Analyze1SequentialFromSourcesV40()
- {
- var options = GrabTestOptions("Slice2Analyze1SequentialFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.ClousotOptions += " -sliceFirst -workers:1";
- if (!options.Skip)
- TestDriver.BuildAndAnalyze1Slicing(options);
- }
+ [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
+ public void Slice2SequentialFromSourcesV40()
+ {
+ var options = GrabTestOptions("Slice2SequentialFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.ClousotOptions += " -workers:0";
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze2Slicing(options);
+ }
- [Timeout(2700000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
- public void Slice2Analyze2SequentialFromSourcesV40()
- {
- var options = GrabTestOptions("Slice2Analyze2SequentialFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.ClousotOptions += " -sliceFirst -workers:1";
- if (!options.Skip)
- TestDriver.BuildAndAnalyze2Slicing(options);
- }
+ [Timeout(2700000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
+ public void Slice2FastSequentialFromSourcesV40()
+ {
+ var options = GrabTestOptions("Slice2FastSequentialFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.ClousotOptions += " -workers:0";
+ options.Fast = true;
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze2Slicing(options);
+ }
- [Timeout(4500000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
- public void Slice2Analyze2SequentialFromSourcesV40WithDiskCache()
- {
- var options = GrabTestOptions("Slice2Analyze2SequentialFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.ClousotOptions += " -sliceFirst -workers:1 -clearcache -cache";
- if (!options.Skip)
- TestDriver.BuildAndAnalyze2Slicing(options);
- }
+ [Timeout(4500000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot1"), TestCategory("Slicer")]
+ public void Slice2Analyze1SequentialFromSourcesV40()
+ {
+ var options = GrabTestOptions("Slice2Analyze1SequentialFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.ClousotOptions += " -sliceFirst -workers:1";
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze1Slicing(options);
+ }
+ [Timeout(2700000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
+ public void Slice2Analyze2SequentialFromSourcesV40()
+ {
+ var options = GrabTestOptions("Slice2Analyze2SequentialFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.ClousotOptions += " -sliceFirst -workers:1";
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze2Slicing(options);
+ }
- [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
- public void Slice2Analyze2FastSequentialFromSourcesV40()
- {
- var options = GrabTestOptions("Slice2Analyze2FastSequentialFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.ClousotOptions += " -sliceFirst -workers:1";
- options.Fast = true;
- if (!options.Skip)
- TestDriver.BuildAndAnalyze2Slicing(options);
- }
+ [Timeout(4500000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
+ public void Slice2Analyze2SequentialFromSourcesV40WithDiskCache()
+ {
+ var options = GrabTestOptions("Slice2Analyze2SequentialFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.ClousotOptions += " -sliceFirst -workers:1 -clearcache -cache";
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze2Slicing(options);
+ }
- [Timeout(3600000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
- public void Slice2Analyze2FastSequentialFromSourcesV40WithDiskCache()
- {
- var options = GrabTestOptions("Slice2Analyze2FastSequentialFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.ClousotOptions += " -sliceFirst -workers:1 -clearcache -cache";
- options.Fast = true;
- if (!options.Skip)
- TestDriver.BuildAndAnalyze2Slicing(options);
- }
+ [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
+ public void Slice2Analyze2FastSequentialFromSourcesV40()
+ {
+ var options = GrabTestOptions("Slice2Analyze2FastSequentialFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.ClousotOptions += " -sliceFirst -workers:1";
+ options.Fast = true;
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze2Slicing(options);
+ }
- [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot1"), TestCategory("Slicer"), TestCategory("Parallel")]
- public void Slice2Analyze1ParallelFromSourcesV40()
- {
- var options = GrabTestOptions("Slice2Analyze1ParallelFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.ClousotOptions += " -sliceFirst";
- if (!options.Skip)
- TestDriver.BuildAndAnalyze1Slicing(options);
- }
+ [Timeout(3600000), DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer")]
+ public void Slice2Analyze2FastSequentialFromSourcesV40WithDiskCache()
+ {
+ var options = GrabTestOptions("Slice2Analyze2FastSequentialFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.ClousotOptions += " -sliceFirst -workers:1 -clearcache -cache";
+ options.Fast = true;
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze2Slicing(options);
+ }
- [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer"), TestCategory("Parallel")]
- public void Slice2Analyze2ParallelFromSourcesV40()
- {
- var options = GrabTestOptions("Slice2Analyze2ParallelFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.ClousotOptions += " -sliceFirst";
- if (!options.Skip)
- TestDriver.BuildAndAnalyze2Slicing(options);
- }
- [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
- [TestMethod]
- [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer"), TestCategory("Parallel")]
- public void Slice2Analyze2FastParallelFromSourcesV40()
- {
- var options = GrabTestOptions("Slice2Analyze2FastParallelFromSourcesV40");
- options.BuildFramework = @".NETFramework\v4.0";
- options.ContractFramework = @".NETFramework\v4.0";
- options.ClousotOptions += " -sliceFirst";
- options.Fast = true;
- if (!options.Skip)
- TestDriver.BuildAndAnalyze2Slicing(options);
- }
+ [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot1"), TestCategory("Slicer"), TestCategory("Parallel")]
+ public void Slice2Analyze1ParallelFromSourcesV40()
+ {
+ var options = GrabTestOptions("Slice2Analyze1ParallelFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.ClousotOptions += " -sliceFirst";
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze1Slicing(options);
+ }
- #endregion
+ [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer"), TestCategory("Parallel")]
+ public void Slice2Analyze2ParallelFromSourcesV40()
+ {
+ var options = GrabTestOptions("Slice2Analyze2ParallelFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.ClousotOptions += " -sliceFirst";
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze2Slicing(options);
+ }
- [AssemblyCleanup] // Automatically called at the end of ClousotTests
- public static void AssemblyCleanup()
- {
- TestDriver.Cleanup();
- }
+ [DeploymentItem(@"Microsoft.Research\RegressionTest\ClousotTests\ClousotTestInputs.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\ClousotTestInputs.xml", "TestRun", DataAccessMethod.Sequential)]
+ [TestMethod]
+ [TestCategory("StaticChecker"), TestCategory("Clousot2"), TestCategory("Slicer"), TestCategory("Parallel")]
+ public void Slice2Analyze2FastParallelFromSourcesV40()
+ {
+ var options = GrabTestOptions("Slice2Analyze2FastParallelFromSourcesV40");
+ options.BuildFramework = @".NETFramework\v4.0";
+ options.ContractFramework = @".NETFramework\v4.0";
+ options.ClousotOptions += " -sliceFirst";
+ options.Fast = true;
+ if (!options.Skip)
+ TestDriver.BuildAndAnalyze2Slicing(options);
+ }
- private Options GrabTestOptions(string testGroupName)
- {
- var options = new Options(testGroupName, TestContext);
- CurrentGroupInfo = options.Group;
- return options;
- }
+ #endregion
- static GroupInfo currentGroupInfo;
+ [AssemblyCleanup] // Automatically called at the end of ClousotTests
+ public static void AssemblyCleanup()
+ {
+ TestDriver.Cleanup();
+ }
- static GroupInfo CurrentGroupInfo
- {
- get
- {
- return currentGroupInfo;
- }
- set
- {
- // see if the group has changed and if so, delete the failure file
- if (!System.Diagnostics.Debugger.IsAttached)
+ private Options GrabTestOptions(string testGroupName)
{
- if (currentGroupInfo == null || currentGroupInfo.TestGroupName != value.TestGroupName)
- {
- // new group, delete the old file
- value.DeleteFailureFile();
- }
+ var options = new Options(testGroupName, TestContext);
+ CurrentGroupInfo = options.Group;
+ return options;
}
- currentGroupInfo = value;
- }
- }
- }
+ private static GroupInfo currentGroupInfo;
-}
+ private static GroupInfo CurrentGroupInfo
+ {
+ get
+ {
+ return currentGroupInfo;
+ }
+ set
+ {
+ // see if the group has changed and if so, delete the failure file
+ if (!System.Diagnostics.Debugger.IsAttached)
+ {
+ if (currentGroupInfo == null || currentGroupInfo.TestGroupName != value.TestGroupName)
+ {
+ // new group, delete the old file
+ value.DeleteFailureFile();
+ }
+ }
+ currentGroupInfo = value;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/Containers/TestContainers/ArrayWithNonNullAnalysis.cs b/Microsoft.Research/RegressionTest/Containers/TestContainers/ArrayWithNonNullAnalysis.cs
index 4ee23526..10d1524a 100644
--- a/Microsoft.Research/RegressionTest/Containers/TestContainers/ArrayWithNonNullAnalysis.cs
+++ b/Microsoft.Research/RegressionTest/Containers/TestContainers/ArrayWithNonNullAnalysis.cs
@@ -19,575 +19,578 @@
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
namespace ArraysNonNull
{
- public class ArraysBasic
- {
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 26, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 19, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 32, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 39, MethodILOffset = 0)]
- public void Test0()
+ public class ArraysBasic
{
- object[] refs = new object[100];
- for (int i = 0; i < refs.Length; i++)
- {
- refs[i] = new object();
- }
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 26, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 19, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 32, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 39, MethodILOffset = 0)]
+ public void Test0()
+ {
+ object[] refs = new object[100];
+ for (int i = 0; i < refs.Length; i++)
+ {
+ refs[i] = new object();
+ }
- Contract.Assert(refs[2] != null);
- }
+ Contract.Assert(refs[2] != null);
+ }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 28, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 56, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 49, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 62, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 69, MethodILOffset = 0)]
- public void Test1(int k)
- {
- string[] strArray;
- int num = 0;
- if (k < 0xff)
- {
- strArray = new string[4];
- strArray[num++] = "";
- }
- else
- {
- strArray = new string[3];
- }
-
- // Here we need the disjunction represented by the arrays
-
- for (int i = num; i < strArray.Length; i++)
- {
- strArray[i] = "";
- }
-
- Contract.Assert(strArray[0] != null);
- }
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 28, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 56, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 49, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 62, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 69, MethodILOffset = 0)]
+ public void Test1(int k)
+ {
+ string[] strArray;
+ int num = 0;
+ if (k < 0xff)
+ {
+ strArray = new string[4];
+ strArray[num++] = "";
+ }
+ else
+ {
+ strArray = new string[3];
+ }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 23, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 6, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as receiver)", PrimaryILOffset = 7, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 62, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 43, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 73, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 7, MethodILOffset = 47)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 19, MethodILOffset = 47)]
- public static void Main(string[] args)
- {
- for (int i = 0; i < args.Length; i++)
- {
- Console.WriteLine(args[i].Length);
- }
-
- var str = "";
- foreach (var arg in args)
- { // To prove the preconditions we need a loop invariant which depends on the quantified invariant
- str = Concat(str, arg);
- }
-
- Contract.Assert(str != null);
- }
+ // Here we need the disjunction represented by the arrays
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 35, MethodILOffset = 61)]
- private static string Concat(string s1, string s2)
- {
- Contract.Requires(s1 != null);
- Contract.Requires(s2 != null);
+ for (int i = num; i < strArray.Length; i++)
+ {
+ strArray[i] = "";
+ }
- Contract.Ensures(Contract.Result() != null);
+ Contract.Assert(strArray[0] != null);
+ }
- var tmp = s1 + s2;
- Contract.Assume(tmp != null);
- return tmp;
- }
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=38,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=18,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=27,MethodILOffset=0)]
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 23, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 6, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as receiver)", PrimaryILOffset = 7, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 62, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 43, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 73, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 7, MethodILOffset = 47)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 19, MethodILOffset = 47)]
+ public static void Main(string[] args)
+ {
+ for (int i = 0; i < args.Length; i++)
+ {
+ Console.WriteLine(args[i].Length);
+ }
+
+ var str = "";
+ foreach (var arg in args)
+ {
+ // To prove the preconditions we need a loop invariant which depends on the quantified invariant
+ str = Concat(str, arg);
+ }
+
+ Contract.Assert(str != null);
+ }
+
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 35, MethodILOffset = 61)]
+ private static string Concat(string s1, string s2)
+ {
+ Contract.Requires(s1 != null);
+ Contract.Requires(s2 != null);
+
+ Contract.Ensures(Contract.Result() != null);
+
+ var tmp = s1 + s2;
+ Contract.Assume(tmp != null);
+ return tmp;
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 38, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 18, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 27, MethodILOffset = 0)]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=17,MethodILOffset=72)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=39,MethodILOffset=72)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=3,MethodILOffset=72)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=25,MethodILOffset=72)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=72)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=44,MethodILOffset=72)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 72)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 44, MethodILOffset = 72)]
#endif
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=77,MethodILOffset=0)]
- public string CheckAllTheElements(string[] s)
- {
- Contract.Requires(s != null);
-
- for(var i = 0; i < s.Length; i++)
- {
- var x = s[i];
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 77, MethodILOffset = 0)]
+ public string CheckAllTheElements(string[] s)
+ {
+ Contract.Requires(s != null);
- Contract.Assert(x != null);
+ for (var i = 0; i < s.Length; i++)
+ {
+ var x = s[i];
- }
+ Contract.Assert(x != null);
+ }
- Contract.Assert(Contract.ForAll(s, el => el != null));
+ Contract.Assert(Contract.ForAll(s, el => el != null));
- return null;
+ return null;
+ }
}
- }
- public class AssumeForAll
- {
- [ClousotRegressionTest("NonNull")]
+ public class AssumeForAll
+ {
+ [ClousotRegressionTest("NonNull")]
#if !CLOUSOT2
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 60, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 14, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 44, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 60, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 14, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 44, MethodILOffset = 0)]
#endif
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 49, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 65, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 90, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 96, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 103, MethodILOffset = 0)]
- public static void Test0_OK(string[] s, int i)
- {
- Contract.Requires(s != null);
- Contract.Requires(i >= 0);
- Contract.Requires(i < s.Length);
- Contract.Requires(Contract.ForAll(0, s.Length, j => s[j] != null));
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 49, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 65, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 90, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 96, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 103, MethodILOffset = 0)]
+ public static void Test0_OK(string[] s, int i)
+ {
+ Contract.Requires(s != null);
+ Contract.Requires(i >= 0);
+ Contract.Requires(i < s.Length);
+ Contract.Requires(Contract.ForAll(0, s.Length, j => s[j] != null));
- Contract.Assert(s[i] != null); // True
- }
+ Contract.Assert(s[i] != null); // True
+ }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
#if !CLOUSOT2
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 14, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 14, MethodILOffset = 0)]
#endif
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 57, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 64, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 77, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 83, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 96, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 103, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 71, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 90, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 107, MethodILOffset = 0)]
- public void Test1_Ok(object[] os)
- {
- Contract.Requires(os != null);
- Contract.Requires(Contract.ForAll(10, 20, j => os[j] != null));
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 57, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 64, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 77, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 83, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 96, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 103, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 71, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 90, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 107, MethodILOffset = 0)]
+ public void Test1_Ok(object[] os)
+ {
+ Contract.Requires(os != null);
+ Contract.Requires(Contract.ForAll(10, 20, j => os[j] != null));
- Contract.Assert(os[15] != null); // True
- Contract.Assert(os[0] != null); // Top
- Contract.Assert(os[19] == null); // False
- }
+ Contract.Assert(os[15] != null); // True
+ Contract.Assert(os[0] != null); // Top
+ Contract.Assert(os[19] == null); // False
+ }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 26, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 69, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 93, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 76, MethodILOffset = 0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=49,MethodILOffset=94)]
- public object Test2_NotOk(object[] data, int count)
- {
- Contract.Requires(data != null);
- Contract.Requires(count >= 0);
- Contract.Requires(count <= data.Length);
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 26, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 69, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 93, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 76, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 49, MethodILOffset = 94)]
+ public object Test2_NotOk(object[] data, int count)
+ {
+ Contract.Requires(data != null);
+ Contract.Requires(count >= 0);
+ Contract.Requires(count <= data.Length);
- Contract.Ensures(Contract.Result() != null);
+ Contract.Ensures(Contract.Result() != null);
- if (count == 0) throw new InvalidOperationException();
+ if (count == 0)
+ throw new InvalidOperationException();
- for (int i = 0; i < count; i++)
- {
- Contract.Assert(data[i] != null);
- }
+ for (int i = 0; i < count; i++)
+ {
+ Contract.Assert(data[i] != null);
+ }
- return data[count - 1];
- }
+ return data[count - 1];
+ }
- [ClousotRegressionTest("NonNull")]
+ [ClousotRegressionTest("NonNull")]
#if !CLOUSOT2
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 14, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 44, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 151)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 14, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 44, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 151)]
#endif
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 49, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 115, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 121, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 142, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 150, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 128, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 96, MethodILOffset = 151)]
- public object Test2_Ok(object[] data, int count)
- {
- Contract.Requires(data != null);
- Contract.Requires(count >= 0);
- Contract.Requires(count <= data.Length);
- Contract.Requires(Contract.ForAll(0, count, i => data[i] != null));
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 49, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 115, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 121, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 142, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 150, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 128, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 96, MethodILOffset = 151)]
+ public object Test2_Ok(object[] data, int count)
+ {
+ Contract.Requires(data != null);
+ Contract.Requires(count >= 0);
+ Contract.Requires(count <= data.Length);
+ Contract.Requires(Contract.ForAll(0, count, i => data[i] != null));
- Contract.Ensures(Contract.Result() != null);
+ Contract.Ensures(Contract.Result() != null);
- if (count == 0) throw new InvalidOperationException();
+ if (count == 0)
+ throw new InvalidOperationException();
- for (int i = 0; i < count; i++)
- {
- Contract.Assert(data[i] != null);
- }
+ for (int i = 0; i < count; i++)
+ {
+ Contract.Assert(data[i] != null);
+ }
- return data[count - 1];
+ return data[count - 1];
+ }
}
- }
-
- public class AssertForAll
- {
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 36, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"Possible use of a null array 'strings'", PrimaryILOffset = 41, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 18, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 29, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 47, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 52, MethodILOffset = 0)]
+
+ public class AssertForAll
+ {
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 36, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"Possible use of a null array 'strings'", PrimaryILOffset = 41, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 18, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 29, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 47, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 52, MethodILOffset = 0)]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=13,MethodILOffset=66)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=35,MethodILOffset=66)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=3,MethodILOffset=66)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=25,MethodILOffset=66)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=66)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=44,MethodILOffset=66)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 66)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 44, MethodILOffset = 66)]
#endif
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 71, MethodILOffset = 0)]
- public void NotNull0(string[] strings)
- {
- for (int i = 0; i < strings.Length; i++)
- {
- strings[i] = "ciao";
- }
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 71, MethodILOffset = 0)]
+ public void NotNull0(string[] strings)
+ {
+ for (int i = 0; i < strings.Length; i++)
+ {
+ strings[i] = "ciao";
+ }
- Contract.Assert(Contract.ForAll(0, strings.Length, i => strings[i] != null));
- }
+ Contract.Assert(Contract.ForAll(0, strings.Length, i => strings[i] != null));
+ }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"Possible use of a null array 'strings'", PrimaryILOffset = 54, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 27, MethodILOffset = 0)]
- //[RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"Possible use of a null array 'strings'", PrimaryILOffset = 38, MethodILOffset = 0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"Possible use of a null array 'strings' (Fixing this warning may solve one additional issue in the code)",PrimaryILOffset=38,MethodILOffset=0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 49, MethodILOffset = 0)]
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"Possible use of a null array 'strings'", PrimaryILOffset = 54, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 27, MethodILOffset = 0)]
+ //[RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"Possible use of a null array 'strings'", PrimaryILOffset = 38, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"Possible use of a null array 'strings' (Fixing this warning may solve one additional issue in the code)", PrimaryILOffset = 38, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 49, MethodILOffset = 0)]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=13,MethodILOffset=68)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=35,MethodILOffset=68)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=3,MethodILOffset=68)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=25,MethodILOffset=68)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=68)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=44,MethodILOffset=68)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 68)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 44, MethodILOffset = 68)]
#endif
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 73, MethodILOffset = 0)]
- public void NotNull1_NotOk(string[] strings, int k)
- {
- Contract.Requires(k > 5);
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 73, MethodILOffset = 0)]
+ public void NotNull1_NotOk(string[] strings, int k)
+ {
+ Contract.Requires(k > 5);
- for (int i = 0; i < k; i++)
- {
- strings[i] = "ciao";
- }
+ for (int i = 0; i < k; i++)
+ {
+ strings[i] = "ciao";
+ }
- Contract.Assert(Contract.ForAll(0, strings.Length, i => strings[i] != null));
- }
+ Contract.Assert(Contract.ForAll(0, strings.Length, i => strings[i] != null));
+ }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 27, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"Possible use of a null array 'strings'. The static checker determined that the condition 'strings != null' should hold on entry. Nevertheless, the condition may be too strong for the callers. If you think it is ok, add a precondition to document it: Contract.Requires(strings != null);", PrimaryILOffset = 38, MethodILOffset = 0)]
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 27, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"Possible use of a null array 'strings'. The static checker determined that the condition 'strings != null' should hold on entry. Nevertheless, the condition may be too strong for the callers. If you think it is ok, add a precondition to document it: Contract.Requires(strings != null);", PrimaryILOffset = 38, MethodILOffset = 0)]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=13,MethodILOffset=61)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=35,MethodILOffset=61)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=3,MethodILOffset=61)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=25,MethodILOffset=61)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=61)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=44,MethodILOffset=61)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 61)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 44, MethodILOffset = 61)]
#endif
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 66, MethodILOffset = 0)]
- public void NotNull1_Ok(string[] strings, int k)
- {
- Contract.Requires(k > 5);
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 66, MethodILOffset = 0)]
+ public void NotNull1_Ok(string[] strings, int k)
+ {
+ Contract.Requires(k > 5);
- for (int i = 0; i < k; i++)
- {
- strings[i] = "ciao";
- }
+ for (int i = 0; i < k; i++)
+ {
+ strings[i] = "ciao";
+ }
- Contract.Assert(Contract.ForAll(0, k, i => strings[i] != null));
- }
+ Contract.Assert(Contract.ForAll(0, k, i => strings[i] != null));
+ }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
#if !CLOUSOT2
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 14, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 14, MethodILOffset = 0)]
#endif
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 49, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 54, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 35, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 42, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 60, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 65, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 49, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 54, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 35, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 42, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 60, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 65, MethodILOffset = 0)]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=13,MethodILOffset=79)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=35,MethodILOffset=79)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=3,MethodILOffset=79)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=25,MethodILOffset=79)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=79)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=44,MethodILOffset=79)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 79)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 44, MethodILOffset = 79)]
#endif
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 84, MethodILOffset = 0)]
- public void AllNull(object[] os)
- {
- Contract.Requires(os != null);
-
- for (int i = 0; i < os.Length; i++)
- {
- os[i] = null;
- }
-
- Contract.Assert(Contract.ForAll(0, os.Length, i => os[i] == null));
- }
- }
-
- public class NonNullStack
- {
- private object[] arr;
- private int counter;
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 84, MethodILOffset = 0)]
+ public void AllNull(object[] os)
+ {
+ Contract.Requires(os != null);
- [ContractInvariantMethod]
- void ObjectInvariant()
- {
- Contract.Invariant(arr != null);
- Contract.Invariant(counter >= 0);
- Contract.Invariant(counter <= arr.Length);
- Contract.Invariant(Contract.ForAll(0, counter, i => arr[i] != null));
- }
+ for (int i = 0; i < os.Length; i++)
+ {
+ os[i] = null;
+ }
- [ClousotRegressionTest("NonNull")]
- public bool IsEmpty
- {
- get
- {
- return this.counter == 0;
- }
+ Contract.Assert(Contract.ForAll(0, os.Length, i => os[i] == null));
+ }
}
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as receiver)", PrimaryILOffset = 1, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 25, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 32, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 12, MethodILOffset = 37)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 29, MethodILOffset = 37)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 53, MethodILOffset = 37)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 82, MethodILOffset = 37)]
- public NonNullStack(int len)
+ public class NonNullStack
{
- Contract.Requires(len >= 0);
+ private object[] arr;
+ private int counter;
- this.arr = new object[len];
- this.counter = 0;
- }
+ [ContractInvariantMethod]
+ private void ObjectInvariant()
+ {
+ Contract.Invariant(arr != null);
+ Contract.Invariant(counter >= 0);
+ Contract.Invariant(counter <= arr.Length);
+ Contract.Invariant(Contract.ForAll(0, counter, i => arr[i] != null));
+ }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 13, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 19, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 24, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 29, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 34, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 67, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 53, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 59, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 60, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 76, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 82, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 88, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 94, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 97, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 104, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "invariant is valid", PrimaryILOffset = 12, MethodILOffset = 109)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "invariant is valid", PrimaryILOffset = 29, MethodILOffset = 109)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "invariant is valid", PrimaryILOffset = 53, MethodILOffset = 109)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "invariant is valid", PrimaryILOffset = 82, MethodILOffset = 109)]
- public void Push(object x)
- {
- Contract.Requires(x != null);
+ [ClousotRegressionTest("NonNull")]
+ public bool IsEmpty
+ {
+ get
+ {
+ return counter == 0;
+ }
+ }
- if (counter == arr.Length)
- {
- var newArr = new object[arr.Length * 2 + 1];
- for (int i = 0; i < counter; i++)
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as receiver)", PrimaryILOffset = 1, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 25, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 32, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 12, MethodILOffset = 37)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 29, MethodILOffset = 37)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 53, MethodILOffset = 37)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 82, MethodILOffset = 37)]
+ public NonNullStack(int len)
{
- newArr[i] = arr[i];
+ Contract.Requires(len >= 0);
+
+ arr = new object[len];
+ counter = 0;
}
- arr = newArr;
- }
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 13, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 19, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 24, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 29, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 34, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 67, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 53, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 59, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 60, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 76, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 82, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 88, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 94, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 97, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as field receiver)", PrimaryILOffset = 104, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "invariant is valid", PrimaryILOffset = 12, MethodILOffset = 109)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "invariant is valid", PrimaryILOffset = 29, MethodILOffset = 109)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "invariant is valid", PrimaryILOffset = 53, MethodILOffset = 109)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "invariant is valid", PrimaryILOffset = 82, MethodILOffset = 109)]
+ public void Push(object x)
+ {
+ Contract.Requires(x != null);
- this.arr[counter] = x;
- counter++;
- }
+ if (counter == arr.Length)
+ {
+ var newArr = new object[arr.Length*2 + 1];
+ for (int i = 0; i < counter; i++)
+ {
+ newArr[i] = arr[i];
+ }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=13,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=18,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=21,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=29,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=34,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=67,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=72,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=53,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=59,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=60,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=78,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=84,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=91,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=100,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=107,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"invariant is valid",PrimaryILOffset=12,MethodILOffset=108)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"invariant is valid",PrimaryILOffset=29,MethodILOffset=108)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"invariant is valid",PrimaryILOffset=53,MethodILOffset=108)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"invariant is valid",PrimaryILOffset=82,MethodILOffset=108)]
- public void PushWithDifferentTestCondition(object obj)
- {
- Contract.Requires(obj != null);
+ arr = newArr;
+ }
- if (arr.Length == counter)
- {
- var newElements = new object[arr.Length * 2 + 1];
- for (var i = 0; i < arr.Length; i++) // F: There was a precision bug here, which was losing some equalities
- {
- newElements[i] = arr[i];
+ arr[counter] = x;
+ counter++;
}
- arr = newElements;
- }
- arr[counter++] = obj;
- }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 1, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 7, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 12, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 17, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 22, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 55, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 41, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 47, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 48, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 64, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 70, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 77, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 86, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 93, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 12, MethodILOffset = 94)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 29, MethodILOffset = 94)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 53, MethodILOffset = 94)]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"invariant unproven: Contract.ForAll(0, counter, i => arr[i] != null)", PrimaryILOffset = 82, MethodILOffset = 94)]
- public void PushWrong(object x)
- {
- if (counter == arr.Length)
- {
- var newArr = new object[arr.Length * 2 + 1];
- for (int i = 0; i < counter; i++)
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 13, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 18, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 21, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 29, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 34, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 67, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 72, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 53, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 59, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 60, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 78, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 84, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 91, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 100, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 107, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 12, MethodILOffset = 108)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 29, MethodILOffset = 108)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 53, MethodILOffset = 108)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 82, MethodILOffset = 108)]
+ public void PushWithDifferentTestCondition(object obj)
{
- newArr[i] = arr[i];
+ Contract.Requires(obj != null);
+
+ if (arr.Length == counter)
+ {
+ var newElements = new object[arr.Length*2 + 1];
+ for (var i = 0; i < arr.Length; i++) // F: There was a precision bug here, which was losing some equalities
+ {
+ newElements[i] = arr[i];
+ }
+ arr = newElements;
+ }
+
+ arr[counter++] = obj;
}
- arr = newArr;
- }
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 1, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 7, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 12, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 17, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 22, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 55, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 41, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 47, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 48, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 64, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 70, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 77, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 86, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 93, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 12, MethodILOffset = 94)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 29, MethodILOffset = 94)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 53, MethodILOffset = 94)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"invariant unproven: Contract.ForAll(0, counter, i => arr[i] != null)", PrimaryILOffset = 82, MethodILOffset = 94)]
+ public void PushWrong(object x)
+ {
+ if (counter == arr.Length)
+ {
+ var newArr = new object[arr.Length*2 + 1];
+ for (int i = 0; i < counter; i++)
+ {
+ newArr[i] = arr[i];
+ }
- this.arr[counter++] = x;
- }
+ arr = newArr;
+ }
+ arr[counter++] = x;
+ }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as receiver)", PrimaryILOffset = 1, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 32, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 39, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 45, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 51, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 56, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 12, MethodILOffset = 59)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 29, MethodILOffset = 59)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 53, MethodILOffset = 59)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 82, MethodILOffset = 59)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 25, MethodILOffset = 59)]
- public object Pop()
- {
- Contract.Requires(!this.IsEmpty);
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as receiver)", PrimaryILOffset = 1, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 32, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 39, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 45, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 51, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 56, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 12, MethodILOffset = 59)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 29, MethodILOffset = 59)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 53, MethodILOffset = 59)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 82, MethodILOffset = 59)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 25, MethodILOffset = 59)]
+ public object Pop()
+ {
+ Contract.Requires(!IsEmpty);
- Contract.Ensures(Contract.Result() != null);
+ Contract.Ensures(Contract.Result() != null);
- counter--;
- var res = this.arr[counter];
+ counter--;
+ var res = arr[counter];
- return res;
- }
+ return res;
+ }
- [ClousotRegressionTest("NonNull")]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as receiver)",PrimaryILOffset=1,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=32,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=60,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=66,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=71,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=96,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=102,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=109,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=112,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=118,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=126,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=129,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=136,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=143,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=171,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=177,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=182,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=165,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=201,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"invariant is valid",PrimaryILOffset=12,MethodILOffset=207)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"invariant is valid",PrimaryILOffset=29,MethodILOffset=207)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"invariant is valid",PrimaryILOffset=53,MethodILOffset=207)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"invariant is valid",PrimaryILOffset=82,MethodILOffset=207)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=25,MethodILOffset=207)]
+ [ClousotRegressionTest("NonNull")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as receiver)", PrimaryILOffset = 1, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 32, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 60, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 66, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 71, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 96, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 102, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 109, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 112, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 118, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 126, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 129, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 136, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 143, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 171, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 177, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 182, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 165, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 201, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 12, MethodILOffset = 207)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 29, MethodILOffset = 207)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 53, MethodILOffset = 207)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"invariant is valid", PrimaryILOffset = 82, MethodILOffset = 207)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 25, MethodILOffset = 207)]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=13,MethodILOffset=49)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=35,MethodILOffset=49)]
@@ -598,7 +601,7 @@ public object Pop()
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=13,MethodILOffset=196)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=35,MethodILOffset=196)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=3,MethodILOffset=49)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=25,MethodILOffset=49)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=3,MethodILOffset=85)]
@@ -608,59 +611,61 @@ public object Pop()
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=3,MethodILOffset=196)] // we can prove it with clousot2, even without wp
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=25,MethodILOffset=196)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=49)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=44,MethodILOffset=49)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=85)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=44,MethodILOffset=85)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=160)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=44,MethodILOffset=160)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=22,MethodILOffset=196)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=44,MethodILOffset=196)]
- #endif
- #endif
- public object PopGCFriendly()
- {
- Contract.Requires(!this.IsEmpty);
- Contract.Ensures(Contract.Result() != null);
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 49)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 44, MethodILOffset = 49)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 85)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 44, MethodILOffset = 85)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 160)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 44, MethodILOffset = 160)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 22, MethodILOffset = 196)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 44, MethodILOffset = 196)]
+#endif
+#endif
+ public object PopGCFriendly()
+ {
+ Contract.Requires(!IsEmpty);
+ Contract.Ensures(Contract.Result() != null);
- Contract.Assume(Contract.ForAll(0, this.counter, i => arr[i] != null));
- Contract.Assume(Contract.ForAll(this.counter, this.arr.Length, i => this.arr[i] == null));
+ Contract.Assume(Contract.ForAll(0, counter, i => arr[i] != null));
+ Contract.Assume(Contract.ForAll(counter, arr.Length, i => arr[i] == null));
- var r = arr[counter - 1];
- arr[counter - 1] = null;
- counter = counter - 1;
+ var r = arr[counter - 1];
+ arr[counter - 1] = null;
+ counter = counter - 1;
- Contract.Assert(Contract.ForAll(0, this.counter, i => arr[i] != null));
- Contract.Assert(Contract.ForAll(this.counter, this.arr.Length, i => this.arr[i] == null));
+ Contract.Assert(Contract.ForAll(0, counter, i => arr[i] != null));
+ Contract.Assert(Contract.ForAll(counter, arr.Length, i => arr[i] == null));
- return r;
+ return r;
+ }
}
- }
}
namespace DaveSexton
{
- class ArrayCrash
- {
- string biz = "", bar = "", baz = "";
- bool can = true;
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=10,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=15,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=23,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=27,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=32,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=40,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=44,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=59,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=74,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=13,MethodILOffset=76)]
- void Test()
+ internal class ArrayCrash
{
- var value = biz + "." + bar + "." + ((can) ? baz + ", " : "");
+ private readonly string biz = "";
+ private readonly string bar = "";
+ private readonly string baz = "";
+ private readonly bool can = true;
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 10, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 15, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 23, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 27, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 32, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 40, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 44, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 59, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 74, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 13, MethodILOffset = 76)]
+ private void Test()
+ {
+ var value = biz + "." + bar + "." + ((can) ? baz + ", " : "");
+ }
}
- }
}
namespace ExamplesWithUIntIndexes
@@ -668,34 +673,35 @@ namespace ExamplesWithUIntIndexes
public class Z3repros
{
[ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as array)",PrimaryILOffset=6,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as array)",PrimaryILOffset=53,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as array)",PrimaryILOffset=21,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as array)",PrimaryILOffset=27,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as array)",PrimaryILOffset=35,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=36,MethodILOffset=0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 6, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 53, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 21, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 27, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 35, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 36, MethodILOffset = 0)]
internal static IntPtr[] ArrayToNative(Z3Object[] a)
{
- if (a == null) return null;
+ if (a == null)
+ return null;
IntPtr[] an = new IntPtr[a.Length];
for (uint i = 0; i < a.Length; i++)
// We were not understanding the cast in a[i]
- if (a[i] != null) an[i] = a[i].NativeObject;
+ if (a[i] != null)
+ an[i] = a[i].NativeObject;
return an;
}
[ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as array)",PrimaryILOffset=13,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as array)",PrimaryILOffset=24,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as array)",PrimaryILOffset=46,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as array)",PrimaryILOffset=59,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as array)",PrimaryILOffset=78,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=66,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=85,MethodILOffset=0)]
- void EnumSort(string[] enumNames)
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 13, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 24, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 46, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 59, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as array)", PrimaryILOffset = 78, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 66, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 85, MethodILOffset = 0)]
+ private void EnumSort(string[] enumNames)
{
-
Contract.Requires(enumNames != null);
Contract.Requires(enumNames.Length > 0);
@@ -717,6 +723,9 @@ void EnumSort(string[] enumNames)
public class Z3Object
{
- extern public IntPtr NativeObject { get; }
+ public extern IntPtr NativeObject
+ {
+ get;
+ }
}
}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/Containers/TestContainers/BasicContainersTest.cs b/Microsoft.Research/RegressionTest/Containers/TestContainers/BasicContainersTest.cs
index 119d0b79..18000ea2 100644
--- a/Microsoft.Research/RegressionTest/Containers/TestContainers/BasicContainersTest.cs
+++ b/Microsoft.Research/RegressionTest/Containers/TestContainers/BasicContainersTest.cs
@@ -19,1545 +19,1540 @@
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
namespace Arrays
{
- public class ArraysBasic
- {
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 26, MethodILOffset = 0)]
- public void SetFirstElementTo_12(int[] arr, int i)
+ public class ArraysBasic
{
- Contract.Requires(arr.Length > 0);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 26, MethodILOffset = 0)]
+ public void SetFirstElementTo_12(int[] arr, int i)
+ {
+ Contract.Requires(arr.Length > 0);
- arr[0] = 12;
+ arr[0] = 12;
- // {0} 12 {1} [-oo, +oo] {arr.Length}?
- if (i == 0)
- {
- Contract.Assert(arr[i] == 12); // true
- }
- }
+ // {0} 12 {1} [-oo, +oo] {arr.Length}?
+ if (i == 0)
+ {
+ Contract.Assert(arr[i] == 12); // true
+ }
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 26, MethodILOffset = 0)]
- public void SetFirstElementTo_12_Precondition(int[] arr, int i)
- {
- Contract.Requires(arr.Length > 1);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 26, MethodILOffset = 0)]
+ public void SetFirstElementTo_12_Precondition(int[] arr, int i)
+ {
+ Contract.Requires(arr.Length > 1);
- arr[0] = 12;
+ arr[0] = 12;
- // {0} 12 {1} [-oo, +oo] {arr.Length}
+ // {0} 12 {1} [-oo, +oo] {arr.Length}
- if (i == 0)
- {
- Contract.Assert(arr[0] == 12); // true
- }
- }
+ if (i == 0)
+ {
+ Contract.Assert(arr[0] == 12); // true
+ }
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 24, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 40, MethodILOffset = 0)]
- public void SetFifthElementTo_12(int[] arr, int i)
- {
- Contract.Requires(arr.Length > 10);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 24, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 40, MethodILOffset = 0)]
+ public void SetFifthElementTo_12(int[] arr, int i)
+ {
+ Contract.Requires(arr.Length > 10);
- arr[4] = 12;
+ arr[4] = 12;
- // {0} [-oo, +oo] {4} 12 {5} [-oo,+oo] {10}
+ // {0} [-oo, +oo] {4} 12 {5} [-oo,+oo] {10}
- Contract.Assert(arr[0] == 12); // top
+ Contract.Assert(arr[0] == 12); // top
- if (i == 4)
- {
- Contract.Assert(arr[i] == 12); // true
- }
- }
+ if (i == 4)
+ {
+ Contract.Assert(arr[i] == 12); // true
+ }
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 23, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 35, MethodILOffset = 0)]
- public void SetFifthElementTo_12_ArrayLength5(int[] arr)
- {
- Contract.Requires(arr.Length == 5);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 23, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 35, MethodILOffset = 0)]
+ public void SetFifthElementTo_12_ArrayLength5(int[] arr)
+ {
+ Contract.Requires(arr.Length == 5);
- arr[4] = 12;
+ arr[4] = 12;
- // {0} [-oo, +oo] {4} 12 {5, arr.length}
+ // {0} [-oo, +oo] {4} 12 {5, arr.length}
- Contract.Assert(arr[0] == 12); // top
- Contract.Assert(arr[4] == 12); // true
- }
+ Contract.Assert(arr[0] == 12); // top
+ Contract.Assert(arr[4] == 12); // true
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 26, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 41, MethodILOffset = 0)]
- public void Init_NoLoop_FirstElement()
- {
- int[] a = new int[100];
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 26, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 41, MethodILOffset = 0)]
+ public void Init_NoLoop_FirstElement()
+ {
+ int[] a = new int[100];
- a[0] = 222;
+ a[0] = 222;
- Contract.Assert(a[0] == 222); // true
- Contract.Assert(a[4] == 222); // false
- }
+ Contract.Assert(a[0] == 222); // true
+ Contract.Assert(a[4] == 222); // false
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 26, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 41, MethodILOffset = 0)]
- public void Init_NoLoop_SecondElement()
- {
- int[] a = new int[100];
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 26, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 41, MethodILOffset = 0)]
+ public void Init_NoLoop_SecondElement()
+ {
+ int[] a = new int[100];
- a[1] = 222;
+ a[1] = 222;
- Contract.Assert(a[1] == 222); // true
- Contract.Assert(a[4] == 222); // false
- }
+ Contract.Assert(a[1] == 222); // true
+ Contract.Assert(a[4] == 222); // false
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 42, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 57, MethodILOffset = 0)]
- public void Init_NoLoop_ThreeElements()
- {
- int[] a = new int[100];
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 42, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 57, MethodILOffset = 0)]
+ public void Init_NoLoop_ThreeElements()
+ {
+ int[] a = new int[100];
- a[0] = 111111;
- a[2] = 2222222;
- a[4] = 3333333;
+ a[0] = 111111;
+ a[2] = 2222222;
+ a[4] = 3333333;
- Contract.Assert(a[0] == 111111); // true
- Contract.Assert(a[2] == 111111); // false
- }
+ Contract.Assert(a[0] == 111111); // true
+ Contract.Assert(a[2] == 111111); // false
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 58, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 76, MethodILOffset = 0)]
- public void Init_NoLoop_Three_Successive_Elements(int index)
- {
- int[] a = new int[100];
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 58, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 76, MethodILOffset = 0)]
+ public void Init_NoLoop_Three_Successive_Elements(int index)
+ {
+ int[] a = new int[100];
- a[10] = 111111;
- a[11] = 2222222;
- a[12] = 3333333;
+ a[10] = 111111;
+ a[11] = 2222222;
+ a[12] = 3333333;
- if (index >= 10 && index <= 12)
- {
- Contract.Assert(a[index] >= 111111);
- Contract.Assert(a[index] <= 3333333);
- }
- }
+ if (index >= 10 && index <= 12)
+ {
+ Contract.Assert(a[index] >= 111111);
+ Contract.Assert(a[index] <= 3333333);
+ }
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 49, MethodILOffset = 0)]
- public int[] InitReverse(int index)
- {
- int[] a = new int[1000];
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 49, MethodILOffset = 0)]
+ public int[] InitReverse(int index)
+ {
+ int[] a = new int[1000];
- a[99] = 2222222;
- a[98] = 2222222;
+ a[99] = 2222222;
+ a[98] = 2222222;
- if (index >= 98 && index <= 99)
- {
- Contract.Assert(a[index] == 2222222);
- }
+ if (index >= 98 && index <= 99)
+ {
+ Contract.Assert(a[index] == 2222222);
+ }
- return a;
- }
+ return a;
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 56, MethodILOffset = 0)]
- public int[] ProveAssertion(int index, int value)
- {
- Contract.Requires(index >= 0);
- Contract.Requires(index < 10);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 56, MethodILOffset = 0)]
+ public int[] ProveAssertion(int index, int value)
+ {
+ Contract.Requires(index >= 0);
+ Contract.Requires(index < 10);
- Contract.Requires(value < -1111);
+ Contract.Requires(value < -1111);
- int[] a = new int[10];
+ int[] a = new int[10];
- a[index] = value;
+ a[index] = value;
- Contract.Assert(a[0] <= 0); // true
+ Contract.Assert(a[0] <= 0); // true
- return a;
- }
+ return a;
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 53, MethodILOffset = 0)]
- public int[] ProveAssertion_NotOk(int index, int value)
- {
- Contract.Requires(index >= 0);
- Contract.Requires(index < 10);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 53, MethodILOffset = 0)]
+ public int[] ProveAssertion_NotOk(int index, int value)
+ {
+ Contract.Requires(index >= 0);
+ Contract.Requires(index < 10);
- Contract.Requires(value < -1111);
+ Contract.Requires(value < -1111);
- int[] a = new int[10];
+ int[] a = new int[10];
- a[index] = value;
+ a[index] = value;
- Contract.Assert(a[0] == 0); // top, we may have written index
+ Contract.Assert(a[0] == 0); // top, we may have written index
- return a;
- }
+ return a;
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 53, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 67, MethodILOffset = 0)]
- public int[] ProveAssertion_FirstThreeElementsZero(int index, int value)
- {
- Contract.Requires(index >= 4);
- Contract.Requires(index < 10);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 53, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 67, MethodILOffset = 0)]
+ public int[] ProveAssertion_FirstThreeElementsZero(int index, int value)
+ {
+ Contract.Requires(index >= 4);
+ Contract.Requires(index < 10);
- Contract.Requires(value < -1111);
+ Contract.Requires(value < -1111);
- int[] a = new int[10];
+ int[] a = new int[10];
- a[index] = value;
+ a[index] = value;
- Contract.Assert(a[0] == 0);
- Contract.Assert(a[4] <= 0);
+ Contract.Assert(a[0] == 0);
+ Contract.Assert(a[4] <= 0);
- return a;
- }
+ return a;
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 35, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 49, MethodILOffset = 0)]
- public void SetToThree_Length10()
- {
- int[] a = new int[10];
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 35, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 49, MethodILOffset = 0)]
+ public void SetToThree_Length10()
+ {
+ int[] a = new int[10];
- int i;
- for (i = 0; i < a.Length; i++)
- {
- a[i] = 3;
+ int i;
+ for (i = 0; i < a.Length; i++)
+ {
+ a[i] = 3;
+ }
- }
+ Contract.Assert(a[7] >= 0); // True
+ Contract.Assert(a[3] >= 4); // False
+ }
- Contract.Assert(a[7] >= 0); // True
- Contract.Assert(a[3] >= 4); // False
- }
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 32, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 43, MethodILOffset = 0)]
+ public void SetToThree_Length10_TestReduction()
+ {
+ int[] a = new int[10];
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 32, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 43, MethodILOffset = 0)]
- public void SetToThree_Length10_TestReduction()
- {
- int[] a = new int[10];
+ int i;
+ for (i = 0; i < a.Length; i++)
+ {
+ a[i] = 3;
+ }
- int i;
- for (i = 0; i < a.Length; i++)
- {
- a[i] = 3;
- }
+ Contract.Assert(a[7] == 3); // True
+ Contract.Assert(a[3] == 4); // False
+ }
- Contract.Assert(a[7] == 3); // True
- Contract.Assert(a[3] == 4); // False
- }
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 41, MethodILOffset = 0)]
+ public void SetToThree_Length10_TestReduction_For()
+ {
+ int[] a = new int[10];
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 41, MethodILOffset = 0)]
- public void SetToThree_Length10_TestReduction_For()
- {
- int[] a = new int[10];
-
- int i;
- for (i = 0; i < a.Length; i++)
- {
- a[i] = 3;
- }
- ClousotDebug.Francesco_PrintArrayContent();
-
- for (i = 0; i < 5; i++)
- {
- Contract.Assert(a[i] == 3); // true
- }
- }
+ int i;
+ for (i = 0; i < a.Length; i++)
+ {
+ a[i] = 3;
+ }
+ ClousotDebug.Francesco_PrintArrayContent();
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 41, MethodILOffset = 0)]
- public void InitArrayNoKnownUpperBound(int[] a)
- {
- // Here we can have a.Length == 0 so that the post-state after the first loop contains ?
- for (int i = 0; i < a.Length; i++)
- {
- a[i] = -333333;
- }
+ for (i = 0; i < 5; i++)
+ {
+ Contract.Assert(a[i] == 3); // true
+ }
+ }
- ClousotDebug.Francesco_PrintArrayContent();
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 41, MethodILOffset = 0)]
+ public void InitArrayNoKnownUpperBound(int[] a)
+ {
+ // Here we can have a.Length == 0 so that the post-state after the first loop contains ?
+ for (int i = 0; i < a.Length; i++)
+ {
+ a[i] = -333333;
+ }
- //sv9 (15) -> {0 ,sv4 (10)} [-333333, -333333] {sv19 (32) ,sv10 (16)}?
+ ClousotDebug.Francesco_PrintArrayContent();
- for (int i = 0; i < a.Length; i++)
- {
- Contract.Assert(a[i] == -333333);
- }
- }
+ //sv9 (15) -> {0 ,sv4 (10)} [-333333, -333333] {sv19 (32) ,sv10 (16)}?
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 52, MethodILOffset = 0)]
- public void InitArrayNoKnownUpperBound_AtMostOneElement(int[] a)
- {
- Contract.Requires(a.Length > 0);
+ for (int i = 0; i < a.Length; i++)
+ {
+ Contract.Assert(a[i] == -333333);
+ }
+ }
- for (int i = 0; i < a.Length; i++)
- {
- a[i] = -333333;
- }
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 52, MethodILOffset = 0)]
+ public void InitArrayNoKnownUpperBound_AtMostOneElement(int[] a)
+ {
+ Contract.Requires(a.Length > 0);
- ClousotDebug.Francesco_PrintArrayContent();
- //sv9 (15) -> {0 ,sv4 (10)} [-333333, -333333] {sv19 (32) ,sv10 (16)}?
+ for (int i = 0; i < a.Length; i++)
+ {
+ a[i] = -333333;
+ }
- for (int i = 0; i < a.Length; i++)
- {
- Contract.Assert(a[i] == -333333); // True
- }
- }
+ ClousotDebug.Francesco_PrintArrayContent();
+ //sv9 (15) -> {0 ,sv4 (10)} [-333333, -333333] {sv19 (32) ,sv10 (16)}?
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 42, MethodILOffset = 0)]
- public void InitArrayTo_i(int[] a)
- {
- Contract.Requires(a.Length > 0);
+ for (int i = 0; i < a.Length; i++)
+ {
+ Contract.Assert(a[i] == -333333); // True
+ }
+ }
- for (int i = 0; i < a.Length; i++)
- {
- a[i] = i;
- }
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 42, MethodILOffset = 0)]
+ public void InitArrayTo_i(int[] a)
+ {
+ Contract.Requires(a.Length > 0);
- for (int i = 0; i < a.Length; i++)
- {
- Contract.Assert(a[i] >= 0); // True
- }
- }
+ for (int i = 0; i < a.Length; i++)
+ {
+ a[i] = i;
+ }
- // TODO
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 39, MethodILOffset = 0)]
- public void InitArrayToi_NeedRelational(int[] a)
- {
- Contract.Requires(a.Length > 0);
+ for (int i = 0; i < a.Length; i++)
+ {
+ Contract.Assert(a[i] >= 0); // True
+ }
+ }
- for (int i = 0; i < a.Length; i++)
- {
- a[i] = i;
- }
+ // TODO
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 39, MethodILOffset = 0)]
+ public void InitArrayToi_NeedRelational(int[] a)
+ {
+ Contract.Requires(a.Length > 0);
- for (int i = 0; i < a.Length; i++)
- {
- Contract.Assert(a[i] == i); // TODO: We need relational information here
- }
- }
+ for (int i = 0; i < a.Length; i++)
+ {
+ a[i] = i;
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 63, MethodILOffset = 0)]
- public int[] Copy_Wrong(int[] from)
- {
- var result = new int[from.Length];
- int j = 0;
- for (int i = 0; i < from.Length; i++)
- {
- Contract.Assume(j <= i);
+ for (int i = 0; i < a.Length; i++)
+ {
+ Contract.Assert(a[i] == i); // TODO: We need relational information here
+ }
+ }
- if (from[i] > 0)
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 63, MethodILOffset = 0)]
+ public int[] Copy_Wrong(int[] from)
{
- result[j] = from[i];
+ var result = new int[from.Length];
+ int j = 0;
+ for (int i = 0; i < from.Length; i++)
+ {
+ Contract.Assume(j <= i);
- j++;
- }
- }
+ if (from[i] > 0)
+ {
+ result[j] = from[i];
- // ClousotDebug.Francesco_PrintArrayContent();
+ j++;
+ }
+ }
- for (int k = 0; k < result.Length; k++)
- {
- Contract.Assert(result[k] > 0); // Top
- }
+ // ClousotDebug.Francesco_PrintArrayContent();
- return result;
- }
+ for (int k = 0; k < result.Length; k++)
+ {
+ Contract.Assert(result[k] > 0); // Top
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 63, MethodILOffset = 0)]
- public int[] Copy_Ok(int[] from)
- {
- var result = new int[from.Length];
- int j = 0;
- for (int i = 0; i < from.Length; i++)
- {
- Contract.Assume(j <= i);
+ return result;
+ }
- if (from[i] > 0)
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 63, MethodILOffset = 0)]
+ public int[] Copy_Ok(int[] from)
{
- result[j] = from[i];
+ var result = new int[from.Length];
+ int j = 0;
+ for (int i = 0; i < from.Length; i++)
+ {
+ Contract.Assume(j <= i);
- j++;
- }
- }
+ if (from[i] > 0)
+ {
+ result[j] = from[i];
- for (int k = 0; k < j; k++)
- {
- Contract.Assert(result[k] > 0); // OK
- }
+ j++;
+ }
+ }
- return result;
- }
+ for (int k = 0; k < j; k++)
+ {
+ Contract.Assert(result[k] > 0); // OK
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 36, MethodILOffset = 0)]
- public void InitTo1234_With_Incrementer(int[] a)
- {
- var i = 0;
- while (i < a.Length)
- {
- a[i++] = 1234;
- }
+ return result;
+ }
- for (int j = 0; j < a.Length; j++)
- {
- Contract.Assert(a[j] == 1234);
- }
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 36, MethodILOffset = 0)]
+ public void InitTo1234_With_Incrementer(int[] a)
+ {
+ var i = 0;
+ while (i < a.Length)
+ {
+ a[i++] = 1234;
+ }
- }
+ for (int j = 0; j < a.Length; j++)
+ {
+ Contract.Assert(a[j] == 1234);
+ }
+ }
- // TODO
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 37, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 48, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 59, MethodILOffset = 0)]
- public void SetToThree_Length10_From2()
- {
- int[] a = new int[10];
+ // TODO
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 37, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 48, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 59, MethodILOffset = 0)]
+ public void SetToThree_Length10_From2()
+ {
+ int[] a = new int[10];
- int i;
- for (i = 2; i < a.Length; i++)
- {
- a[i] = 3;
- }
+ int i;
+ for (i = 2; i < a.Length; i++)
+ {
+ a[i] = 3;
+ }
- ClousotDebug.Francesco_PrintArrayContent();
+ ClousotDebug.Francesco_PrintArrayContent();
- Contract.Assert(a[1] == 0); // True - we can prove it
- Contract.Assert(a[7] == 3); // True - cannot prove it yet
- Contract.Assert(a[3] == 4); // False - we can prove it
- }
+ Contract.Assert(a[1] == 0); // True - we can prove it
+ Contract.Assert(a[7] == 3); // True - cannot prove it yet
+ Contract.Assert(a[3] == 4); // False - we can prove it
+ }
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=99,MethodILOffset=0)]
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 99, MethodILOffset = 0)]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=13,MethodILOffset=94)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: predicate != null (predicate)",PrimaryILOffset=35,MethodILOffset=94)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=3,MethodILOffset=94)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=25,MethodILOffset=94)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=22,MethodILOffset=94)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=44,MethodILOffset=94)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 22, MethodILOffset = 94)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 94)]
#endif
- public void SetFromNthElement(int[] array, int N)
- {
- Contract.Requires(N >= 0);
- Contract.Requires(N < array.Length);
-
- for (var i = N; i < array.Length; i++)
- {
- array[i] = 9876;
- }
-
- Contract.Assert(Contract.ForAll(N, array.Length, index => array[index] == 9876)); // ok
- }
+#endif
+ public void SetFromNthElement(int[] array, int N)
+ {
+ Contract.Requires(N >= 0);
+ Contract.Requires(N < array.Length);
- }
+ for (var i = N; i < array.Length; i++)
+ {
+ array[i] = 9876;
+ }
- public class ClousotDebug
- {
- static internal void Francesco_PrintArrayContent()
+ Contract.Assert(Contract.ForAll(N, array.Length, index => array[index] == 9876)); // ok
+ }
+ }
+
+ public class ClousotDebug
{
+ internal static void Francesco_PrintArrayContent()
+ {
+ }
}
- }
}
namespace UseForAll
{
- class Assume
- {
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 101, MethodILOffset = 0)]
- public static void Test1_Ok(int[] a, int i)
+ internal class Assume
{
- Contract.Requires(a != null);
- Contract.Requires(i >= 0);
- Contract.Requires(i < a.Length);
- Contract.Requires(Contract.ForAll(0, a.Length, j => a[j] > 100));
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 101, MethodILOffset = 0)]
+ public static void Test1_Ok(int[] a, int i)
+ {
+ Contract.Requires(a != null);
+ Contract.Requires(i >= 0);
+ Contract.Requires(i < a.Length);
+ Contract.Requires(Contract.ForAll(0, a.Length, j => a[j] > 100));
- Contract.Assert(a[i] > 100); // True
- }
+ Contract.Assert(a[i] > 100); // True
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 101, MethodILOffset = 0)]
- public static void Test2_NotOk(int[] a, int i)
- {
- Contract.Requires(a != null);
- Contract.Requires(i >= 0);
- Contract.Requires(i < a.Length);
- Contract.Requires(Contract.ForAll(0, a.Length, j => a[j] > 100));
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 101, MethodILOffset = 0)]
+ public static void Test2_NotOk(int[] a, int i)
+ {
+ Contract.Requires(a != null);
+ Contract.Requires(i >= 0);
+ Contract.Requires(i < a.Length);
+ Contract.Requires(Contract.ForAll(0, a.Length, j => a[j] > 100));
- Contract.Assert(a[i] == -100); // False
- }
+ Contract.Assert(a[i] == -100); // False
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=73,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=93,MethodILOffset=0)]
- public static void Test3(int[] a)
- {
- Contract.Requires(a.Length >= 10);
- Contract.Requires(Contract.ForAll(2, 10, t => a[t] == -765));
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 73, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 93, MethodILOffset = 0)]
+ public static void Test3(int[] a)
+ {
+ Contract.Requires(a.Length >= 10);
+ Contract.Requires(Contract.ForAll(2, 10, t => a[t] == -765));
- Contract.Assert(a[3] == -765); // True
- Contract.Assert(a[0] == -765); // Top
- }
+ Contract.Assert(a[3] == -765); // True
+ Contract.Assert(a[0] == -765); // Top
+ }
- [ClousotRegressionTest("Intervals")]
+ [ClousotRegressionTest("Intervals")]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=13,MethodILOffset=50)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven: predicate != null (predicate)",PrimaryILOffset=35,MethodILOffset=50)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=3,MethodILOffset=50)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=25,MethodILOffset=50)]
#else
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 50)]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 50)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 50)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 50)]
#endif
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 75, MethodILOffset = 0)]
- public void TestAssumeForAll(int[] arr)
- {
- Contract.Requires(arr.Length > 0);
- Contract.Assume(Contract.ForAll(0, arr.Length, i => arr[i] == -987));
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 75, MethodILOffset = 0)]
+ public void TestAssumeForAll(int[] arr)
+ {
+ Contract.Requires(arr.Length > 0);
+ Contract.Assume(Contract.ForAll(0, arr.Length, i => arr[i] == -987));
- Contract.Assert(arr[0] == -987); // true
+ Contract.Assert(arr[0] == -987); // true
+ }
}
- }
- class Assert
- {
- [ClousotRegressionTest]
+ internal class Assert
+ {
+ [ClousotRegressionTest]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=13,MethodILOffset=45)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: predicate != null (predicate)",PrimaryILOffset=35,MethodILOffset=45)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=3,MethodILOffset=45)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=25,MethodILOffset=45)]
- #else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=45)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=44,MethodILOffset=45)]
- #endif
+ #else
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 45)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 45)]
#endif
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=50,MethodILOffset=0)]
- public static string[] Test1()
- {
- var result = new string[1];
- result[0] = "Ciao";
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 50, MethodILOffset = 0)]
+ public static string[] Test1()
+ {
+ var result = new string[1];
+ result[0] = "Ciao";
- Contract.Assert(Contract.ForAll(0, 1, j => result[j] != null)); // We get top because we do not run the nonnull analysis in this test
+ Contract.Assert(Contract.ForAll(0, 1, j => result[j] != null)); // We get top because we do not run the nonnull analysis in this test
- return result;
- }
+ return result;
+ }
- [ClousotRegressionTest("Intervals")]
+ [ClousotRegressionTest("Intervals")]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=13,MethodILOffset=82)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven: predicate != null (predicate)",PrimaryILOffset=35,MethodILOffset=82)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=3,MethodILOffset=82)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=25,MethodILOffset=82)]
#else
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 82)]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 82)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 82)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 82)]
#endif
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 87, MethodILOffset = 0)]
- public void TestAssertForAll(int[] arr)
- {
- Contract.Requires(arr.Length > 0);
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 87, MethodILOffset = 0)]
+ public void TestAssertForAll(int[] arr)
+ {
+ Contract.Requires(arr.Length > 0);
- for (int i = 0; i < arr.Length; i++)
- {
- arr[i] = -987;
- }
+ for (int i = 0; i < arr.Length; i++)
+ {
+ arr[i] = -987;
+ }
- Contract.Assert(Contract.ForAll(0, arr.Length, i => arr[i] == -987));
- }
+ Contract.Assert(Contract.ForAll(0, arr.Length, i => arr[i] == -987));
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 55, MethodILOffset = 92)]
- public void TestEnsuresForAll(int[] arr)
- {
- Contract.Requires(arr.Length > 0);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 55, MethodILOffset = 92)]
+ public void TestEnsuresForAll(int[] arr)
+ {
+ Contract.Requires(arr.Length > 0);
- Contract.Ensures(Contract.ForAll(0, arr.Length, i => arr[i] == -987));
+ Contract.Ensures(Contract.ForAll(0, arr.Length, i => arr[i] == -987));
- for (int i = 0; i < arr.Length; i++)
- {
- arr[i] = -987;
- }
+ for (int i = 0; i < arr.Length; i++)
+ {
+ arr[i] = -987;
+ }
+ }
}
- }
- class Requires
- {
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 101, MethodILOffset = 0)]
- public void ForEach(int[] a)
+ internal class Requires
{
- Contract.Requires(a != null);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 101, MethodILOffset = 0)]
+ public void ForEach(int[] a)
+ {
+ Contract.Requires(a != null);
- Contract.Requires(Contract.ForAll(0, a.Length, i => a[i] > 0));
+ Contract.Requires(Contract.ForAll(0, a.Length, i => a[i] > 0));
- var sum = 1;
+ var sum = 1;
- foreach (var val in a)
- {
- sum += val;
- }
+ foreach (var val in a)
+ {
+ sum += val;
+ }
- // Well, up to overflows
- Contract.Assert(sum > 0);
+ // Well, up to overflows
+ Contract.Assert(sum > 0);
+ }
}
- }
}
namespace FromPapers
{
- public class KovacsVoronkov
- {
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 83, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 111, MethodILOffset = 0)]
- public void KovacsVoronkov_NoIncrements_Wrong(int[] a)
+ public class KovacsVoronkov
{
- int[] pos = new int[a.Length];
- int[] neg = new int[a.Length];
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 83, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 111, MethodILOffset = 0)]
+ public void KovacsVoronkov_NoIncrements_Wrong(int[] a)
+ {
+ int[] pos = new int[a.Length];
+ int[] neg = new int[a.Length];
- int p = 0;
- int n = 0;
+ int p = 0;
+ int n = 0;
- for (int i = 0; i < a.Length; i++)
- {
- if (a[i] > 0)
- {
- pos[p] = a[i];
- p++;
- }
- else
- {
- neg[n] = a[i];
- n++;
+ for (int i = 0; i < a.Length; i++)
+ {
+ if (a[i] > 0)
+ {
+ pos[p] = a[i];
+ p++;
+ }
+ else
+ {
+ neg[n] = a[i];
+ n++;
+ }
+ }
+
+ for (int i = 0; i < p; i++)
+ {
+ Contract.Assert(pos[i] > 0); // True
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ Contract.Assert(neg[i] < 0); // Top: can be zero!
+ }
}
- }
- for (int i = 0; i < p; i++)
- {
- Contract.Assert(pos[i] > 0); // True
- }
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 61, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 102, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 130, MethodILOffset = 0)]
+ public void KovacsVoronkov_NoIncrements(int[] a)
+ {
+ int[] pos = new int[a.Length];
+ int[] neg = new int[a.Length];
- for (int i = 0; i < n; i++)
- {
- Contract.Assert(neg[i] < 0); // Top: can be zero!
- }
- }
+ int p = 0;
+ int n = 0;
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 61, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 102, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 130, MethodILOffset = 0)]
- public void KovacsVoronkov_NoIncrements(int[] a)
- {
- int[] pos = new int[a.Length];
- int[] neg = new int[a.Length];
+ for (int i = 0; i < a.Length; i++)
+ {
+ if (a[i] > 0)
+ {
+ pos[p] = a[i];
+ p++;
+ }
+ else if (a[i] < 0)
+ {
+ Contract.Assert(a[i] < 0);
+ neg[n] = a[i];
+ n++;
+ }
+ }
- int p = 0;
- int n = 0;
+ for (int i = 0; i < p; i++)
+ {
+ Contract.Assert(pos[i] > 0);
+ }
- for (int i = 0; i < a.Length; i++)
- {
- if (a[i] > 0)
- {
- pos[p] = a[i];
- p++;
+ for (int i = 0; i < n; i++)
+ {
+ Contract.Assert(neg[i] < 0);
+ }
}
- else if (a[i] < 0)
+
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 122, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 150, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 179, MethodILOffset = 0)]
+ public void KovacsVoronkov_NoIncrements_Zero(int[] a)
{
- Contract.Assert(a[i] < 0);
- neg[n] = a[i];
- n++;
- }
- }
+ int[] pos = new int[a.Length];
+ int[] neg = new int[a.Length];
+ int[] zero = new int[a.Length];
- for (int i = 0; i < p; i++)
- {
- Contract.Assert(pos[i] > 0);
- }
+ int p = 0;
+ int n = 0;
+ int z = 0;
- for (int i = 0; i < n; i++)
- {
- Contract.Assert(neg[i] < 0);
- }
- }
+ for (int i = 0; i < a.Length; i++)
+ {
+ if (a[i] > 0)
+ {
+ pos[p] = a[i];
+ p++;
+ }
+ else if (a[i] < 0)
+ {
+ neg[n] = a[i];
+ n++;
+ }
+ else
+ {
+ zero[z] = a[i];
+ z++;
+ }
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 122, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 150, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 179, MethodILOffset = 0)]
- public void KovacsVoronkov_NoIncrements_Zero(int[] a)
- {
- int[] pos = new int[a.Length];
- int[] neg = new int[a.Length];
- int[] zero = new int[a.Length];
+ for (int i = 0; i < p; i++)
+ {
+ Contract.Assert(pos[i] > 0); // True
+ }
- int p = 0;
- int n = 0;
- int z = 0;
+ for (int i = 0; i < n; i++)
+ {
+ Contract.Assert(neg[i] < 0); // True
+ }
- for (int i = 0; i < a.Length; i++)
- {
- if (a[i] > 0)
- {
- pos[p] = a[i];
- p++;
- }
- else if (a[i] < 0)
- {
- neg[n] = a[i];
- n++;
- }
- else
- {
- zero[z] = a[i];
- z++;
+ for (int i = 0; i < z; i++)
+ {
+ Contract.Assert(zero[i] == 0); // True
+ }
}
- }
-
- for (int i = 0; i < p; i++)
- {
- Contract.Assert(pos[i] > 0); // True
- }
-
- for (int i = 0; i < n; i++)
- {
- Contract.Assert(neg[i] < 0); // True
- }
- for (int i = 0; i < z; i++)
- {
- Contract.Assert(zero[i] == 0); // True
- }
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 132, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 149, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 178, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 206, MethodILOffset = 0)]
+ public static void Split(int[] input)
+ {
+ Contract.Requires(input != null);
- }
+ int[] zero = new int[input.Length],
+ pos = new int[input.Length], neg = new int[input.Length];
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 132, MethodILOffset = 0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=149,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=178,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=206,MethodILOffset=0)]
- public static void Split(int[] input)
- {
- Contract.Requires(input != null);
+ int z = 0, p = 0, n = 0;
- int[] zero = new int[input.Length],
- pos = new int[input.Length], neg = new int[input.Length];
+ for (int i = 0; i < input.Length; i++)
+ {
+ if (input[i] > 0)
+ {
+ pos[p++] = input[i];
+ }
+ else if (input[i] < 0)
+ {
+ neg[n++] = input[i];
+ }
+ else
+ {
+ zero[z++] = input[i];
+ }
+ }
- int z = 0, p = 0, n = 0;
+ Contract.Assert(input.Length == p + n + z);
- for (int i = 0; i < input.Length; i++)
- {
- if (input[i] > 0)
- {
- pos[p++] = input[i];
- }
- else if (input[i] < 0)
- {
- neg[n++] = input[i];
- }
- else
- {
- zero[z++] = input[i];
+ for (int i = 0; i < p; i++)
+ {
+ Contract.Assert(pos[i] > 0); // True
+ }
+ for (int i = 0; i < z; i++)
+ {
+ Contract.Assert(zero[i] == 0); // True
+ }
+ for (int i = 0; i < n; i++)
+ {
+ Contract.Assert(neg[i] < 0); // True
+ }
}
- }
- Contract.Assert(input.Length == p + n + z);
-
- for (int i = 0; i < p; i++)
- {
- Contract.Assert(pos[i] > 0); // True
- }
- for (int i = 0; i < z; i++)
- {
- Contract.Assert(zero[i] == 0); // True
- }
- for (int i = 0; i < n; i++)
- {
- Contract.Assert(neg[i] < 0); // True
- }
- }
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 70, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 82, MethodILOffset = 0)]
+ public void GopanRepsSagiv_PartialInit_Ok(int[] a, int[] b, int[] c)
+ {
+ Contract.Requires(a.Length == b.Length);
+ Contract.Requires(a.Length == 100);
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 70, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 82, MethodILOffset = 0)]
- public void GopanRepsSagiv_PartialInit_Ok(int[] a, int[] b, int[] c)
- {
- Contract.Requires(a.Length == b.Length);
- Contract.Requires(a.Length == 100);
+ int j = 0;
+ for (int i = 0; i < a.Length; i++)
+ {
+ if (a[i] == b[i])
+ {
+ c[j] = i;
+ j++;
+ }
+ }
- int j = 0;
- for (int i = 0; i < a.Length; i++)
- {
- if (a[i] == b[i])
- {
- c[j] = i;
- j++;
+ for (int k = 0; k < j; k++)
+ {
+ Contract.Assert(c[k] >= 0); // True
+ Contract.Assert(c[k] < 100); // True
+ }
}
- }
- for (int k = 0; k < j; k++)
- {
- Contract.Assert(c[k] >= 0); // True
- Contract.Assert(c[k] < 100); // True
- }
- }
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 70, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 82, MethodILOffset = 0)]
+ public void GopanRepsSagiv_PartialInit_NotOk(int[] a, int[] b, int[] c)
+ {
+ Contract.Requires(a.Length == b.Length);
+ Contract.Requires(a.Length == 100);
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=70,MethodILOffset=0)]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 82, MethodILOffset = 0)]
- public void GopanRepsSagiv_PartialInit_NotOk(int[] a, int[] b, int[] c)
- {
- Contract.Requires(a.Length == b.Length);
- Contract.Requires(a.Length == 100);
+ int j = 0;
+ for (int i = 0; i < a.Length; i++)
+ {
+ if (a[i] == b[i])
+ {
+ c[j] = i;
+ j++;
+ }
+ }
- int j = 0;
- for (int i = 0; i < a.Length; i++)
- {
- if (a[i] == b[i])
- {
- c[j] = i;
- j++;
+ for (int k = 0; k < c.Length; k++)
+ {
+ Contract.Assert(c[k] >= 0); // Top
+ Contract.Assert(c[k] < 100); // Top
+ }
}
- }
-
- for (int k = 0; k < c.Length; k++)
- {
- Contract.Assert(c[k] >= 0); // Top
- Contract.Assert(c[k] < 100); // Top
- }
}
- }
}
// F: We keep Mathias's test anyway , even if they duplicate some of the tests above
+
namespace Mathias
{
- class Program
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=81,MethodILOffset=0)]
+ internal class Program
+ {
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 81, MethodILOffset = 0)]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=17,MethodILOffset=76)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: predicate != null (predicate)",PrimaryILOffset=39,MethodILOffset=76)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=3,MethodILOffset=76)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=25,MethodILOffset=76)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=76)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=44,MethodILOffset=76)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 76)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 76)]
#endif
- public int Max(int[] arr)
- {
- Contract.Requires(arr != null);
- int max = Int32.MinValue;
-
- for (int i = 0; i < arr.Length; i++)
- {
- if (arr[i] > max)
+#endif
+ public int Max(int[] arr)
{
- max = arr[i];
- }
- }
-
- Contract.Assert(Contract.ForAll(arr, el => el <= max));
+ Contract.Requires(arr != null);
+ int max = int.MinValue;
- return max;
- }
+ for (int i = 0; i < arr.Length; i++)
+ {
+ if (arr[i] > max)
+ {
+ max = arr[i];
+ }
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=42,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=56,MethodILOffset=0)]
- static void MathiasTest0(string[] args)
- {
- int[] a = new int[5];
+ Contract.Assert(Contract.ForAll(arr, el => el <= max));
- for (int i = 0; i < a.Length - 1; i = i + 1)
- {
- a[i + 1] = 7;
- }
+ return max;
+ }
- // here a[i] == 0, so a[*] \in [0, 7]
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 42, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 56, MethodILOffset = 0)]
+ private static void MathiasTest0(string[] args)
+ {
+ int[] a = new int[5];
- for (int i = 0; i < a.Length; i++)
- {
- Contract.Assert(a[i] >= 0); // True
- Contract.Assert(a[i] <= 7); // True, but we cannot prove it: we need one more join before widening (-joinsBeforeWidening >= 2)
- }
- }
+ for (int i = 0; i < a.Length - 1; i = i + 1)
+ {
+ a[i + 1] = 7;
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 36, MethodILOffset = 0)]
- static void SetToSeven()
- {
- int[] a = new int[53];
+ // here a[i] == 0, so a[*] \in [0, 7]
- for (int i = 0; i < a.Length; i = i + 1)
- {
- a[i] = 7;
- }
+ for (int i = 0; i < a.Length; i++)
+ {
+ Contract.Assert(a[i] >= 0); // True
+ Contract.Assert(a[i] <= 7); // True, but we cannot prove it: we need one more join before widening (-joinsBeforeWidening >= 2)
+ }
+ }
- for (int i = 0; i < a.Length; i++)
- {
- Contract.Assert(a[i] == 7);
- }
- }
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 36, MethodILOffset = 0)]
+ private static void SetToSeven()
+ {
+ int[] a = new int[53];
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 48, MethodILOffset = 0)]
- static int[] FilterGTZero(int[] z)
- {
- int[] res = new int[z.Length];
+ for (int i = 0; i < a.Length; i = i + 1)
+ {
+ a[i] = 7;
+ }
- for (int i = 0; i < z.Length; i++)
- {
- if (z[i] >= 0)
- {
- res[i] = z[i];
+ for (int i = 0; i < a.Length; i++)
+ {
+ Contract.Assert(a[i] == 7);
+ }
}
- }
- for (int i = 0; i < res.Length; i++)
- {
- Contract.Assert(res[i] >= 0); // True
- }
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 48, MethodILOffset = 0)]
+ private static int[] FilterGTZero(int[] z)
+ {
+ int[] res = new int[z.Length];
- return res;
- }
+ for (int i = 0; i < z.Length; i++)
+ {
+ if (z[i] >= 0)
+ {
+ res[i] = z[i];
+ }
+ }
- // TODO: We need week relational information
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 60, MethodILOffset = 0)]
- static int[] FilterUp(int[] z, int M)
- {
- Contract.Requires(M >= 0);
+ for (int i = 0; i < res.Length; i++)
+ {
+ Contract.Assert(res[i] >= 0); // True
+ }
- int[] res = new int[z.Length];
+ return res;
+ }
- for (int i = 0; i < z.Length; i++)
- {
- if (z[i] >= M)
+ // TODO: We need week relational information
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 60, MethodILOffset = 0)]
+ private static int[] FilterUp(int[] z, int M)
{
- res[i] = z[i];
- }
- }
+ Contract.Requires(M >= 0);
- // It seems it does not infer res[*] >= 0
+ int[] res = new int[z.Length];
- for (int i = 0; i < res.Length; i++)
- {
- Contract.Assert(res[i] >= M); // True, but we cannot prove it yet, without relational information
- }
+ for (int i = 0; i < z.Length; i++)
+ {
+ if (z[i] >= M)
+ {
+ res[i] = z[i];
+ }
+ }
- return res;
- }
+ // It seems it does not infer res[*] >= 0
- // TODO: We need relational segment indexes
- [ClousotRegressionTest("Intervals")]
- static void CopyArray(int[] from, int[] to)
- {
- Contract.Requires(from.Length == to.Length);
+ for (int i = 0; i < res.Length; i++)
+ {
+ Contract.Assert(res[i] >= M); // True, but we cannot prove it yet, without relational information
+ }
+
+ return res;
+ }
- for (int i = 0; i < from.Length; i++)
- {
- to[i] = from[i];
- }
+ // TODO: We need relational segment indexes
+ [ClousotRegressionTest("Intervals")]
+ private static void CopyArray(int[] from, int[] to)
+ {
+ Contract.Requires(from.Length == to.Length);
+
+ for (int i = 0; i < from.Length; i++)
+ {
+ to[i] = from[i];
+ }
+ }
}
- }
}
namespace NonConsecutiveArrayAccesses
{
- class MsCorlib_Random
- {
- int[] SeedArray;
+ internal class MsCorlib_Random
+ {
+ private int[] SeedArray;
- int inext;
- int inextp;
+ private int inext;
+ private int inextp;
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 75, MethodILOffset = 0)]
- public void Random_0_OK(int Seed, int posValue)
- {
- Contract.Requires(posValue > 0);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 75, MethodILOffset = 0)]
+ public void Random_0_OK(int Seed, int posValue)
+ {
+ Contract.Requires(posValue > 0);
- this.SeedArray = new int[0x38];
+ SeedArray = new int[0x38];
- for (int i = 1; i < 0x38; i++)
- {
- int index = (0x15 * i) % 0x38;
- this.SeedArray[index] = posValue; // Tests non consecutive array access
- }
+ for (int i = 1; i < 0x38; i++)
+ {
+ int index = (0x15*i)%0x38;
+ SeedArray[index] = posValue; // Tests non consecutive array access
+ }
- // sv22 (1808) -> {0 ,sv4 (1790)} [0, +oo] {sv21 (1807) ,56}
- ClousotDebug.Francesco_PrintArrayContent();
+ // sv22 (1808) -> {0 ,sv4 (1790)} [0, +oo] {sv21 (1807) ,56}
+ ClousotDebug.Francesco_PrintArrayContent();
- for (var i = 0; i < this.SeedArray.Length; i++)
- {
- Contract.Assert(this.SeedArray[i] >= 0); //True
- }
- }
+ for (var i = 0; i < SeedArray.Length; i++)
+ {
+ Contract.Assert(SeedArray[i] >= 0); //True
+ }
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 85, MethodILOffset = 0)]
- public void Random_1_OK(int Seed, int posValue, int num2)
- {
- Contract.Requires(posValue > 0);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 85, MethodILOffset = 0)]
+ public void Random_1_OK(int Seed, int posValue, int num2)
+ {
+ Contract.Requires(posValue > 0);
- this.SeedArray = new int[0x38];
+ SeedArray = new int[0x38];
- this.SeedArray[0x37] = num2; // Set the last element to some arbitrary value
+ SeedArray[0x37] = num2; // Set the last element to some arbitrary value
- for (int i = 1; i < 0x37; i++)
- {
- int index = (0x15 * i) % 0x37;
- this.SeedArray[index] = posValue;
- }
+ for (int i = 1; i < 0x37; i++)
+ {
+ int index = (0x15*i)%0x37;
+ SeedArray[index] = posValue;
+ }
- // sv25 (1877) -> {0 ,sv4 (1856)} [0, +oo] {55 ,sv27 (1879)} [-oo, +oo] {sv24 (1876) ,56}
- ClousotDebug.Francesco_PrintArrayContent();
+ // sv25 (1877) -> {0 ,sv4 (1856)} [0, +oo] {55 ,sv27 (1879)} [-oo, +oo] {sv24 (1876) ,56}
+ ClousotDebug.Francesco_PrintArrayContent();
- for (var i = 0; i < this.SeedArray.Length - 1; i++)
- {
- Contract.Assert(this.SeedArray[i] >= 0); // Should be true
- }
- }
+ for (var i = 0; i < SeedArray.Length - 1; i++)
+ {
+ Contract.Assert(SeedArray[i] >= 0); // Should be true
+ }
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 85, MethodILOffset = 0)]
- public void Random_1_NOTOK(int Seed, int posValue, int num2)
- {
- Contract.Requires(posValue > 0);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 85, MethodILOffset = 0)]
+ public void Random_1_NOTOK(int Seed, int posValue, int num2)
+ {
+ Contract.Requires(posValue > 0);
- this.SeedArray = new int[0x38]; // Set the last element to some arbitrary value
+ SeedArray = new int[0x38]; // Set the last element to some arbitrary value
- this.SeedArray[0x37] = num2;
+ SeedArray[0x37] = num2;
- for (int i = 1; i < 0x37; i++)
- {
- int index = (0x15 * i) % 0x37;
- this.SeedArray[index] = posValue;
- }
+ for (int i = 1; i < 0x37; i++)
+ {
+ int index = (0x15*i)%0x37;
+ SeedArray[index] = posValue;
+ }
- // sv25 (1950) -> {0 ,sv4 (1929)} [0, +oo] {55 ,sv27 (1952)} [-oo, +oo] {sv24 (1949) ,56}
- ClousotDebug.Francesco_PrintArrayContent();
+ // sv25 (1950) -> {0 ,sv4 (1929)} [0, +oo] {55 ,sv27 (1952)} [-oo, +oo] {sv24 (1949) ,56}
+ ClousotDebug.Francesco_PrintArrayContent();
- for (var i = 0; i < this.SeedArray.Length; i++)
- {
- Contract.Assert(this.SeedArray[i] >= 0); // Should be top as the last element can be any value
- }
- }
+ for (var i = 0; i < SeedArray.Length; i++)
+ {
+ Contract.Assert(SeedArray[i] >= 0); // Should be top as the last element can be any value
+ }
+ }
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 77, MethodILOffset = 0)]
- public void Random_2_FromZero_OK(int Seed, int num2, int val)
- {
- Contract.Requires(val > 0);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 77, MethodILOffset = 0)]
+ public void Random_2_FromZero_OK(int Seed, int num2, int val)
+ {
+ Contract.Requires(val > 0);
- this.SeedArray = new int[0x38];
+ SeedArray = new int[0x38];
- this.SeedArray[0x37] = num2; // The fact we were setting the last element exposed an unsoundness in the materialization in the loop
+ SeedArray[0x37] = num2; // The fact we were setting the last element exposed an unsoundness in the materialization in the loop
- for (int k = 0; k < 0x38; k++)
- {
- this.SeedArray[k] = val;
- }
+ for (int k = 0; k < 0x38; k++)
+ {
+ SeedArray[k] = val;
+ }
- // sv25 (1950) -> {0 ,sv4 (1929)} [0, +oo] {55 ,sv27 (1952)} [-oo, +oo] {sv24 (1949) ,56}
- ClousotDebug.Francesco_PrintArrayContent();
- for (var i = 0; i < this.SeedArray.Length; i++)
- {
- Contract.Assert(this.SeedArray[i] >= 0); // ok
- }
- }
+ // sv25 (1950) -> {0 ,sv4 (1929)} [0, +oo] {55 ,sv27 (1952)} [-oo, +oo] {sv24 (1949) ,56}
+ ClousotDebug.Francesco_PrintArrayContent();
+ for (var i = 0; i < SeedArray.Length; i++)
+ {
+ Contract.Assert(SeedArray[i] >= 0); // ok
+ }
+ }
- // TODO: need to push the info k=1
- //[ClousotRegressionTest("Intervals")]
- public void Random_2_FromOne_Ok(int Seed, int num2, int val)
- {
- Contract.Requires(val > 0);
+ // TODO: need to push the info k=1
+ //[ClousotRegressionTest("Intervals")]
+ public void Random_2_FromOne_Ok(int Seed, int num2, int val)
+ {
+ Contract.Requires(val > 0);
- this.SeedArray = new int[0x38];
+ SeedArray = new int[0x38];
- this.SeedArray[0x37] = num2;
+ SeedArray[0x37] = num2;
- for (int k = 1; k < 0x38; k++) // Here k starts from 1
- {
- ClousotDebug.Francesco_PrintArrayContent();
- this.SeedArray[k] = val;
- ClousotDebug.Francesco_PrintArrayContent();
- }
+ for (int k = 1; k < 0x38; k++) // Here k starts from 1
+ {
+ ClousotDebug.Francesco_PrintArrayContent();
+ SeedArray[k] = val;
+ ClousotDebug.Francesco_PrintArrayContent();
+ }
- ClousotDebug.Francesco_PrintArrayContent();
- for (var i = 0; i < this.SeedArray.Length; i++)
- {
- Contract.Assert(this.SeedArray[i] >= 0); // True, but we cannot prove it yet
- }
- }
+ ClousotDebug.Francesco_PrintArrayContent();
+ for (var i = 0; i < SeedArray.Length; i++)
+ {
+ Contract.Assert(SeedArray[i] >= 0); // True, but we cannot prove it yet
+ }
+ }
- // The constructor of the Random class in mscorlib
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: value != -2147483648",PrimaryILOffset=17,MethodILOffset=19)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 82, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 125, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 212, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 307, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 376, MethodILOffset = 0)]
- public void Random_3_WithManualLoopUnrolling(int Seed)
- {
- this.SeedArray = new int[0x38];
- int num2 = 0x9a4ec86 - Math.Abs(Seed);
- this.SeedArray[0x37] = num2;
- int num3 = 1;
- for (int i = 1; i < 0x37; i++)
- {
- int index = (0x15 * i) % 0x37;
- this.SeedArray[index] = num3;
- num3 = num2 - num3;
- if (num3 < 0)
+ // The constructor of the Random class in mscorlib
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven: value != -2147483648", PrimaryILOffset = 17, MethodILOffset = 19)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 82, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 125, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 212, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 307, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 376, MethodILOffset = 0)]
+ public void Random_3_WithManualLoopUnrolling(int Seed)
{
- num3 += 0x7fffffff;
- }
+ SeedArray = new int[0x38];
+ int num2 = 0x9a4ec86 - Math.Abs(Seed);
+ SeedArray[0x37] = num2;
+ int num3 = 1;
+ for (int i = 1; i < 0x37; i++)
+ {
+ int index = (0x15*i)%0x37;
+ SeedArray[index] = num3;
+ num3 = num2 - num3;
+ if (num3 < 0)
+ {
+ num3 += 0x7fffffff;
+ }
+
+ Contract.Assert(num3 >= -1); // ok
- Contract.Assert(num3 >= -1); // ok
+ num2 = SeedArray[index];
+ }
- num2 = this.SeedArray[index];
- }
+ for (var i = 0; i < SeedArray.Length - 1; i++)
+ {
+ Contract.Assert(SeedArray[i] >= -1); // ok
+ }
- for (var i = 0; i < this.SeedArray.Length - 1; i++)
- {
- Contract.Assert(this.SeedArray[i] >= -1); // ok
- }
+ // F: We do one loop unrolling
+ ClousotDebug.Francesco_PrintArrayContent();
+ for (int k = 0; k < 0x38; k++)
+ {
+ var val = SeedArray[k] - SeedArray[1 + ((k + 30)%0x37)];
- // F: We do one loop unrolling
- ClousotDebug.Francesco_PrintArrayContent();
- for (int k = 0; k < 0x38; k++)
- {
- var val = this.SeedArray[k] - this.SeedArray[1 + ((k + 30) % 0x37)];
+ if (val < 0)
+ {
+ val += 0x7fffffff;
+ }
- if (val < 0)
- {
- val += 0x7fffffff;
- }
+ Contract.Assert(val >= -1); // ok
+ SeedArray[k] = val;
+ }
- Contract.Assert(val >= -1); // ok
- this.SeedArray[k] = val;
- }
+ for (int j = 2; j < 5; j++)
+ {
+ ClousotDebug.Francesco_PrintArrayContent();
+ for (int k = 0; k < 0x38; k++)
+ {
+ var val = SeedArray[k] - SeedArray[1 + ((k + 30)%0x37)];
- for (int j = 2; j < 5; j++)
- {
- ClousotDebug.Francesco_PrintArrayContent();
- for (int k = 0; k < 0x38; k++)
- {
- var val = this.SeedArray[k] - this.SeedArray[1 + ((k + 30) % 0x37)];
+ if (val < 0)
+ {
+ val += 0x7fffffff;
+ }
- if (val < 0)
- {
- val += 0x7fffffff;
- }
+ Contract.Assert(val >= -1);
+ SeedArray[k] = val;
+ }
+ ClousotDebug.Francesco_PrintArrayContent();
+ }
- Contract.Assert(val >= -1);
- this.SeedArray[k] = val;
+ ClousotDebug.Francesco_PrintArrayContent();
+ for (var i = 0; i < SeedArray.Length; i++)
+ {
+ Contract.Assert(SeedArray[i] >= -1); // ok
+ }
}
- ClousotDebug.Francesco_PrintArrayContent();
- }
-
- ClousotDebug.Francesco_PrintArrayContent();
- for (var i = 0; i < this.SeedArray.Length; i++)
- {
- Contract.Assert(this.SeedArray[i] >= -1); // ok
- }
}
- }
-
- public class ClousotDebug
- {
- static internal void Francesco_PrintArrayContent()
+ public class ClousotDebug
{
+ internal static void Francesco_PrintArrayContent()
+ {
+ }
}
- }
}
namespace BugRepros
{
- public class ThrownExceptions
- {
- public int[] SeedArray;
-
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome=ProofOutcome.Bottom,Message=@"assert unreachable",PrimaryILOffset=52,MethodILOffset=0)]
- public void TestUnification_OutOfBounds(int val, bool b)
+ public class ThrownExceptions
{
- this.SeedArray = new int[0x38];
+ public int[] SeedArray;
+
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.Bottom, Message = @"assert unreachable", PrimaryILOffset = 52, MethodILOffset = 0)]
+ public void TestUnification_OutOfBounds(int val, bool b)
+ {
+ SeedArray = new int[0x38];
- this.SeedArray[0x38] = val; // definitely wrong indexing, it was causing a crash in the analsys
+ SeedArray[0x38] = val; // definitely wrong indexing, it was causing a crash in the analsys
- if (b)
- {
- this.SeedArray[0x15] = 22;
- }
+ if (b)
+ {
+ SeedArray[0x15] = 22;
+ }
- Contract.Assert(this.SeedArray[0x15] >= 0);
+ Contract.Assert(SeedArray[0x15] >= 0);
+ }
}
- }
-
- public class Join
- {
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=32,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=47,MethodILOffset=0)]
- public void TestUnification0(int val, bool b)
+
+ public class Join
{
- var loc = new int[0x38];
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 32, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 47, MethodILOffset = 0)]
+ public void TestUnification0(int val, bool b)
+ {
+ var loc = new int[0x38];
- loc[0x37] = val; // can be negative
+ loc[0x37] = val; // can be negative
- if (b)
- {
- loc[0x15] = 22;
- }
+ if (b)
+ {
+ loc[0x15] = 22;
+ }
- Contract.Assert(loc[0x15] >= 0); // true
- Contract.Assert(loc[0x37] >= 0); // top
+ Contract.Assert(loc[0x15] >= 0); // true
+ Contract.Assert(loc[0x37] >= 0); // top
+ }
}
- }
- public class ArrayEqualityTest
- {
- [ClousotRegressionTest("Intervals")]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=25,MethodILOffset=0)]
- public void TwoArrays(int[] a, int[] b)
+ public class ArrayEqualityTest
{
- Contract.Requires(a.Length > 1);
+ [ClousotRegressionTest("Intervals")]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 25, MethodILOffset = 0)]
+ public void TwoArrays(int[] a, int[] b)
+ {
+ Contract.Requires(a.Length > 1);
- a[0] = 1;
- if (a == b)
- {
- Contract.Assert(b[0] == 1); // True because we know a and b are the same array
- }
+ a[0] = 1;
+ if (a == b)
+ {
+ Contract.Assert(b[0] == 1); // True because we know a and b are the same array
+ }
+ }
}
- }
}
namespace MethodCalls
{
- public class Havoc
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: a != null",PrimaryILOffset=7,MethodILOffset=10)] // We are not running -nonnull in this test
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=18,MethodILOffset=10)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=22,MethodILOffset=0)]
- public void CallWithSideEffects()
+ public class Havoc
{
- var array = new int[16];
- Write(array); // Here we havoc the array content
- Contract.Assert(array[3] == 12); // unproven
- }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven: a != null", PrimaryILOffset = 7, MethodILOffset = 10)] // We are not running -nonnull in this test
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 18, MethodILOffset = 10)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 22, MethodILOffset = 0)]
+ public void CallWithSideEffects()
+ {
+ var array = new int[16];
+ Write(array); // Here we havoc the array content
+ Contract.Assert(array[3] == 12); // unproven
+ }
- private void Write(int[] a)
- {
- Contract.Requires(a != null);
- Contract.Requires(a.Length > 3);
- a[3] = 12;
- }
+ private void Write(int[] a)
+ {
+ Contract.Requires(a != null);
+ Contract.Requires(a.Length > 3);
+ a[3] = 12;
+ }
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: input != null",PrimaryILOffset=7,MethodILOffset=13)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=25,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.False,Message=@"assert is false",PrimaryILOffset=37,MethodILOffset=0)]
- public void CallWithNoSideEffects()
- {
- var array = new int[256];
- Read(array); // no side effects
- Contract.Assert(array[10] == 0); // true
- Contract.Assert(array[12] == 1); // false
- }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven: input != null", PrimaryILOffset = 7, MethodILOffset = 13)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 25, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = @"assert is false", PrimaryILOffset = 37, MethodILOffset = 0)]
+ public void CallWithNoSideEffects()
+ {
+ var array = new int[256];
+ Read(array); // no side effects
+ Contract.Assert(array[10] == 0); // true
+ Contract.Assert(array[12] == 1); // false
+ }
- [Pure]
- private void Read(int[] input)
- {
- Contract.Requires(input != null);
- for (var i = 0; i < input.Length; i++)
- {
- Console.WriteLine(i);
- }
- }
+ [Pure]
+ private void Read(int[] input)
+ {
+ Contract.Requires(input != null);
+ for (var i = 0; i < input.Length; i++)
+ {
+ Console.WriteLine(i);
+ }
+ }
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=37,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=53,MethodILOffset=0)]
- public void CallWithMixedEffects()
- {
- var read = new int[256];
- var write = new int[1024];
- Read(read, write); // no side effects on read
- Contract.Assert(read[10] == 0); // true
- Contract.Assert(write[12] == 1111); // true, we cannot prove it because we do not propagate ForAll arguments, so top is ok.
- }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 37, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 53, MethodILOffset = 0)]
+ public void CallWithMixedEffects()
+ {
+ var read = new int[256];
+ var write = new int[1024];
+ Read(read, write); // no side effects on read
+ Contract.Assert(read[10] == 0); // true
+ Contract.Assert(write[12] == 1111); // true, we cannot prove it because we do not propagate ForAll arguments, so top is ok.
+ }
- // read is not annotated to not be modified
- private void Read([Pure] int[] read, int[] write)
- {
- var sum = 0;
- for (var i = 0; i < read.Length; i++)
- {
- sum += read[i];
- }
-
- for (var i = 0; i < write.Length; i++)
- {
- write[i] = 1111;
- }
+ // read is not annotated to not be modified
+ private void Read([Pure] int[] read, int[] write)
+ {
+ var sum = 0;
+ for (var i = 0; i < read.Length; i++)
+ {
+ sum += read[i];
+ }
+
+ for (var i = 0; i < write.Length; i++)
+ {
+ write[i] = 1111;
+ }
+ }
}
- }
}
namespace OutRefParameters
{
- public class TestCases
- {
- [ClousotRegressionTest]
+ public class TestCases
+ {
+ [ClousotRegressionTest]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: collection != null (collection)",PrimaryILOffset=17,MethodILOffset=47)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: predicate != null (predicate)",PrimaryILOffset=39,MethodILOffset=47)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=3,MethodILOffset=47)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=25,MethodILOffset=47)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=22,MethodILOffset=47)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=44,MethodILOffset=47)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 22, MethodILOffset = 47)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 47)]
#endif
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=52,MethodILOffset=0)]
- public static void Example()
- {
- int[] myArray = new int[100];
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 52, MethodILOffset = 0)]
+ public static void Example()
+ {
+ int[] myArray = new int[100];
- WriteSomething(myArray[10]);
+ WriteSomething(myArray[10]);
- Contract.Assert(Contract.ForAll(myArray, el => el == 0)); // true
- }
+ Contract.Assert(Contract.ForAll(myArray, el => el == 0)); // true
+ }
- [ClousotRegressionTest]
+ [ClousotRegressionTest]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: collection != null (collection)",PrimaryILOffset=17,MethodILOffset=51)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: predicate != null (predicate)",PrimaryILOffset=39,MethodILOffset=51)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=3,MethodILOffset=51)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=25,MethodILOffset=51)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=22,MethodILOffset=51)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=44,MethodILOffset=51)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 22, MethodILOffset = 51)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 51)]
#endif
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=56,MethodILOffset=0)]
- public static void ExampleWithRef()
- {
- int[] myArray = new int[100];
-
- WriteSomething(ref myArray[10]);
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 56, MethodILOffset = 0)]
+ public static void ExampleWithRef()
+ {
+ int[] myArray = new int[100];
- Contract.Assert(Contract.ForAll(myArray, el => el == 0)); // top
- }
+ WriteSomething(ref myArray[10]);
+
+ Contract.Assert(Contract.ForAll(myArray, el => el == 0)); // top
+ }
- [ClousotRegressionTest]
+ [ClousotRegressionTest]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: collection != null (collection)",PrimaryILOffset=17,MethodILOffset=51)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: predicate != null (predicate)",PrimaryILOffset=39,MethodILOffset=51)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=3,MethodILOffset=51)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=25,MethodILOffset=51)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=22,MethodILOffset=51)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=44,MethodILOffset=51)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 22, MethodILOffset = 51)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 51)]
#endif
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=56,MethodILOffset=0)]
- public static void ExampleWithOut()
- {
- int[] myArray = new int[100];
-
- WriteSomethingOut(out myArray[10]);
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 56, MethodILOffset = 0)]
+ public static void ExampleWithOut()
+ {
+ int[] myArray = new int[100];
- Contract.Assert(Contract.ForAll(myArray, el => el == 0)); // top
+ WriteSomethingOut(out myArray[10]);
- }
+ Contract.Assert(Contract.ForAll(myArray, el => el == 0)); // top
+ }
- private static void WriteSomething(int x)
- {
- x = DateTime.Now.Millisecond;
- }
+ private static void WriteSomething(int x)
+ {
+ x = DateTime.Now.Millisecond;
+ }
- private static void WriteSomething(ref int x)
- {
- x = DateTime.Now.Millisecond;
- }
+ private static void WriteSomething(ref int x)
+ {
+ x = DateTime.Now.Millisecond;
+ }
- private static void WriteSomethingOut(out int x)
- {
- x = DateTime.Now.Millisecond;
+ private static void WriteSomethingOut(out int x)
+ {
+ x = DateTime.Now.Millisecond;
+ }
}
- }
}
namespace SymbolicPropagationOfConditions
{
- public class Tests
- {
- [ClousotRegressionTest]
-
+ public class Tests
+ {
+ [ClousotRegressionTest]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=13,MethodILOffset=78)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: predicate != null (predicate)",PrimaryILOffset=35,MethodILOffset=78)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=3,MethodILOffset=78)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=25,MethodILOffset=78)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=78)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=44,MethodILOffset=78)]
- #endif
-#endif
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=83,MethodILOffset=0)]
- static public int[] Filter(int[] origin)
- {
- var result = new int[origin.Length];
- int j = 0;
- for (int i = 0; i < origin.Length; i++)
- {
- // This expression is outside the expressivity of Clousot numerical domains, but we propagate it symbolically anyway
- if (origin[i] % 2345 + 2== 0)
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 78)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 78)]
+#endif
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 83, MethodILOffset = 0)]
+ public static int[] Filter(int[] origin)
{
- result[j] = origin[i];
- j++;
- }
- }
+ var result = new int[origin.Length];
+ int j = 0;
+ for (int i = 0; i < origin.Length; i++)
+ {
+ // This expression is outside the expressivity of Clousot numerical domains, but we propagate it symbolically anyway
+ if (origin[i]%2345 + 2 == 0)
+ {
+ result[j] = origin[i];
+ j++;
+ }
+ }
- Contract.Assert(Contract.ForAll(0, j, indx => result[indx] % 2345 + 2 == 0));
+ Contract.Assert(Contract.ForAll(0, j, indx => result[indx]%2345 + 2 == 0));
- return result;
+ return result;
+ }
}
- }
}
namespace Disequalities
{
public class Search
- {
- [ClousotRegressionTest]
+ {
+ [ClousotRegressionTest]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=17,MethodILOffset=96)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: predicate != null (predicate)",PrimaryILOffset=39,MethodILOffset=96)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=3,MethodILOffset=96)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=25,MethodILOffset=96)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=96)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=44,MethodILOffset=96)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 96)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 96)]
#endif
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=36,MethodILOffset=72)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"ensures is valid",PrimaryILOffset=51,MethodILOffset=72)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=101,MethodILOffset=0)]
- public int LinearSearch(int[] a, int value)
- {
- Contract.Requires(a != null);
-
- Contract.Ensures(Contract.Result() >= 0);
- Contract.Ensures(Contract.Result() < a.Length);
-
- for (var i = 0; i < a.Length; i++)
- {
- if (a[i] == value)
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 36, MethodILOffset = 72)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"ensures is valid", PrimaryILOffset = 51, MethodILOffset = 72)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 101, MethodILOffset = 0)]
+ public int LinearSearch(int[] a, int value)
{
- return i;
- }
- }
+ Contract.Requires(a != null);
+
+ Contract.Ensures(Contract.Result() >= 0);
+ Contract.Ensures(Contract.Result() < a.Length);
+
+ for (var i = 0; i < a.Length; i++)
+ {
+ if (a[i] == value)
+ {
+ return i;
+ }
+ }
- Contract.Assert(Contract.ForAll(a, el => el != value)); // if we reach this point, no element was found
+ Contract.Assert(Contract.ForAll(a, el => el != value)); // if we reach this point, no element was found
- throw new Exception();
+ throw new Exception();
+ }
}
- }
}
namespace FromMsCorlib
{
- public class SomeByteManipulation
- {
- [ClousotRegressionTest]
+ public class SomeByteManipulation
+ {
+ [ClousotRegressionTest]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=13,MethodILOffset=196)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven: predicate != null (predicate)",PrimaryILOffset=35,MethodILOffset=196)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=3,MethodILOffset=196)]
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=25,MethodILOffset=196)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=22,MethodILOffset=196)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"requires unproven",PrimaryILOffset=44,MethodILOffset=196)]
- #endif
-#endif
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=201,MethodILOffset=0)]
- private void MarshalHeader(byte[] binaryForm, int offset)
- {
- Contract.Requires(offset >= 0);
- Contract.Requires(offset + 8 < binaryForm.Length);
-
- Contract.Requires(Contract.ForAll(binaryForm, b => b < 10));
-
- binaryForm[offset] = 11;
- binaryForm[offset + 1] = 10;
- binaryForm[offset + 2] = 13;
- binaryForm[offset + 3] = 14;
- binaryForm[offset + 4] = 10;
- binaryForm[offset + 5] = 11;
- binaryForm[offset + 6] = 10;
- binaryForm[offset + 7] = 10;
-
- Contract.Assert(Contract.ForAll(0, offset, i => binaryForm[i] < 10)); // So we know we had the elements up to offset are untouched
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 22, MethodILOffset = 196)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"requires unproven", PrimaryILOffset = 44, MethodILOffset = 196)]
+#endif
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 201, MethodILOffset = 0)]
+ private void MarshalHeader(byte[] binaryForm, int offset)
+ {
+ Contract.Requires(offset >= 0);
+ Contract.Requires(offset + 8 < binaryForm.Length);
+
+ Contract.Requires(Contract.ForAll(binaryForm, b => b < 10));
+
+ binaryForm[offset] = 11;
+ binaryForm[offset + 1] = 10;
+ binaryForm[offset + 2] = 13;
+ binaryForm[offset + 3] = 14;
+ binaryForm[offset + 4] = 10;
+ binaryForm[offset + 5] = 11;
+ binaryForm[offset + 6] = 10;
+ binaryForm[offset + 7] = 10;
+
+ Contract.Assert(Contract.ForAll(0, offset, i => binaryForm[i] < 10)); // So we know we had the elements up to offset are untouched
+ }
}
- }
}
namespace FalseRepro
@@ -1569,8 +1564,8 @@ public class Repro
[RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=23,MethodILOffset=0)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=34,MethodILOffset=0)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=27,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=38,MethodILOffset=0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 27, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 38, MethodILOffset = 0)]
#endif
public byte[] RemoveWhiteSpace(byte[] data1)
{
@@ -1581,13 +1576,13 @@ public byte[] RemoveWhiteSpace(byte[] data1)
var data = new byte[j];
for (int idx = 0; idx < data.Length; idx++)
{
- Contract.Assert(j== data.Length);
- // var tmp = temp[idx];
+ Contract.Assert(j == data.Length);
+ // var tmp = temp[idx];
Contract.Assert(idx < data.Length); // We used to say false at this exp, because they array analysis thought we entered the loop at the first iteration (when j == 0)
- //data[idx] = 0;
+ //data[idx] = 0;
}
}
return data1;
}
}
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/Containers/TestContainers/Enumerables.cs b/Microsoft.Research/RegressionTest/Containers/TestContainers/Enumerables.cs
index e3aa4a98..0ee6d66f 100644
--- a/Microsoft.Research/RegressionTest/Containers/TestContainers/Enumerables.cs
+++ b/Microsoft.Research/RegressionTest/Containers/TestContainers/Enumerables.cs
@@ -19,316 +19,312 @@
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
+
using Microsoft.Research.ClousotRegression;
namespace EnumerablesNonNull
{
- public class EnumerablesBasic
- {
- // can't deal with assumption aggregation yet
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="Possibly calling a method on a null reference 'args'",PrimaryILOffset=1,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=29,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=10,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=49,MethodILOffset=55)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=56,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=87,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=67,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=111,MethodILOffset=117)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="assert unproven",PrimaryILOffset=80,MethodILOffset=0)]
- public static void Start(IEnumerable args)
- {
- foreach (var arg in args) {
- Contract.Assume(arg != null);
- }
-
- foreach (var arg in args)
- {
- Contract.Assert(arg != null);
- }
- }
-
- }
-
- public class AssumeForAll
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=53,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=81,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=62,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=94,MethodILOffset=100)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=75,MethodILOffset=0)]
- public static void NonNull_OK(System.Collections.Generic.IEnumerable s)
- {
- Contract.Requires(s != null);
- Contract.Requires(Contract.ForAll(s, arg => arg != null));
-
- foreach (var arg in s)
- {
- Contract.Assert(arg != null);
- }
- }
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=53,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=83,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=63,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=76,MethodILOffset=0)]
- public void NonNullList(System.Collections.Generic.List xs)
- {
- Contract.Requires(xs != null);
- Contract.Requires(Contract.ForAll(xs, i => i != null));
-
- foreach (var x in xs)
- {
-
- Contract.Assert(x != null);
- }
- }
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=53,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=81,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=62,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=94,MethodILOffset=100)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=75,MethodILOffset=0)]
- public void NonNullCollection(System.Collections.Generic.ICollection xs)
+ public class EnumerablesBasic
{
- Contract.Requires(xs != null);
- Contract.Requires(Contract.ForAll(xs, i => i != null));
-
- foreach (var x in xs)
- {
-
- Contract.Assert(x != null);
- }
+ // can't deal with assumption aggregation yet
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference 'args'", PrimaryILOffset = 1, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 29, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 10, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 49, MethodILOffset = 55)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 56, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 87, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 67, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 111, MethodILOffset = 117)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "assert unproven", PrimaryILOffset = 80, MethodILOffset = 0)]
+ public static void Start(IEnumerable args)
+ {
+ foreach (var arg in args)
+ {
+ Contract.Assume(arg != null);
+ }
+
+ foreach (var arg in args)
+ {
+ Contract.Assert(arg != null);
+ }
+ }
}
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=53,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=69,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=76,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=13,MethodILOffset=69)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=33,MethodILOffset=69)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=13,MethodILOffset=76)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=33,MethodILOffset=76)]
- [RegressionOutcome(Outcome=ProofOutcome.False,Message="assert is false",PrimaryILOffset=87,MethodILOffset=0)]
- public void NonNullListAssigned1(System.Collections.Generic.List xs)
+ public class AssumeForAll
{
- Contract.Requires(xs != null);
- Contract.Requires(Contract.ForAll(xs, i => i != null));
- Contract.Requires(xs.Count > 5);
-
- xs[3] = null;
-
- Contract.Assert(xs[3] != null); // must be false
- }
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=53,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=69,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=13,MethodILOffset=69)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=33,MethodILOffset=69)]
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 53, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 81, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 62, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 94, MethodILOffset = 100)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 75, MethodILOffset = 0)]
+ public static void NonNull_OK(System.Collections.Generic.IEnumerable s)
+ {
+ Contract.Requires(s != null);
+ Contract.Requires(Contract.ForAll(s, arg => arg != null));
+
+ foreach (var arg in s)
+ {
+ Contract.Assert(arg != null);
+ }
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 53, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 83, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 63, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 76, MethodILOffset = 0)]
+ public void NonNullList(System.Collections.Generic.List xs)
+ {
+ Contract.Requires(xs != null);
+ Contract.Requires(Contract.ForAll(xs, i => i != null));
+
+ foreach (var x in xs)
+ {
+ Contract.Assert(x != null);
+ }
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 53, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 81, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 62, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 94, MethodILOffset = 100)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 75, MethodILOffset = 0)]
+ public void NonNullCollection(System.Collections.Generic.ICollection xs)
+ {
+ Contract.Requires(xs != null);
+ Contract.Requires(Contract.ForAll(xs, i => i != null));
+
+ foreach (var x in xs)
+ {
+ Contract.Assert(x != null);
+ }
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 53, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 69, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 76, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 13, MethodILOffset = 69)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 33, MethodILOffset = 69)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 13, MethodILOffset = 76)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 33, MethodILOffset = 76)]
+ [RegressionOutcome(Outcome = ProofOutcome.False, Message = "assert is false", PrimaryILOffset = 87, MethodILOffset = 0)]
+ public void NonNullListAssigned1(System.Collections.Generic.List xs)
+ {
+ Contract.Requires(xs != null);
+ Contract.Requires(Contract.ForAll(xs, i => i != null));
+ Contract.Requires(xs.Count > 5);
+
+ xs[3] = null;
+
+ Contract.Assert(xs[3] != null); // must be false
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 53, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 69, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 13, MethodILOffset = 69)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 33, MethodILOffset = 69)]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=17,MethodILOffset=104)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=39,MethodILOffset=104)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=3,MethodILOffset=104)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=25,MethodILOffset=104)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=22,MethodILOffset=104)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=44,MethodILOffset=104)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 22, MethodILOffset = 104)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 44, MethodILOffset = 104)]
#endif
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="assert unproven",PrimaryILOffset=109,MethodILOffset=0)]
- public void NonNullListAssigned2(System.Collections.Generic.List xs)
- {
- Contract.Requires(xs != null);
- Contract.Requires(Contract.ForAll(xs, i => i != null));
- Contract.Requires(xs.Count > 5);
-
- xs[3] = null;
-
- Contract.Assert(Contract.ForAll(xs, i=> i != null)); // must be unproven
- }
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=53,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=69,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=75,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=105,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=85,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=13,MethodILOffset=69)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=33,MethodILOffset=69)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="assert unproven",PrimaryILOffset=98,MethodILOffset=0)]
- public void NonNullListAssigned3(System.Collections.Generic.List xs)
- {
- Contract.Requires(xs != null);
- Contract.Requires(Contract.ForAll(xs, i => i != null));
- Contract.Requires(xs.Count > 5);
-
- xs[3] = null;
-
- foreach (var x in xs)
- {
- Contract.Assert(x != null); // must be unproven
- }
- }
-
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=36,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=69,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=45,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=82,MethodILOffset=88)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=63,MethodILOffset=0)]
- public static void NonNullGeneric_OK(System.Collections.Generic.IEnumerable s) where T:class
- {
- Contract.Requires(s != null);
- Contract.Requires(Contract.ForAll(s, arg => arg != null));
-
- foreach (var arg in s)
- {
- Contract.Assert(arg != null);
- }
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "assert unproven", PrimaryILOffset = 109, MethodILOffset = 0)]
+ public void NonNullListAssigned2(System.Collections.Generic.List xs)
+ {
+ Contract.Requires(xs != null);
+ Contract.Requires(Contract.ForAll(xs, i => i != null));
+ Contract.Requires(xs.Count > 5);
+
+ xs[3] = null;
+
+ Contract.Assert(Contract.ForAll(xs, i => i != null)); // must be unproven
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 53, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 69, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 75, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 105, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 85, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 13, MethodILOffset = 69)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 33, MethodILOffset = 69)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "assert unproven", PrimaryILOffset = 98, MethodILOffset = 0)]
+ public void NonNullListAssigned3(System.Collections.Generic.List xs)
+ {
+ Contract.Requires(xs != null);
+ Contract.Requires(Contract.ForAll(xs, i => i != null));
+ Contract.Requires(xs.Count > 5);
+
+ xs[3] = null;
+
+ foreach (var x in xs)
+ {
+ Contract.Assert(x != null); // must be unproven
+ }
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 36, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 69, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 45, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 82, MethodILOffset = 88)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 63, MethodILOffset = 0)]
+ public static void NonNullGeneric_OK(System.Collections.Generic.IEnumerable s) where T : class
+ {
+ Contract.Requires(s != null);
+ Contract.Requires(Contract.ForAll(s, arg => arg != null));
+
+ foreach (var arg in s)
+ {
+ Contract.Assert(arg != null);
+ }
+ }
+
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 53, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 78, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 62, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 91, MethodILOffset = 97)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 72, MethodILOffset = 0)]
+ // Now it passes, thanks to the improved handling of box instructions
+ public static void Positive_OK(System.Collections.Generic.IEnumerable s)
+ {
+ Contract.Requires(s != null);
+ Contract.Requires(Contract.ForAll(s, arg => arg > 0));
+
+ foreach (var arg in s)
+ {
+ Contract.Assert(arg > 0);
+ }
+ }
}
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=53,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=78,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=62,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="valid non-null reference (as receiver)",PrimaryILOffset=91,MethodILOffset=97)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=72,MethodILOffset=0)]
- // Now it passes, thanks to the improved handling of box instructions
- public static void Positive_OK(System.Collections.Generic.IEnumerable s)
+ public class AssertForAll
{
- Contract.Requires(s != null);
- Contract.Requires(Contract.ForAll(s, arg => arg > 0));
-
- foreach (var arg in s)
- {
- Contract.Assert(arg > 0);
- }
- }
-
- }
-
- public class AssertForAll
- {
- [ClousotRegressionTest]
+ [ClousotRegressionTest]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven: collection != null (collection)",PrimaryILOffset=17,MethodILOffset=36)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=39,MethodILOffset=36)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=3,MethodILOffset=36)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=25,MethodILOffset=36)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=22,MethodILOffset=36)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=44,MethodILOffset=36)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "requires unproven", PrimaryILOffset = 22, MethodILOffset = 36)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 44, MethodILOffset = 36)]
#endif
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=41,MethodILOffset=0)]
- public void NotNullGeneric(System.Collections.Generic.IEnumerable s) where T:class
- {
- Contract.Requires(Contract.ForAll(s, arg => arg != null));
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 41, MethodILOffset = 0)]
+ public void NotNullGeneric(System.Collections.Generic.IEnumerable s) where T : class
+ {
+ Contract.Requires(Contract.ForAll(s, arg => arg != null));
- Contract.Assert(Contract.ForAll(s, arg => arg != null));
- }
+ Contract.Assert(Contract.ForAll(s, arg => arg != null));
+ }
- [ClousotRegressionTest]
+ [ClousotRegressionTest]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven: collection != null (collection)",PrimaryILOffset=17,MethodILOffset=70)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=39,MethodILOffset=70)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=3,MethodILOffset=70)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=25,MethodILOffset=70)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=22,MethodILOffset=70)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=44,MethodILOffset=70)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "requires unproven", PrimaryILOffset = 22, MethodILOffset = 70)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 44, MethodILOffset = 70)]
#endif
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=75,MethodILOffset=0)]
- public void NotNull(System.Collections.Generic.IEnumerable s)
- {
- Contract.Requires(Contract.ForAll(s, arg => arg != null));
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 75, MethodILOffset = 0)]
+ public void NotNull(System.Collections.Generic.IEnumerable s)
+ {
+ Contract.Requires(Contract.ForAll(s, arg => arg != null));
- Contract.Assert(Contract.ForAll(s, arg => arg != null));
- }
+ Contract.Assert(Contract.ForAll(s, arg => arg != null));
+ }
- [ClousotRegressionTest]
+ [ClousotRegressionTest]
#if NETFRAMEWORK_4_0
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven: collection != null (collection)",PrimaryILOffset=17,MethodILOffset=70)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=39,MethodILOffset=70)]
#else
- #if CLOUSOT2
+#if CLOUSOT2
[RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=3,MethodILOffset=70)]
[RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=25,MethodILOffset=70)]
#else
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message="requires unproven",PrimaryILOffset=22,MethodILOffset=70)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="requires is valid",PrimaryILOffset=44,MethodILOffset=70)]
- #endif
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "requires unproven", PrimaryILOffset = 22, MethodILOffset = 70)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "requires is valid", PrimaryILOffset = 44, MethodILOffset = 70)]
#endif
- [RegressionOutcome(Outcome=ProofOutcome.True,Message="assert is valid",PrimaryILOffset=75,MethodILOffset=0)]
- public void Positive(System.Collections.Generic.IEnumerable s)
- {
- Contract.Requires(Contract.ForAll(s, arg => arg > 0));
+#endif
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 75, MethodILOffset = 0)]
+ public void Positive(System.Collections.Generic.IEnumerable s)
+ {
+ Contract.Requires(Contract.ForAll(s, arg => arg > 0));
- Contract.Assert(Contract.ForAll(s, arg => arg > 0));
+ Contract.Assert(Contract.ForAll(s, arg => arg > 0));
+ }
}
-
- }
-
}
namespace Repros
{
- public class ArrayLength
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=8,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=15,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"Possible use of a null array 'xs'",PrimaryILOffset=20,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=8,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=45,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=50,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=87,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=92,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as field receiver)",PrimaryILOffset=68,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"valid non-null reference (as array)",PrimaryILOffset=74,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven",PrimaryILOffset=112,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"requires is valid",PrimaryILOffset=7,MethodILOffset=75)]
- [RegressionOutcome(Outcome=ProofOutcome.True,Message=@"assert is valid",PrimaryILOffset=100,MethodILOffset=0)]
- [RegressionOutcome(Outcome=ProofOutcome.Top,Message=@"assert unproven. Is it an off-by-one? The static checker can prove xs.Length > (0 - 1) instead",PrimaryILOffset=55,MethodILOffset=0)]
- public static object JoinAll(object[] xs)
- {
- Contract.Requires(Contract.ForAll(0, xs.Length, j => xs[j] != null));
-
- Contract.Assert(xs.Length > 0); // It's not always true...
-
- object result = null;
-
- int i;
- for (i = 0; i < xs.Length; i++)
- {
- result = Join(result, xs[i]);
- }
-
- Contract.Assert(i > 0); // We need wp to prove it
-
- Contract.Assert(result != null); // Ok
-
- return result;
- }
-
- [ContractVerification(false)]
- public static object Join(object x, object y)
+ public class ArrayLength
{
- Contract.Requires(y != null);
- Contract.Ensures(Contract.Result() != null);
-
- return y;
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 15, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"Possible use of a null array 'xs'", PrimaryILOffset = 20, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 45, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 50, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 87, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 92, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as field receiver)", PrimaryILOffset = 68, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"valid non-null reference (as array)", PrimaryILOffset = 74, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 112, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"requires is valid", PrimaryILOffset = 7, MethodILOffset = 75)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 100, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven. Is it an off-by-one? The static checker can prove xs.Length > (0 - 1) instead", PrimaryILOffset = 55, MethodILOffset = 0)]
+ public static object JoinAll(object[] xs)
+ {
+ Contract.Requires(Contract.ForAll(0, xs.Length, j => xs[j] != null));
+
+ Contract.Assert(xs.Length > 0); // It's not always true...
+
+ object result = null;
+
+ int i;
+ for (i = 0; i < xs.Length; i++)
+ {
+ result = Join(result, xs[i]);
+ }
+
+ Contract.Assert(i > 0); // We need wp to prove it
+
+ Contract.Assert(result != null); // Ok
+
+ return result;
+ }
+
+ [ContractVerification(false)]
+ public static object Join(object x, object y)
+ {
+ Contract.Requires(y != null);
+ Contract.Ensures(Contract.Result() != null);
+
+ return y;
+ }
}
- }
}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/TestFrameworkOOB/Purity.cs b/Microsoft.Research/RegressionTest/TestFrameworkOOB/Purity.cs
index 10e7e624..26c4ff53 100644
--- a/Microsoft.Research/RegressionTest/TestFrameworkOOB/Purity.cs
+++ b/Microsoft.Research/RegressionTest/TestFrameworkOOB/Purity.cs
@@ -17,60 +17,61 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+
using Microsoft.Research.ClousotRegression;
namespace TestFrameworkOOB.Purity
{
- class Tests
- {
- [ClousotRegressionTest]
- public static void Test(object a, object b)
+ internal class Tests
{
- Contract.Requires(Object.ReferenceEquals(a, b));
-
- }
+ [ClousotRegressionTest]
+ public static void Test(object a, object b)
+ {
+ Contract.Requires(ReferenceEquals(a, b));
+ }
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference \'dict\'", PrimaryILOffset = 3, MethodILOffset = 0), RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 16, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 21, MethodILOffset = 0)]
- public static void Test(IDictionary dict, int key)
- {
- Contract.Requires(dict.ContainsKey(key));
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference \'dict\'", PrimaryILOffset = 3, MethodILOffset = 0), RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 16, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 21, MethodILOffset = 0)]
+ public static void Test(IDictionary dict, int key)
+ {
+ Contract.Requires(dict.ContainsKey(key));
- Contract.Assert(dict.ContainsKey(key));
+ Contract.Assert(dict.ContainsKey(key));
+ }
}
- }
- interface J { }
-
- class TypeMethodPurity : J
- {
- void Get(Type messageType)
+ internal interface J
{
- Contract.Requires(messageType != null && typeof(J).IsAssignableFrom(messageType));
}
- void Foo()
+ internal class TypeMethodPurity : J
{
- J message = new TypeMethodPurity();
- Type t = message.GetType();
- Contract.Assert(t != null);
- Contract.Assume(t == typeof(TypeMethodPurity));
- Contract.Assume(typeof(J).IsAssignableFrom(typeof(TypeMethodPurity)));
- Contract.Assume(typeof(J).IsAssignableFrom(t));
- }
+ private void Get(Type messageType)
+ {
+ Contract.Requires(messageType != null && typeof (J).IsAssignableFrom(messageType));
+ }
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 25, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 47, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 52, MethodILOffset = 0)]
- void Bar(Type t)
- {
- Contract.Requires(t != null);
- Contract.Requires(typeof(J).IsAssignableFrom(t));
+ private void Foo()
+ {
+ J message = new TypeMethodPurity();
+ Type t = message.GetType();
+ Contract.Assert(t != null);
+ Contract.Assume(t == typeof (TypeMethodPurity));
+ Contract.Assume(typeof (J).IsAssignableFrom(typeof (TypeMethodPurity)));
+ Contract.Assume(typeof (J).IsAssignableFrom(t));
+ }
- Contract.Assert(typeof(J).IsAssignableFrom(t));
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 25, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 47, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 52, MethodILOffset = 0)]
+ private void Bar(Type t)
+ {
+ Contract.Requires(t != null);
+ Contract.Requires(typeof (J).IsAssignableFrom(t));
+ Contract.Assert(typeof (J).IsAssignableFrom(t));
+ }
}
- }
-}
+}
\ No newline at end of file
diff --git a/Microsoft.Research/RegressionTest/TestFrameworkOOB/ReferenceToAllOOBC.cs b/Microsoft.Research/RegressionTest/TestFrameworkOOB/ReferenceToAllOOBC.cs
index 6cf12eb4..291f14c4 100644
--- a/Microsoft.Research/RegressionTest/TestFrameworkOOB/ReferenceToAllOOBC.cs
+++ b/Microsoft.Research/RegressionTest/TestFrameworkOOB/ReferenceToAllOOBC.cs
@@ -22,94 +22,96 @@
using System.Net.Mail;
using System.Security.Cryptography.X509Certificates;
using System.Windows;
-using Microsoft.Research.ClousotRegression;
-
-namespace ReferenceAllOOBC {
+using Microsoft.Research.ClousotRegression;
- class TestMicrosoftVisualBasic
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 15, MethodILOffset = 0)]
- public static void Test1(string str)
+namespace ReferenceAllOOBC
+{
+ internal class TestMicrosoftVisualBasic
{
- Contract.Assert(Microsoft.VisualBasic.Strings.Len(str) == str.Length);
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "valid non-null reference (as receiver)", PrimaryILOffset = 8, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 15, MethodILOffset = 0)]
+ public static void Test1(string str)
+ {
+ Contract.Assert(Microsoft.VisualBasic.Strings.Len(str) == str.Length);
+ }
}
- }
- class TestMscorlib
- {
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference \'array\'", PrimaryILOffset = 2, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 13, MethodILOffset = 0)]
- public static void Test1(Array array)
+ internal class TestMscorlib
{
- Contract.Assert(array.Rank >= 0);
- //Contract.Assert(((System.Collections.ICollection)array).Count == array.Length);
- }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference \'array\'", PrimaryILOffset = 2, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 13, MethodILOffset = 0)]
+ public static void Test1(Array array)
+ {
+ Contract.Assert(array.Rank >= 0);
+ //Contract.Assert(((System.Collections.ICollection)array).Count == array.Length);
+ }
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference 'e'", PrimaryILOffset = 2, MethodILOffset = 0)]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 13, MethodILOffset = 0)]
- public static void TestExceptionGetType(Exception e)
- {
- Contract.Assert(e.GetType() != null);
- }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.Top, Message = "Possibly calling a method on a null reference 'e'", PrimaryILOffset = 2, MethodILOffset = 0)]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = "assert is valid", PrimaryILOffset = 13, MethodILOffset = 0)]
+ public static void TestExceptionGetType(Exception e)
+ {
+ Contract.Assert(e.GetType() != null);
+ }
- [ClousotRegressionTest]
- [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 12, MethodILOffset = 0)]
- public static void Test2()
- {
- Contract.Assert(System.Collections.Generic.EqualityComparer.Default != null);
- }
+ [ClousotRegressionTest]
+ [RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 12, MethodILOffset = 0)]
+ public static void Test2()
+ {
+ Contract.Assert(EqualityComparer