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); }
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); }
internal static void Warning(string test, int numExpectedWarnings, string expectedOutput, bool isPSharpProgram = true) { var configuration = Setup.GetConfiguration(); Warning(configuration, test, numExpectedWarnings, expectedOutput, isPSharpProgram); }
internal static void Failed(string test, int numExpectedErrors, string expectedOutput, bool isPSharpProgram = true) { var configuration = Setup.GetConfiguration(); Failed(configuration, test, numExpectedErrors, expectedOutput, isPSharpProgram); }
internal static void Succeeded(string test, bool isPSharpProgram = true) { var configuration = Setup.GetConfiguration(); Succeeded(configuration, test, isPSharpProgram); }
internal static void FailedAndWarning(string test, int numExpectedErrors, int numExpectedWarnings, bool isPSharpProgram = true) { var configuration = Setup.GetConfiguration(); FailedAndWarning(configuration, test, numExpectedErrors, numExpectedWarnings, isPSharpProgram); }