Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Add a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
wuestholz committed Jun 15, 2016
1 parent e904c8d commit 6cc1faf
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Microsoft.Research/RegressionTest/ClousotTests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ private static IEnumerable<Options> TestRunDataSource
references: new string[0],
libPaths: new string[0],
compilerCode: "CS");
yield return new Options(
sourceFile: @"Microsoft.Research\RegressionTest\MaxJoins\MaxJoins3.cs",
clousotOptions: @"-nobox -nologo -nopex -stats=!! -stats controller -suggest=!! -infer autopropertiesensures -infer methodensures -warninglevel full -assemblyMode=standard -wp=true -premode combined -adaptive -show validations -nonnull -bounds:type:Intervals -arithmetic:type:Intervals,obl=div0,obl=negMin,obl=floatEq,obl=divOverflow,obl=intOverflow -trace suspended -maxJoins 0",
useContractReferenceAssemblies: false,
useExe: false,
compilerOptions: @"/unsafe",
references: new string[0],
libPaths: new string[0],
compilerCode: "CS");
#endregion

#region MaxWidenings
Expand Down
81 changes: 81 additions & 0 deletions Microsoft.Research/RegressionTest/MaxJoins/MaxJoins3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// 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.Diagnostics.Contracts;
using Microsoft.Research.ClousotRegression;

namespace MaxJoins
{
public class MaxJoins
{
[ClousotRegressionTest]
[RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 12, MethodILOffset = 0)]
private void Test0(bool b)
{
string s = Foo(b);
Contract.Assert(s == null);
}

[ClousotRegressionTest]
[RegressionOutcome(Outcome = ProofOutcome.True, Message = @"assert is valid", PrimaryILOffset = 15, MethodILOffset = 0)]
private void Test1(int i)
{
string s = Bar(i);
Contract.Assert(s != null);
}

[ClousotRegressionTest]
[RegressionOutcome(Outcome = ProofOutcome.Top, Message = @"assert unproven", PrimaryILOffset = 15, MethodILOffset = 0)]
private void Test2(int i)
{
string s = FooBar(i);
Contract.Assert(s != null);
}

[ClousotRegressionTest]
private static string Foo(bool b)
{
string result = "non-null";
if (b) {
result = null;
}
return result;
}

[ClousotRegressionTest]
private static string Bar(int i)
{
string x = null;
if (i < 1) {
x = "non-null";
} else if (i < 3) {
x = Bar(i - 1);
}
return x;
}

[ClousotRegressionTest]
private static string FooBar(int i)
{
string x = null;
if (i < 3) {
x = FooBar(i - 1);
} else if (i < 1) {
x = "non-null";
}
return x;
}
}
}

0 comments on commit 6cc1faf

Please sign in to comment.