diff --git a/Source/Core/Testing/Interleaving/PartialOrderSamplingStrategy.cs b/Source/Core/Testing/Interleaving/PartialOrderSamplingStrategy.cs index b71167fe..ab2bdb9e 100644 --- a/Source/Core/Testing/Interleaving/PartialOrderSamplingStrategy.cs +++ b/Source/Core/Testing/Interleaving/PartialOrderSamplingStrategy.cs @@ -62,13 +62,16 @@ namespace Microsoft.Coyote.Testing.Interleaving if (Debug.IsEnabled) { Debug.WriteLine($" {prioritized} and {op} are racing."); - Debug.WriteLine($" Resetting priority of {op.Group}."); + Debug.WriteLine($" Resetting priority of {op}."); } this.PrioritizedOperations.Remove(op); } } + this.PrioritizedOperations.Remove(prioritized); + Debug.WriteLine($" Resetting priority of {prioritized}."); + next = ops.First(op => op == prioritized); return true; } @@ -106,7 +109,7 @@ namespace Microsoft.Coyote.Testing.Interleaving foreach (var op in ops.Where(o => !this.PrioritizedOperations.Contains(o))) { // Randomly choose a priority for this operation. - int index = this.RandomValueGenerator.Next(this.PrioritizedOperations.Count) + 1; + int index = this.RandomValueGenerator.Next(this.PrioritizedOperations.Count + 1); this.PrioritizedOperations.Insert(index, op); Debug.WriteLine(" Assigned priority '{0}' for operation '{1}'.", index, op); } diff --git a/Source/Core/Testing/Interleaving/PrioritizationStrategy.cs b/Source/Core/Testing/Interleaving/PrioritizationStrategy.cs index ece8838d..7dd591e1 100644 --- a/Source/Core/Testing/Interleaving/PrioritizationStrategy.cs +++ b/Source/Core/Testing/Interleaving/PrioritizationStrategy.cs @@ -156,7 +156,7 @@ namespace Microsoft.Coyote.Testing.Interleaving foreach (var group in ops.Select(op => op.Group).Where(g => !this.PrioritizedOperationGroups.Contains(g))) { // Randomly choose a priority for this group. - int index = this.RandomValueGenerator.Next(this.PrioritizedOperationGroups.Count) + 1; + int index = this.RandomValueGenerator.Next(this.PrioritizedOperationGroups.Count + 1); this.PrioritizedOperationGroups.Insert(index, group); Debug.WriteLine("[coyote::strategy] Assigned priority '{0}' for operation group '{1}'.", index, group); }