-
Notifications
You must be signed in to change notification settings - Fork 208
Decoupling file excludability from mutant spans #2645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
psfinaki
wants to merge
7
commits into
stryker-mutator:master
Choose a base branch
from
psfinaki:fsharp-20
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
754f469
Decoupling file excludability from mutant spans
psfinaki 8581c9b
Fix
psfinaki 0e7674f
up
psfinaki 8893c12
up
psfinaki c5a0720
A bunch of F# range math + range reduction
psfinaki 6c0f8db
moar range math
psfinaki 513cb37
up
psfinaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
335 changes: 335 additions & 0 deletions
335
src/Stryker.Core/Stryker.Core.UnitTest/Helpers/RangeHelperTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,335 @@ | ||
using System.Linq; | ||
using FSharp.Compiler.Text; | ||
using Shouldly; | ||
using Stryker.Core.Helpers; | ||
using Xunit; | ||
|
||
namespace Stryker.Core.UnitTest.Helpers | ||
{ | ||
public class RangeHelperTests : TestBase | ||
{ | ||
[Fact] | ||
public void IsEmpty_ZeroRange() | ||
{ | ||
var range = Range.Zero; | ||
|
||
range.IsEmpty().ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void IsEmpty_HollowRange() | ||
{ | ||
var range = GetRange((42, 42), (42, 42)); | ||
|
||
range.IsEmpty().ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void IsEmpty_NotEmptyRange() | ||
{ | ||
var range = GetRange((0, 0), (42, 42)); | ||
|
||
range.IsEmpty().ShouldBeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void Max_Greater() | ||
{ | ||
var position1 = PositionModule.mkPos(42, 42); | ||
var position2 = PositionModule.pos0; | ||
|
||
var actual = RangeHelper.Max(position1, position2); | ||
|
||
actual.ShouldBe(position1); | ||
} | ||
|
||
[Fact] | ||
public void Max_Equal() | ||
{ | ||
var position1 = PositionModule.pos0; | ||
var position2 = PositionModule.pos0; | ||
|
||
var actual = RangeHelper.Max(position1, position2); | ||
|
||
actual.ShouldBe(position1); | ||
} | ||
|
||
[Fact] | ||
public void Max_Less() | ||
{ | ||
var position1 = PositionModule.pos0; | ||
var position2 = PositionModule.mkPos(42, 42); | ||
|
||
var actual = RangeHelper.Max(position1, position2); | ||
|
||
actual.ShouldBe(position2); | ||
} | ||
|
||
[Fact] | ||
public void Min_Greater() | ||
{ | ||
var position1 = PositionModule.mkPos(42, 42); | ||
var position2 = PositionModule.pos0; | ||
|
||
var actual = RangeHelper.Min(position1, position2); | ||
|
||
actual.ShouldBe(position2); | ||
} | ||
|
||
[Fact] | ||
public void Min_Equal() | ||
{ | ||
var position1 = PositionModule.pos0; | ||
var position2 = PositionModule.pos0; | ||
|
||
var actual = RangeHelper.Min(position1, position2); | ||
|
||
actual.ShouldBe(position2); | ||
} | ||
|
||
[Fact] | ||
public void Min_Less() | ||
{ | ||
var position1 = PositionModule.pos0; | ||
var position2 = PositionModule.mkPos(42, 42); | ||
|
||
var actual = RangeHelper.Min(position1, position2); | ||
|
||
actual.ShouldBe(position1); | ||
} | ||
|
||
[Fact] | ||
public void OverlapsWith_Overlapping_Left() | ||
{ | ||
var range1 = GetRange((0, 0), (22, 22)); | ||
var range2 = GetRange((11, 11), (33, 33)); | ||
|
||
range1.OverlapsWith(range2).ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void OverlapsWith_Overlapping_Right() | ||
{ | ||
var range1 = GetRange((11, 11), (33, 33)); | ||
var range2 = GetRange((0, 0), (22, 22)); | ||
|
||
range1.OverlapsWith(range2).ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void OverlapsWith_Overlapping_Between() | ||
{ | ||
var range1 = GetRange((0, 0), (33, 33)); | ||
var range2 = GetRange((11, 11), (22, 22)); | ||
|
||
range1.OverlapsWith(range2).ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void OverlapsWith_NotOverlapping() | ||
{ | ||
var range1 = GetRange((0, 0), (11, 11)); | ||
var range2 = GetRange((22, 22), (33, 33)); | ||
|
||
range1.OverlapsWith(range2).ShouldBeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void OverlapsWith_Empty_Left() | ||
{ | ||
var range1 = GetRange((0, 0), (42, 42)); | ||
var range2 = Range.Zero; | ||
|
||
range1.OverlapsWith(range2).ShouldBeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void OverlapsWith_Empty_Right() | ||
{ | ||
var range1 = Range.Zero; | ||
var range2 = GetRange((0, 0), (42, 42)); | ||
|
||
range1.OverlapsWith(range2).ShouldBeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void OverlapsWith_Empty_Both() | ||
{ | ||
var range1 = Range.Zero; | ||
var range2 = Range.Zero; | ||
|
||
range1.OverlapsWith(range2).ShouldBeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void Overlap_Overlapping() | ||
{ | ||
var filePath = "test.fs"; | ||
|
||
var range1 = GetRange((0, 0), (22, 22)); | ||
var range2 = GetRange((11, 11), (33, 33)); | ||
var expectedOverlap = GetRange((11, 11), (22, 22)); | ||
|
||
range1.Overlap(range2, filePath).ShouldBe(expectedOverlap); | ||
} | ||
|
||
[Fact] | ||
public void Overlap_NotOverlapping() | ||
{ | ||
var filePath = "test.fs"; | ||
|
||
var range1 = GetRange((0, 0), (11, 11)); | ||
var range2 = GetRange((22, 22), (33, 33)); | ||
|
||
range1.Overlap(range2, filePath).ShouldBeNull(); | ||
} | ||
|
||
[Fact] | ||
public void IntersectsWith_Intersecting_Left() | ||
{ | ||
var range1 = GetRange((0, 0), (22, 22)); | ||
var range2 = GetRange((11, 11), (33, 33)); | ||
|
||
range1.IntersectsWith(range2).ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void IntersectsWith_Intersecting_Right() | ||
{ | ||
var range1 = GetRange((11, 11), (33, 33)); | ||
var range2 = GetRange((0, 0), (22, 22)); | ||
|
||
range1.IntersectsWith(range2).ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void IntersectsWith_Intersecting_Between() | ||
{ | ||
var range1 = GetRange((0, 0), (33, 33)); | ||
var range2 = GetRange((11, 11), (22, 22)); | ||
|
||
range1.IntersectsWith(range2).ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void IntersectsWith_NoIntersection() | ||
{ | ||
var range1 = GetRange((0, 0), (11, 11)); | ||
var range2 = GetRange((22, 22), (33, 33)); | ||
|
||
range1.IntersectsWith(range2).ShouldBeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void Reduce_Zero() | ||
{ | ||
var result = RangeHelper.Reduce("test.fs", Enumerable.Empty<Range>()); | ||
|
||
result.ShouldBeEmpty(); | ||
} | ||
|
||
[Fact] | ||
public void Reduce_One() | ||
{ | ||
var filePath = "test.fs"; | ||
|
||
var range = GetRange((0, 0), (42, 42)); | ||
|
||
var ranges = new[] { range }; | ||
|
||
var result = RangeHelper.Reduce(filePath, ranges); | ||
|
||
result.ShouldBe(ranges); | ||
} | ||
|
||
[Fact] | ||
public void Reduce_Two_Intersecting() | ||
{ | ||
var filePath = "test.fs"; | ||
|
||
var range1 = GetRange((0, 0), (22, 22)); | ||
var range2 = GetRange((11, 11), (33, 33)); | ||
var expectedRange = GetRange((0, 0), (33, 33)); | ||
|
||
var result = RangeHelper.Reduce(filePath, new[] { range1, range2 }); | ||
|
||
result.ShouldBe(new[] { expectedRange }); | ||
} | ||
|
||
[Fact] | ||
public void Reduce_Two_NonIntersecting() | ||
{ | ||
var filePath = "test.fs"; | ||
|
||
var range1 = GetRange((0, 0), (11, 11)); | ||
var range2 = GetRange((22, 22), (33, 33)); | ||
var ranges = new[] { range1, range2 }; | ||
|
||
var actual = RangeHelper.Reduce(filePath, ranges); | ||
|
||
actual.ShouldBe(ranges); | ||
} | ||
|
||
[Fact] | ||
public void Reduce_Three_PartiallyIntersecting() | ||
{ | ||
var filePath = "test.fs"; | ||
|
||
var range1 = GetRange((0, 0), (22, 22)); | ||
var range2 = GetRange((11, 11), (33, 33)); | ||
var range3 = GetRange((44, 44), (55, 55)); | ||
var expectedIntersection = GetRange((0, 0), (33, 33)); | ||
var expectedRanges = new[] { expectedIntersection, range3 }; | ||
|
||
var result = RangeHelper.Reduce(filePath, new[] { range1, range2, range3 }); ; | ||
|
||
result.ShouldBe(expectedRanges, ignoreOrder: true); | ||
} | ||
|
||
[Fact] | ||
public void RemoveOverlap_Overlapping_Partially() | ||
{ | ||
var filePath = "test.fs"; | ||
|
||
var range1 = GetRange((0, 0), (22, 22)); | ||
var range2 = GetRange((11, 11), (22, 22)); | ||
var expectedRange = GetRange((0, 0), (11, 11)); | ||
|
||
var result = RangeHelper.RemoveOverlap(new[] { range1 }, new [] { range2 }, filePath); | ||
|
||
result.ShouldBe(new[] { expectedRange }); | ||
} | ||
|
||
[Fact] | ||
public void RemoveOverlap_Overlapping_Completely() | ||
{ | ||
var filePath = "test.fs"; | ||
|
||
var range1 = GetRange((0, 0), (42, 42)); | ||
var range2 = GetRange((0, 0), (42, 42)); | ||
|
||
var result = RangeHelper.RemoveOverlap(new[] { range1 }, new[] { range2 }, filePath); | ||
|
||
result.ShouldBeEmpty(); | ||
} | ||
|
||
[Fact] | ||
public void RemoveOverlap_NotOverlapping() | ||
{ | ||
var filePath = "test.fs"; | ||
|
||
var range1 = GetRange((0, 0), (11, 11)); | ||
var range2 = GetRange((22, 22), (33, 33)); | ||
|
||
var result = RangeHelper.RemoveOverlap(new[] { range1 }, new[] { range2 }, filePath); | ||
|
||
result.ShouldBe(new[] { range1 }); | ||
} | ||
|
||
private static Range GetRange((int Line, int Column) start, (int Line, int Column) end) => | ||
RangeModule.mkRange( | ||
"test.fs", | ||
PositionModule.mkPos(start.Line, start.Column), | ||
PositionModule.mkPos(end.Line, end.Column)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.