Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into improve_mutation_of…
Browse files Browse the repository at this point in the history
…_directives
  • Loading branch information
dupdob committed Nov 22, 2024
2 parents da24233 + f7c0a71 commit df53cc3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1953,11 +1953,13 @@ public void ShouldProtectDirectives()
}";
var expected = @"public void SomeMethod() {if(StrykerNamespace.MutantControl.IsActive(0)){}else{
var x = 0;
if(StrykerNamespace.MutantControl.IsActive(1)){;}else{if(StrykerNamespace.MutantControl.IsActive(2)){ #if !DEBUG
#if !DEBUG
if(StrykerNamespace.MutantControl.IsActive(1)){;}else{if(StrykerNamespace.MutantControl.IsActive(2)){
x--;
}else{ #if !DEBUG
}else{
x++;
}} #endif
}}
#endif
}}";

ShouldMutateSourceInClassToExpected(source, expected);
Expand Down
17 changes: 10 additions & 7 deletions src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,20 +542,20 @@ private static StringBuilder BuildReferenceChoice(IEnumerable<string> projectRef

private sealed class DynamicEnumerableQueue<T>
{
private readonly Queue<T> _queue;
private readonly HashSet<T> _cache;
private readonly ConcurrentQueue<T> _queue;
private readonly ConcurrentDictionary<T, bool> _cache;

public DynamicEnumerableQueue(IEnumerable<T> init)
{
_cache = [.. init];
_queue = new Queue<T>(_cache);
_cache = new(init.ToDictionary(x => x, x => true));
_queue = new (_cache.Keys);
}

public bool Empty => _queue.Count == 0;
public bool Empty => _queue.IsEmpty;

public void Add(T entry)
{
if (!_cache.Add(entry))
if (!_cache.TryAdd(entry, true))
{
return;
}
Expand All @@ -566,7 +566,10 @@ public IEnumerable<T> Consume()
{
while (_queue.Count > 0)
{
yield return _queue.Dequeue();
if (_queue.TryDequeue(out var entry))
{
yield return entry;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static List<INodeOrchestrator> BuildOrchestratorList() =>
new MemberAccessExpressionOrchestrator<SimpleNameSyntax>(),
new MemberAccessExpressionOrchestrator<PostfixUnaryExpressionSyntax>(t =>
t.IsKind(SyntaxKind.SuppressNullableWarningExpression)),
// ensure patterhsyntax nodes are mutated (as they are neither expression nor statements, they are not mutated by default)
// ensure pattern syntax nodes are mutated (as they are neither expression nor statements, they are not mutated by default)
new NodeSpecificOrchestrator<PatternSyntax, PatternSyntax>(),
new NodeSpecificOrchestrator<SubpatternSyntax, SubpatternSyntax>(),
new ConditionalExpressionOrchestrator(),
Expand Down

0 comments on commit df53cc3

Please sign in to comment.