Skip to content

Commit

Permalink
fix: fix some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dupdob committed Nov 22, 2024
1 parent bfec606 commit 80871b8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
3 changes: 1 addition & 2 deletions docs/technical-reference/Mutation Orchestration Design.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ This class is used for several constructs:
- `AttributeListSyntax`: Attributes must be defined at compile time.
- `ParameterListSyntax`: Parameters and default values must be known at compile time.
- `EnumMemberSyntax`: Enumeration value must be known at compile time
- `RecursivePatternSyntax`: Pattern syntax must be known at compile time.
- `UsingDirectiveSyntax`: using directives are fixed and critical for compilation
- `UsingDirectiveSyntax`: using directives are fixed and critical for compilation
- `FieldDeclarationSyntax` (only const fields): cannot modify const fields at run time.
- `LocalDeclarationStatementSyntax` (only const): cannot modify constants at run time.

Expand Down
18 changes: 1 addition & 17 deletions src/Stryker.Core/Stryker.Core.UnitTest/AssertExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,7 @@ public static void ShouldBeSemantically(this SyntaxTree actual, SyntaxTree expec
Console.WriteLine(string.Join(Environment.NewLine, diff));

}

// find the different
var actualLines = actual.ToString().Split(Environment.NewLine);
var expectedLines = expected.ToString().Split(Environment.NewLine);
for (var i = 0; i < actualLines.Length; i++)
{
if (expectedLines.Length <= i)
{
isSame.ShouldBeTrue($"AST's are not equivalent. Line[{i + 1}]{Environment.NewLine}actual:{actualLines[i]}{Environment.NewLine}expect: nothing{Environment.NewLine}Actual(full):{Environment.NewLine}{actual}{Environment.NewLine}, expected:{Environment.NewLine}{expected}");
continue;
}
if (actualLines[i] != expectedLines[i])
{
isSame.ShouldBeTrue($"AST's are not equivalent. Line[{i + 1}]{Environment.NewLine}actual:{actualLines[i]}{Environment.NewLine}expect:{expectedLines[i]}{Environment.NewLine}Actual(full):{Environment.NewLine}{actual}{Environment.NewLine}, expected:{Environment.NewLine}{expected}");
}
}
}
}

private static List<string> ScanDiff(SyntaxNode actual, SyntaxNode expected)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mono.Cecil;
using Shouldly;
using Stryker.Abstractions;
using Stryker.Abstractions.Mutators;
Expand Down Expand Up @@ -1269,9 +1267,11 @@ public void ShouldNotAddReturnDefaultToAsyncTaskMethods()
;
}";
var expected = @"public async Task TestMethod()
{if(StrykerNamespace.MutantControl.IsActive(0)){}else{
{if(StrykerNamespace.MutantControl.IsActive(0)){}
else{
;
}}";
}
}";
ShouldMutateSourceInClassToExpected(source, expected);
}

Expand All @@ -1283,9 +1283,11 @@ public void ShouldNotAddReturnDefaultToMethodsWithReturnTypeVoid()
;
}";
var expected = @"void TestMethod()
{if(StrykerNamespace.MutantControl.IsActive(0)){}else{
{if(StrykerNamespace.MutantControl.IsActive(0)){}else
{
;
}}";
}
}";
ShouldMutateSourceInClassToExpected(source, expected);
}

Expand Down

0 comments on commit 80871b8

Please sign in to comment.