コード例 #1
0
        public void TestFieldAliasAccessAfterSend2Fail()
        {
            var test = @"
using Microsoft.PSharp;

namespace Foo {
class eUnit : Event
{
 public Letter Letter;
 
 public eUnit(Letter letter)
  : base()
 {
  this.Letter = letter;
 }
}

struct Letter
{
 public string Text;

 public Letter(string text)
 {
  this.Text = text;
 }
}

class M : Machine
{
 MachineId Target;
 Letter Letter;

 [Start]
 [OnEntry(nameof(FirstOnEntryAction))]
 class First : MachineState { }

 void FirstOnEntryAction()
 {
  this.Target = this.CreateMachine(typeof(M));
  this.Letter = new Letter(""London"");
  this.Send(this.Target, new eUnit(this.Letter));
  this.Foo();
 }

 void Foo()
 {
  this.Bar();
 }

 void Bar()
 {
  this.Letter.Text = ""text2""; // ERROR
 }
}
}";

            var configuration = Setup.GetConfiguration();

            configuration.DoStateTransitionAnalysis = false;
            Assert.Failed(configuration, test, 2, isPSharpProgram: false);
        }
コード例 #2
0
ファイル: FieldSendAliasTests.cs プロジェクト: p-org/PSharp
        public void TestFieldSendAlias1Fail()
        {
            var test = @"
using Microsoft.PSharp;

namespace Foo {
class eUnit : Event
{
 public Letter Letter;
 
 public eUnit(Letter letter)
  : base()
 {
  this.Letter = letter;
 }
}

struct Letter
{
 public string Text;
 public int Num;

 public Letter(string text, int num)
 {
  this.Text = text;
  this.Num = num;
 }
}

class M : Machine
{
 MachineId Target;
 Letter Letter;

 [Start]
 [OnEntry(nameof(FirstOnEntryAction))]
 class First : MachineState { }

 void FirstOnEntryAction()
 {
  var letter = new Letter(""test"", 0);
  this.Target = this.CreateMachine(typeof(M));
  this.Foo(letter);
  this.Send(this.Target, new eUnit(letter));
 }

 void Foo(Letter letter)
 {
  this.Letter = letter;
 }
}
}";

            var configuration = Setup.GetConfiguration();

            configuration.DoStateTransitionAnalysis = false;

            var error = "Error: Method 'FirstOnEntryAction' of machine 'Foo.M' sends " +
                        "'letter', which contains data from field 'letter'.";

            Assert.Failed(configuration, test, 1, error, isPSharpProgram: false);
        }
コード例 #3
0
ファイル: Assert.cs プロジェクト: notfarfromorion/PSharp
        internal static void Warning(string test, int numExpectedWarnings, string expectedOutput, bool isPSharpProgram = true)
        {
            var configuration = Setup.GetConfiguration();

            Warning(configuration, test, numExpectedWarnings, expectedOutput, isPSharpProgram);
        }
コード例 #4
0
ファイル: Assert.cs プロジェクト: notfarfromorion/PSharp
        internal static void Failed(string test, int numExpectedErrors, string expectedOutput, bool isPSharpProgram = true)
        {
            var configuration = Setup.GetConfiguration();

            Failed(configuration, test, numExpectedErrors, expectedOutput, isPSharpProgram);
        }
コード例 #5
0
ファイル: Assert.cs プロジェクト: notfarfromorion/PSharp
        internal static void Succeeded(string test, bool isPSharpProgram = true)
        {
            var configuration = Setup.GetConfiguration();

            Succeeded(configuration, test, isPSharpProgram);
        }
コード例 #6
0
ファイル: Assert.cs プロジェクト: notfarfromorion/PSharp
        internal static void FailedAndWarning(string test, int numExpectedErrors, int numExpectedWarnings, bool isPSharpProgram = true)
        {
            var configuration = Setup.GetConfiguration();

            FailedAndWarning(configuration, test, numExpectedErrors, numExpectedWarnings, isPSharpProgram);
        }