From 519db821e20fe5fe808904d76c6115033afe3e16 Mon Sep 17 00:00:00 2001 From: nth-commit Date: Sat, 13 Aug 2022 22:20:18 +1200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=8C=8D=20#365=20Delete=20pure=20prope?= =?UTF-8?q?rties=20(ForThese())=20for=20now=20-=20maybe=20do=20a=20better?= =?UTF-8?q?=20version=20of=20it=20later?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PurePropertyTests/AboutPresentation.cs | 165 ------------------ .../RendererTests/AboutUnaryExamples.cs | 42 ++++- .../RunnerTests/AssertTests/Snapshots.cs | 5 +- ...alsifiable_AtLargerSizes_Iterations=1.snap | 2 +- ...sifiable_AtLargerSizes_Iterations=100.snap | 2 +- ...alsifiable_AtLargerSizes_Iterations=2.snap | 2 +- ...lsifiable_AtLargerSizes_Iterations=50.snap | 2 +- ...ifiable_AtSmallerSizes_Iterations=100.snap | 2 +- ...lsifiable_AtSmallerSizes_Iterations=2.snap | 2 +- ...sifiable_AtSmallerSizes_Iterations=50.snap | 2 +- .../RunnerTests/PrintTests/Snapshots.cs | 20 ++- .../IntegrationSample/AsyncTests.cs | 27 --- .../IntegrationSample/Tests.cs | 24 --- .../IntegrationTests.cs | 6 - .../Iterations/GenIterationFactory.cs | 22 +-- .../Gens/Iterations/GenIteration.cs | 20 +-- .../Gens/Iterations/Generic/GenIteration.cs | 18 +- src/GalaxyCheck/Operators/Cast.cs | 3 +- src/GalaxyCheck/Operators/NoShrink.cs | 3 +- src/GalaxyCheck/Operators/Select.cs | 3 +- src/GalaxyCheck/Operators/SelectMany.cs | 3 +- src/GalaxyCheck/Operators/Unfold.cs | 3 +- src/GalaxyCheck/Operators/Where.cs | 3 +- src/GalaxyCheck/Properties/ForThese.cs | 15 -- src/GalaxyCheck/Properties/ForTheseAsync.cs | 16 -- src/GalaxyCheck/Properties/Test.cs | 2 +- src/GalaxyCheck/Properties/TestFactory.cs | 20 +-- src/GalaxyCheck/Runners/Assert.cs | 4 +- src/GalaxyCheck/Runners/Check.cs | 8 +- .../AsyncAutomata/CheckStateAggregator.cs | 8 +- .../Check/AsyncAutomata/CheckStateContext.cs | 11 +- .../InstanceExplorationStates.cs | 7 - .../Check/AsyncAutomata/ReplayState.cs | 6 - .../Check/Automata/CheckStateAggregator.cs | 8 +- .../Check/Automata/CheckStateContext.cs | 11 +- .../Automata/InstanceExplorationStates.cs | 7 - .../Runners/Check/Automata/ReplayState.cs | 6 - .../Runners/Check/PresentationInferrer.cs | 66 ------- src/GalaxyCheck/Runners/ExampleRenderer.cs | 117 ++++++++++--- .../Runners/PresentationalSample.cs | 2 +- 40 files changed, 196 insertions(+), 499 deletions(-) delete mode 100644 src/GalaxyCheck.Tests/PropertyTests/PurePropertyTests/AboutPresentation.cs delete mode 100644 src/GalaxyCheck/Properties/ForThese.cs delete mode 100644 src/GalaxyCheck/Properties/ForTheseAsync.cs delete mode 100644 src/GalaxyCheck/Runners/Check/PresentationInferrer.cs diff --git a/src/GalaxyCheck.Tests/PropertyTests/PurePropertyTests/AboutPresentation.cs b/src/GalaxyCheck.Tests/PropertyTests/PurePropertyTests/AboutPresentation.cs deleted file mode 100644 index 9cbb3d1c..00000000 --- a/src/GalaxyCheck.Tests/PropertyTests/PurePropertyTests/AboutPresentation.cs +++ /dev/null @@ -1,165 +0,0 @@ -using FluentAssertions; -using GalaxyCheck; -using System.Linq; -using Xunit; - -namespace Tests.V2.PropertyTests.LinqInferenceTests -{ - public class AboutPresentation - { - [Fact] - public void ItPopulatesThePresentationalValueWithAScopedVariable() - { - var value = 0; - - var property = - from a in Gen.Constant(value) - select Property.ForThese(() => false); - - var result = property.Check(); - - result.Counterexample!.PresentationalValue.Should().BeEquivalentTo(value); - } - - [Fact] - public void ItPopulatesThePresentationalValueWithTwoScopedVariables() - { - var value0 = 0; - var value1 = 1; - - var property = - from a in Gen.Constant(value0) - from b in Gen.Constant(value1) - select Property.ForThese(() => false); - - var result = property.Check(); - - result.Counterexample!.PresentationalValue.Should().BeEquivalentTo(new [] { value0, value1 }); - } - - [Fact] - public void ItPopulatesThePresentationalValueWithThreeScopedVariables() - { - var value0 = 0; - var value1 = 1; - var value2 = 2; - - var property = - from a in Gen.Constant(value0) - from b in Gen.Constant(value1) - from c in Gen.Constant(value2) - select Property.ForThese(() => false); - - var result = property.Check(); - - result.Counterexample!.PresentationalValue.Should().BeEquivalentTo(new[] { value0, value1, value2 }); - } - - [Fact] - public void ItPopulatesThePresentationalValueWithAScopedVariableAndIgnoresInnerSelect() - { - var value_ignored = 0; - var value = 1; - - var property = - from a in Gen.Constant(value_ignored).Select(_ => value) - select Property.ForThese(() => false); - - var result = property.Check(); - - result.Counterexample!.PresentationalValue.Should().BeEquivalentTo(value); - } - - [Fact] - public void ItPopulatesThePresentationalValueWithAScopedVariableAndIgnoresInnerSelectMany() - { - var value_ignored = 0; - var value = 1; - - var property = - from a in Gen.Constant(value_ignored).SelectMany(_ => Gen.Constant(value)) - select Property.ForThese(() => false); - - var result = property.Check(); - - result.Counterexample!.PresentationalValue.Should().BeEquivalentTo(value); - } - - [Fact] - public void ItPopulatesThePresentationalValueWithAScopedVariableFromTheLetKeyword() - { - var value0 = 0; - var value1 = 1; - - var property = - from a in Gen.Constant(value0) - let b = a - let c = value1 - select Property.ForThese(() => false); - - var result = property.Check(); - - result.Counterexample!.PresentationalValue.Should().BeEquivalentTo(new[] { value0, value0, value1 }); - } - - /// - /// The LINQ inference works by unwrapping anonymous types, to reverse engineer what LINQ expressions do. This - /// means if you explicitly return anonymous types inside a LINQ statement, those values will get erroneously - /// unrolled. This is not ideal, but it's not possible (or really tricky + hacky) to disambiguate at the - /// moment. - /// - public class AboutSuboptimalRendering - { - [Fact] - public void ItAllowsAnonymousObjectsToBeExplicitlyReturnedBySelect() - { - // Ideally: { a = value } - // Actual: [value] - - var value = 0; - - var property = - from obj in Gen.Constant(value).Select(a => new { a }) - select Property.ForThese(() => false); - - var result = property.Check(seed: 0); - - result.Counterexample!.PresentationalValue.Should().BeEquivalentTo(new[] { value }); - } - - [Fact] - public void ItAllowsAnonymousObjectsToBeExplicitlyReturnedBySelectMany() - { - // Ideally: { a = value } - // Actual: [value] - - var value = 0; - - var property = - from obj in Gen.Constant(value).SelectMany(a => Gen.Constant(new { a })) - select Property.ForThese(() => false); - - var result = property.Check(seed: 0); - - result.Counterexample!.PresentationalValue.Should().BeEquivalentTo(new [] { value }); - } - - [Fact] - public void ItAllowsAnonymousObjectsToBeExplicitlyReturnedBySelectManyWithProjection() - { - // Ideally: { a = value, b = value } - // Actual: [value, value] - - var value = 0; - - var property = - from obj in Gen.Constant(value).SelectMany(a => Gen.Constant(new { a }), (x, y) => new { x, y }) - select Property.ForThese(() => false); - - var result = property.Check(seed: 0); - - result.Counterexample!.PresentationalValue.Should().BeEquivalentTo(new[] { value, value }); - } - } - } -} diff --git a/src/GalaxyCheck.Tests/RendererTests/AboutUnaryExamples.cs b/src/GalaxyCheck.Tests/RendererTests/AboutUnaryExamples.cs index 05581c3f..a871e687 100644 --- a/src/GalaxyCheck.Tests/RendererTests/AboutUnaryExamples.cs +++ b/src/GalaxyCheck.Tests/RendererTests/AboutUnaryExamples.cs @@ -42,7 +42,40 @@ public void ItCanHandleCircularReferences() rendering.Should().Be("{ Self = }"); } - public static TheoryData Values => new TheoryData + public static TheoryData TupleValues => new TheoryData + { + { new Tuple(1, 2, 3), new object[] { 1, 2, 3 } }, + { (1, 2, 3), new object[] { 1, 2, 3 } }, + { (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), new object[] {1, 2, 3, 4, 5, 6, 7 } }, + }; + + [Theory] + [MemberData(nameof(TupleValues))] + public void TuplesAreExpanded(object value, object[] expectedExpandedValues) + { + var rendering = ExampleRenderer.Render(new object[] { value }).ToList(); + + rendering.Should().HaveCount(expectedExpandedValues.Length); + } + + public static TheoryData TupleValueRenders => new TheoryData + { + { new Tuple(1, 2, 3), "(Item1 = 1, Item2 = 2, Item3 = 3)" }, + { (1, 2, 3), "(Item1 = 1, Item2 = 2, Item3 = 3)" }, + { (1, 2, 3, 4, 5, 6, 7, 8), "(Item1 = 1, Item2 = 2, Item3 = 3, Item4 = 4, Item5 = 5, Item6 = 6, Item7 = 7, Rest = ...)" }, + }; + + [Theory] + [MemberData(nameof(TupleValueRenders))] + public void TupleExamples(object value, string expectedRendering) + { + // Pass two params to force tuple not to be unwrapped + var rendering = ExampleRenderer.Render(new object[] { value, null! }).First().Substring("[0] = ".Length); + + rendering.Should().Be(expectedRendering); + } + + public static TheoryData OtherValueRenders => new TheoryData { { null, "null" }, { 1, "1" }, @@ -61,16 +94,13 @@ public void ItCanHandleCircularReferences() { new Func((_) => true), "System.Func`2[System.Int32,System.Boolean]" }, { new Func>(() => (_) => true), "System.Func`1[System.Func`2[System.Int32,System.Boolean]]" }, { new Action(() => { }), "System.Action" }, - { new Tuple(1, 2, 3), "(Item1 = 1, Item2 = 2, Item3 = 3)" }, - { (1, 2, 3), "(Item1 = 1, Item2 = 2, Item3 = 3)" }, - { (1, 2, 3, 4, 5, 6, 7, 8), "(Item1 = 1, Item2 = 2, Item3 = 3, Item4 = 4, Item5 = 5, Item6 = 6, Item7 = 7, Rest = ...)" }, { Operations.Create, "Create" }, { new FaultyRecord(), "" }, }; [Theory] - [MemberData(nameof(Values))] - public void Examples(object value, string expectedRendering) + [MemberData(nameof(OtherValueRenders))] + public void OtherExamples(object value, string expectedRendering) { var rendering = ExampleRenderer.Render(new object[] { value }).Single(); diff --git a/src/GalaxyCheck.Tests/RunnerTests/AssertTests/Snapshots.cs b/src/GalaxyCheck.Tests/RunnerTests/AssertTests/Snapshots.cs index a0b72e3c..91dfab2a 100644 --- a/src/GalaxyCheck.Tests/RunnerTests/AssertTests/Snapshots.cs +++ b/src/GalaxyCheck.Tests/RunnerTests/AssertTests/Snapshots.cs @@ -31,10 +31,11 @@ public void Snapshot_AssertFailure_IntLessThanEquals_BinaryProperty() // TODO: Cross-platform consistent replay encoding if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - var property = + var gen = from x in Gen.Int32().LessThan(int.MaxValue) from y in Gen.Int32().GreaterThan(x) - select Property.ForThese(() => x < 1000); + select (x, y); + var property = gen.ForAll(input => input.x < 1000); Action action = () => property.Assert(seed: 0); diff --git a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=1.snap b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=1.snap index a2872b02..aae0ff03 100644 --- a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=1.snap +++ b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=1.snap @@ -20,7 +20,7 @@ "ReplayPath": [], "Replay": "", "Exception": null, - "PresentationalValue": [ + "PresentedInput": [ 100 ] }, diff --git a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=100.snap b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=100.snap index aa939a88..3189ad9a 100644 --- a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=100.snap +++ b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=100.snap @@ -20,7 +20,7 @@ "ReplayPath": [], "Replay": "", "Exception": null, - "PresentationalValue": [ + "PresentedInput": [ 50 ] }, diff --git a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=2.snap b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=2.snap index 68874ca6..dcadaf17 100644 --- a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=2.snap +++ b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=2.snap @@ -20,7 +20,7 @@ "ReplayPath": [], "Replay": "", "Exception": null, - "PresentationalValue": [ + "PresentedInput": [ 100 ] }, diff --git a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=50.snap b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=50.snap index e79587b8..9cfe35ef 100644 --- a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=50.snap +++ b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtLargerSizes_Iterations=50.snap @@ -20,7 +20,7 @@ "ReplayPath": [], "Replay": "", "Exception": null, - "PresentationalValue": [ + "PresentedInput": [ 51 ] }, diff --git a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=100.snap b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=100.snap index 8e45d4c2..05678a5b 100644 --- a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=100.snap +++ b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=100.snap @@ -20,7 +20,7 @@ "ReplayPath": [], "Replay": "", "Exception": null, - "PresentationalValue": [ + "PresentedInput": [ 0 ] }, diff --git a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=2.snap b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=2.snap index 8e45d4c2..05678a5b 100644 --- a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=2.snap +++ b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=2.snap @@ -20,7 +20,7 @@ "ReplayPath": [], "Replay": "", "Exception": null, - "PresentationalValue": [ + "PresentedInput": [ 0 ] }, diff --git a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=50.snap b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=50.snap index 8e45d4c2..05678a5b 100644 --- a/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=50.snap +++ b/src/GalaxyCheck.Tests/RunnerTests/CheckTests/__snapshots__/Snapshots.Falsifiable_AtSmallerSizes_Iterations=50.snap @@ -20,7 +20,7 @@ "ReplayPath": [], "Replay": "", "Exception": null, - "PresentationalValue": [ + "PresentedInput": [ 0 ] }, diff --git a/src/GalaxyCheck.Tests/RunnerTests/PrintTests/Snapshots.cs b/src/GalaxyCheck.Tests/RunnerTests/PrintTests/Snapshots.cs index c63186ab..360a877d 100644 --- a/src/GalaxyCheck.Tests/RunnerTests/PrintTests/Snapshots.cs +++ b/src/GalaxyCheck.Tests/RunnerTests/PrintTests/Snapshots.cs @@ -77,10 +77,11 @@ public void PrintUnaryProperty() [Fact] public void PrintBinaryProperty() { - var property = new Property( + var gen = from x in Gen.Int32().LessThan(int.MaxValue) from y in Gen.Int32().GreaterThan(x) - select Property.ForThese(() => false)); + select (x, y); + var property = gen.ForAll((_) => false); var print = PrintAndCollect(property); @@ -100,10 +101,11 @@ public void PrintUnaryListProperty() [Fact] public void PrintBinaryListProperty() { - var property = new Property( + var gen = from xs in Gen.Int32().ListOf() from ys in Gen.Int32().ListOf().WithCountGreaterThan(xs.Count) - select Property.ForThese(() => false)); + select (xs, ys); + var property = gen.ForAll((_) => false); var print = PrintAndCollect(property); @@ -145,10 +147,11 @@ public async Task PrintUnaryProperty() [Fact] public async Task PrintBinaryProperty() { - var property = new AsyncProperty( + var gen = from x in Gen.Int32().LessThan(int.MaxValue) from y in Gen.Int32().GreaterThan(x) - select Property.ForTheseAsync(() => Task.FromResult(false))); + select (x, y); + var property = gen.ForAllAsync((_) => Task.FromResult(false)); var print = await PrintAndCollect(property); @@ -168,10 +171,11 @@ public async Task PrintUnaryListProperty() [Fact] public async Task PrintBinaryListProperty() { - var property = new AsyncProperty( + var gen = from xs in Gen.Int32().ListOf() from ys in Gen.Int32().ListOf().WithCountGreaterThan(xs.Count) - select Property.ForTheseAsync(() => Task.FromResult(false))); + select (xs, ys); + var property = gen.ForAllAsync((_) => Task.FromResult(false)); var print = await PrintAndCollect(property); diff --git a/src/GalaxyCheck.Xunit.Tests/IntegrationSample/AsyncTests.cs b/src/GalaxyCheck.Xunit.Tests/IntegrationSample/AsyncTests.cs index cf4e2cbc..8406faef 100644 --- a/src/GalaxyCheck.Xunit.Tests/IntegrationSample/AsyncTests.cs +++ b/src/GalaxyCheck.Xunit.Tests/IntegrationSample/AsyncTests.cs @@ -18,25 +18,6 @@ public AsyncTests(ITestOutputHelper testOutputHelper) _testOutputHelper = testOutputHelper; } - [Property] - public IGen InfalliblePurePropertyAsync() => - from a in Gen.Int32().Between(0, 100) - select Property.ForTheseAsync(async () => - { - await Task.Delay(1); - AnnounceTestInvocation(nameof(InfalliblePurePropertyAsync)); - }); - - [Property] - public IGen FalliblePurePropertyAsync() => - from a in Gen.Int32().Between(0, 100) - select Property.ForTheseAsync(async () => - { - await Task.Delay(1); - AnnounceTestInvocation(nameof(FalliblePurePropertyAsync)); - throw new Exception("Failed!"); - }); - [Property] public async Task InfallibleVoidPropertyAsync([Between(0, 100)] int x) { @@ -112,14 +93,6 @@ public async Task PropertyWithGenFromMemberGenAsync([MemberGen(nameof(EvenInt32) Assert.True(x % 2 != 1, "They are not odd!"); } - [Sample] - public IGen SamplePurePropertyAsync() => - from a in Gen.Int32().Between(0, 100) - select Property.ForTheseAsync(async () => - { - await Task.Delay(1); - }); - [Sample] public async Task SampleVoidPropertyAsync([Between(0, 100)] int x) { diff --git a/src/GalaxyCheck.Xunit.Tests/IntegrationSample/Tests.cs b/src/GalaxyCheck.Xunit.Tests/IntegrationSample/Tests.cs index ce9a33cc..c322db04 100644 --- a/src/GalaxyCheck.Xunit.Tests/IntegrationSample/Tests.cs +++ b/src/GalaxyCheck.Xunit.Tests/IntegrationSample/Tests.cs @@ -17,23 +17,6 @@ public Tests(ITestOutputHelper testOutputHelper) _testOutputHelper = testOutputHelper; } - [Property] - public IGen InfalliblePureProperty() => - from a in Gen.Int32().Between(0, 100) - select Property.ForThese(() => - { - AnnounceTestInvocation(nameof(InfalliblePureProperty)); - }); - - [Property] - public IGen FalliblePureProperty() => - from a in Gen.Int32().Between(0, 100) - select Property.ForThese(() => - { - AnnounceTestInvocation(nameof(FalliblePureProperty)); - throw new Exception("Failed!"); - }); - [Property] public void InfallibleVoidProperty([Between(0, 100)] int x) { @@ -96,13 +79,6 @@ public void PropertyWithGenFromMemberGen([MemberGen(nameof(EvenInt32))] int x) Assert.True(x % 2 != 1, "They are not odd!"); } - [Sample] - public IGen SamplePureProperty() => - from a in Gen.Int32().Between(0, 100) - select Property.ForThese(() => - { - }); - [Sample] public void SampleVoidProperty([Between(0, 100)] int x) { diff --git a/src/GalaxyCheck.Xunit.Tests/IntegrationTests.cs b/src/GalaxyCheck.Xunit.Tests/IntegrationTests.cs index d1808d9f..786ce897 100644 --- a/src/GalaxyCheck.Xunit.Tests/IntegrationTests.cs +++ b/src/GalaxyCheck.Xunit.Tests/IntegrationTests.cs @@ -21,8 +21,6 @@ public IntegrationTests(TestSuiteFixture fixture) } [Theory] - [InlineData("InfalliblePureProperty")] - [InlineData("InfalliblePurePropertyAsync")] [InlineData("InfallibleVoidProperty")] [InlineData("InfallibleVoidPropertyAsync")] [InlineData("InfallibleBooleanProperty")] @@ -41,8 +39,6 @@ public void PassingProperties(string testName) } [Theory] - [InlineData("FalliblePureProperty")] - [InlineData("FalliblePurePropertyAsync")] [InlineData("FallibleVoidProperty")] [InlineData("FallibleVoidPropertyAsync")] [InlineData("FallibleBooleanProperty")] @@ -58,8 +54,6 @@ public void FailingProperties(string testName) } [Theory] - [InlineData("SamplePureProperty")] - [InlineData("SamplePurePropertyAsync")] [InlineData("SampleVoidProperty")] [InlineData("SampleVoidPropertyAsync")] public void SampledProperties(string testName) diff --git a/src/GalaxyCheck/Gens/Internal/Iterations/GenIterationFactory.cs b/src/GalaxyCheck/Gens/Internal/Iterations/GenIterationFactory.cs index f2cf751d..97c70ac6 100644 --- a/src/GalaxyCheck/Gens/Internal/Iterations/GenIterationFactory.cs +++ b/src/GalaxyCheck/Gens/Internal/Iterations/GenIterationFactory.cs @@ -29,7 +29,7 @@ public GenIteration( public IGenData Data { get; init; } IGenData IGenIteration.Data => Data.Match( - onInstance: instanceData => GenData.InstanceData(instanceData.ExampleSpace, instanceData.ExampleSpaceHistory), + onInstance: instanceData => GenData.InstanceData(instanceData.ExampleSpace), onError: errorData => GenData.ErrorData(errorData.GenName, errorData.Message), onDiscard: discardData => GenData.DiscardData(discardData.ExampleSpace)); @@ -53,8 +53,6 @@ public GenInstance( public IExampleSpace ExampleSpace => Data.Instance!.ExampleSpace; - public IEnumerable ExampleSpaceHistory => Data.Instance!.ExampleSpaceHistory; - IExampleSpace IGenInstanceData.ExampleSpace => ExampleSpace; } @@ -92,23 +90,7 @@ public static IGenIteration Instance( GenParameters nextParameters, IExampleSpace exampleSpace) { - var instanceData = GenData.InstanceData( - exampleSpace, - new[] { exampleSpace }); - - return new GenIteration(replayParameters, nextParameters, instanceData); - } - - public static IGenIteration Instance( - GenParameters replayParameters, - GenParameters nextParameters, - IExampleSpace exampleSpace, - IEnumerable lastExampleSpaceHistory) - { - var instanceData = GenData.InstanceData( - exampleSpace, - lastExampleSpaceHistory.Append(exampleSpace)); - + var instanceData = GenData.InstanceData(exampleSpace); return new GenIteration(replayParameters, nextParameters, instanceData); } diff --git a/src/GalaxyCheck/Gens/Iterations/GenIteration.cs b/src/GalaxyCheck/Gens/Iterations/GenIteration.cs index a827c0d9..b5c4c693 100644 --- a/src/GalaxyCheck/Gens/Iterations/GenIteration.cs +++ b/src/GalaxyCheck/Gens/Iterations/GenIteration.cs @@ -31,8 +31,6 @@ T Match( public interface IGenInstanceData { IExampleSpace ExampleSpace { get; } - - IEnumerable ExampleSpaceHistory { get; } } public interface IGenErrorData @@ -47,9 +45,7 @@ public interface IGenDiscardData IExampleSpace ExampleSpace { get; } } - public record GenInstanceData( - IExampleSpace ExampleSpace, - IEnumerable ExampleSpaceHistory) : IGenInstanceData; + public record GenInstanceData(IExampleSpace ExampleSpace) : IGenInstanceData; public record GenErrorData(string GenName, string Message) : IGenErrorData; @@ -57,14 +53,12 @@ public record GenDiscardData(IExampleSpace ExampleSpace) : IGenDiscardData; public record GenData : IGenData { - public static GenData InstanceData( - IExampleSpace exampleSpace, - IEnumerable exampleSpaceHistory) => new GenData - { - Instance = new GenInstanceData(exampleSpace, exampleSpaceHistory), - Error = null, - Discard = null - }; + public static GenData InstanceData(IExampleSpace exampleSpace) => new GenData + { + Instance = new GenInstanceData(exampleSpace), + Error = null, + Discard = null + }; public static GenData ErrorData(string genName, string message) => new GenData { diff --git a/src/GalaxyCheck/Gens/Iterations/Generic/GenIteration.cs b/src/GalaxyCheck/Gens/Iterations/Generic/GenIteration.cs index b11cf072..bbd6e844 100644 --- a/src/GalaxyCheck/Gens/Iterations/Generic/GenIteration.cs +++ b/src/GalaxyCheck/Gens/Iterations/Generic/GenIteration.cs @@ -45,9 +45,7 @@ public interface IGenInstanceData : IGenInstanceData new IExampleSpace ExampleSpace { get; } } - public record GenInstanceData( - IExampleSpace ExampleSpace, - IEnumerable ExampleSpaceHistory) : IGenInstanceData + public record GenInstanceData(IExampleSpace ExampleSpace) : IGenInstanceData { IExampleSpace IGenInstanceData.ExampleSpace => ExampleSpace; } @@ -58,14 +56,12 @@ public record GenDiscardData(IExampleSpace ExampleSpace) : IGenDiscardData; public record GenData : IGenData { - public static GenData InstanceData( - IExampleSpace exampleSpace, - IEnumerable exampleSpaceHistory) => new GenData - { - Instance = new GenInstanceData(exampleSpace, exampleSpaceHistory), - Error = null, - Discard = null - }; + public static GenData InstanceData(IExampleSpace exampleSpace) => new GenData + { + Instance = new GenInstanceData(exampleSpace), + Error = null, + Discard = null + }; public static GenData ErrorData(string genName, string message) => new GenData { diff --git a/src/GalaxyCheck/Operators/Cast.cs b/src/GalaxyCheck/Operators/Cast.cs index 5e51d1c2..58c8dbfc 100644 --- a/src/GalaxyCheck/Operators/Cast.cs +++ b/src/GalaxyCheck/Operators/Cast.cs @@ -14,8 +14,7 @@ public static partial class Extensions onInstance: instance => GenIterationFactory.Instance( iteration.ReplayParameters, iteration.NextParameters, - instance.ExampleSpace.Cast(), - instance.ExampleSpaceHistory), + instance.ExampleSpace.Cast()), onError: error => GenIterationFactory.Error( iteration.ReplayParameters, iteration.NextParameters, diff --git a/src/GalaxyCheck/Operators/NoShrink.cs b/src/GalaxyCheck/Operators/NoShrink.cs index 6af757f7..1d808c22 100644 --- a/src/GalaxyCheck/Operators/NoShrink.cs +++ b/src/GalaxyCheck/Operators/NoShrink.cs @@ -10,7 +10,6 @@ public static IGen NoShrink(this IGen gen) => gen.TransformInstances(instance => GenIterationFactory.Instance( instance.ReplayParameters, instance.NextParameters, - ExampleSpaceFactory.Singleton(instance.ExampleSpace.Current.Id, instance.ExampleSpace.Current.Value), - instance.ExampleSpaceHistory)); + ExampleSpaceFactory.Singleton(instance.ExampleSpace.Current.Id, instance.ExampleSpace.Current.Value))); } } diff --git a/src/GalaxyCheck/Operators/Select.cs b/src/GalaxyCheck/Operators/Select.cs index 4b983247..2af01ef7 100644 --- a/src/GalaxyCheck/Operators/Select.cs +++ b/src/GalaxyCheck/Operators/Select.cs @@ -32,8 +32,7 @@ public static IGen Select(this IGen gen, Func> Run( onInstance: innerInstance => GenIterationFactory.Instance( iteration.ReplayParameters, innerIteration.NextParameters, - innerInstance.ExampleSpace, - instance.ExampleSpaceHistory), + innerInstance.ExampleSpace), onError: innerError => GenIterationFactory.Error( iteration.ReplayParameters, innerIteration.NextParameters, diff --git a/src/GalaxyCheck/Operators/Unfold.cs b/src/GalaxyCheck/Operators/Unfold.cs index 947c9f9f..4c5777e0 100644 --- a/src/GalaxyCheck/Operators/Unfold.cs +++ b/src/GalaxyCheck/Operators/Unfold.cs @@ -30,8 +30,7 @@ public static IGen Unfold( return GenIterationFactory.Instance( instance.ReplayParameters, instance.NextParameters, - unfolder(instance.ExampleSpace.Current.Value), - instance.ExampleSpaceHistory); + unfolder(instance.ExampleSpace.Current.Value)); }; return gen.TransformInstances(transformation); diff --git a/src/GalaxyCheck/Operators/Where.cs b/src/GalaxyCheck/Operators/Where.cs index d64854d8..2319eb1c 100644 --- a/src/GalaxyCheck/Operators/Where.cs +++ b/src/GalaxyCheck/Operators/Where.cs @@ -33,8 +33,7 @@ public static IGen Where(this IGen gen, Func pred) return GenIterationFactory.Instance( instance.ReplayParameters, instance.NextParameters, - filteredExampleSpace, - instance.ExampleSpaceHistory); + filteredExampleSpace); }; GenStreamTransformation resizeAndTerminateAfterConsecutiveDiscards = (stream) => diff --git a/src/GalaxyCheck/Properties/ForThese.cs b/src/GalaxyCheck/Properties/ForThese.cs deleted file mode 100644 index 01f16c1f..00000000 --- a/src/GalaxyCheck/Properties/ForThese.cs +++ /dev/null @@ -1,15 +0,0 @@ -using GalaxyCheck.Properties; -using System; - -namespace GalaxyCheck -{ - public partial class Property - { - public static Test ForThese(Func func) => TestFactory.Create( - null!, - () => func(), - null); - - public static Test ForThese(Action func) => ForThese(func.AsTrueFunc()); - } -} diff --git a/src/GalaxyCheck/Properties/ForTheseAsync.cs b/src/GalaxyCheck/Properties/ForTheseAsync.cs deleted file mode 100644 index 05560a2d..00000000 --- a/src/GalaxyCheck/Properties/ForTheseAsync.cs +++ /dev/null @@ -1,16 +0,0 @@ -using GalaxyCheck.Properties; -using System; -using System.Threading.Tasks; - -namespace GalaxyCheck -{ - public partial class Property - { - public static AsyncTest ForTheseAsync(Func> func) => TestFactory.Create( - null!, - () => new ValueTask(func()), - null); - - public static AsyncTest ForTheseAsync(Func func) => ForTheseAsync(func.AsTrueFunc()); - } -} diff --git a/src/GalaxyCheck/Properties/Test.cs b/src/GalaxyCheck/Properties/Test.cs index 5241bf63..c76bc3da 100644 --- a/src/GalaxyCheck/Properties/Test.cs +++ b/src/GalaxyCheck/Properties/Test.cs @@ -12,7 +12,7 @@ public interface TestInput Lazy Output { get; } - IReadOnlyList? PresentedInput { get; } + IReadOnlyList PresentedInput { get; } } public interface Test : TestInput diff --git a/src/GalaxyCheck/Properties/TestFactory.cs b/src/GalaxyCheck/Properties/TestFactory.cs index 9d7640a8..eaa99d9b 100644 --- a/src/GalaxyCheck/Properties/TestFactory.cs +++ b/src/GalaxyCheck/Properties/TestFactory.cs @@ -8,21 +8,21 @@ internal static class TestFactory { private record TestOutputImpl(TestResult Result, Exception? Exception) : TestOutput; - private record TestImpl(T Input, Lazy Output, IReadOnlyList? PresentedInput) : Test; + private record TestImpl(T Input, Lazy Output, IReadOnlyList PresentedInput) : Test; - private record TestImpl(object? Input, Lazy Output, IReadOnlyList? PresentedInput) : Test; + private record TestImpl(object? Input, Lazy Output, IReadOnlyList PresentedInput) : Test; - public static Test Create(T input, Lazy output, IReadOnlyList? presentedInput) + public static Test Create(T input, Lazy output, IReadOnlyList presentedInput) { return new TestImpl(input, output, presentedInput); } - public static Test Create(T input, Func generateOutput, IReadOnlyList? presentedInput) + public static Test Create(T input, Func generateOutput, IReadOnlyList presentedInput) { return new TestImpl(input, AnalyzeBooleanOutput(generateOutput), presentedInput); } - public static Test Create(object[] input, Func generateOutput, IReadOnlyList? presentedInput) + public static Test Create(object[] input, Func generateOutput, IReadOnlyList presentedInput) { return new TestImpl(input, AnalyzeBooleanOutput(generateOutput), presentedInput); } @@ -39,21 +39,21 @@ public static Test Create(object[] input, Func generateOutput, IReadOnlyLi } }); - private record AsyncTestImpl(T Input, Lazy> Output, IReadOnlyList? PresentedInput) : AsyncTest; + private record AsyncTestImpl(T Input, Lazy> Output, IReadOnlyList PresentedInput) : AsyncTest; - private record AsyncTestImpl(object? Input, Lazy> Output, IReadOnlyList? PresentedInput) : AsyncTest; + private record AsyncTestImpl(object? Input, Lazy> Output, IReadOnlyList PresentedInput) : AsyncTest; - public static AsyncTest Create(T input, Lazy> output, IReadOnlyList? presentedInput) + public static AsyncTest Create(T input, Lazy> output, IReadOnlyList presentedInput) { return new AsyncTestImpl(input, output, presentedInput); } - public static AsyncTest Create(T input, Func> generateOutput, IReadOnlyList? presentedInput) + public static AsyncTest Create(T input, Func> generateOutput, IReadOnlyList presentedInput) { return new AsyncTestImpl(input, AnalyzeBooleanOutput(generateOutput), presentedInput); } - public static AsyncTest Create(object[] input, Func> generateOutput, IReadOnlyList? presentedInput) + public static AsyncTest Create(object[] input, Func> generateOutput, IReadOnlyList presentedInput) { return new AsyncTestImpl(input, AnalyzeBooleanOutput(generateOutput), presentedInput); } diff --git a/src/GalaxyCheck/Runners/Assert.cs b/src/GalaxyCheck/Runners/Assert.cs index 28aceac5..46ba9550 100644 --- a/src/GalaxyCheck/Runners/Assert.cs +++ b/src/GalaxyCheck/Runners/Assert.cs @@ -66,7 +66,7 @@ private static void ThrowIfFalsified( counterexample.ReplayPath, counterexample.Replay, counterexample.Exception, - counterexample.PresentationalValue); + counterexample.PresentedInput); } } } @@ -151,7 +151,7 @@ private static string ReproductionLine( private static string CounterexampleValueLine(Counterexample counterexample) { - var lines = ExampleRenderer.Render(counterexample.PresentationalValue).ToList(); + var lines = ExampleRenderer.Render(counterexample.PresentedInput).ToList(); return lines.Count switch { diff --git a/src/GalaxyCheck/Runners/Check.cs b/src/GalaxyCheck/Runners/Check.cs index c28ca543..51894288 100644 --- a/src/GalaxyCheck/Runners/Check.cs +++ b/src/GalaxyCheck/Runners/Check.cs @@ -118,7 +118,7 @@ private static Counterexample FromCounterexampleContext( counterexampleContext.ReplayPath, replayEncoded, counterexampleContext.Exception, - counterexampleContext.PresentationalValue); + counterexampleContext.PresentedInput); } private static Counterexample FromCounterexampleContext( @@ -135,7 +135,7 @@ private static Counterexample FromCounterexampleContext( counterexampleContext.ReplayPath, replayEncoded, counterexampleContext.Exception, - counterexampleContext.PresentationalValue); + counterexampleContext.PresentedInput); } } } @@ -187,7 +187,7 @@ public CheckResult( public record CheckIteration( T Value, - IReadOnlyList PresentationalValue, + IReadOnlyList PresentedInput, IExampleSpace ExampleSpace, GenParameters Parameters, IEnumerable Path, @@ -202,7 +202,7 @@ public record Counterexample( IEnumerable ReplayPath, string Replay, Exception? Exception, - IReadOnlyList PresentationalValue); + IReadOnlyList PresentedInput); public enum TerminationReason { diff --git a/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateAggregator.cs b/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateAggregator.cs index 5e1ad15a..26442480 100644 --- a/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateAggregator.cs +++ b/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateAggregator.cs @@ -90,9 +90,7 @@ private static bool isTransitionDiscard(CheckStateTransition transition) = { return new CheckIteration( Value: state.InputExampleSpace.Current.Value, - PresentationalValue: - state.TestExampleSpace.Current.Value.PresentedInput ?? - PresentationInferrer.InferValue(state.ExampleSpaceHistory), + PresentedInput: state.TestExampleSpace.Current.Value.PresentedInput, ExampleSpace: state.InputExampleSpace, Parameters: state.CounterexampleContext.ReplayParameters, Path: state.CounterexampleContext.ReplayPath, @@ -104,9 +102,7 @@ private static bool isTransitionDiscard(CheckStateTransition transition) = { return new CheckIteration( Value: state.InputExampleSpace.Current.Value, - PresentationalValue: - state.TestExampleSpace.Current.Value.PresentedInput ?? - PresentationInferrer.InferValue(state.ExampleSpaceHistory), + PresentedInput: state.TestExampleSpace.Current.Value.PresentedInput, ExampleSpace: state.InputExampleSpace, Parameters: state.Instance.ReplayParameters, Path: state.NonCounterexampleExploration.Path, diff --git a/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateContext.cs b/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateContext.cs index f5981b35..7777cd9c 100644 --- a/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateContext.cs +++ b/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateContext.cs @@ -125,7 +125,6 @@ public CheckStateContext WithNextGenParameters(GenParameters genParameters) = internal record CounterexampleContext( IExampleSpace> TestExampleSpace, - IEnumerable?>> ExampleSpaceHistory, GenParameters ReplayParameters, IEnumerable ReplayPath, Exception? Exception) @@ -134,14 +133,6 @@ internal record CounterexampleContext( public T Value => ExampleSpace.Current.Value; - public IReadOnlyList PresentationalValue - { - get - { - var test = TestExampleSpace.Current.Value; - var arity = test.PresentedInput?.Count; - return arity > 0 ? test.PresentedInput! : PresentationInferrer.InferValue(ExampleSpaceHistory); - } - } + public IReadOnlyList PresentedInput => TestExampleSpace.Current.Value.PresentedInput; } } diff --git a/src/GalaxyCheck/Runners/Check/AsyncAutomata/InstanceExplorationStates.cs b/src/GalaxyCheck/Runners/Check/AsyncAutomata/InstanceExplorationStates.cs index 3eda4b56..e47387d9 100644 --- a/src/GalaxyCheck/Runners/Check/AsyncAutomata/InstanceExplorationStates.cs +++ b/src/GalaxyCheck/Runners/Check/AsyncAutomata/InstanceExplorationStates.cs @@ -76,7 +76,6 @@ public Task> Transition(CheckStateContext context) => public CounterexampleContext CounterexampleContext => new CounterexampleContext( CounterexampleExploration.ExampleSpace, - ExampleSpaceHistory, Instance.ReplayParameters, CounterexampleExploration.Path, CounterexampleExploration.Exception); @@ -86,9 +85,6 @@ public Task> Transition(CheckStateContext context) => public IExampleSpace InputExampleSpace => CounterexampleExploration.ExampleSpace.Map(ex => ex.Input); public IEnumerable Path => CounterexampleExploration.Path; - - public IEnumerable?>> ExampleSpaceHistory => Instance.ExampleSpaceHistory.Select( - exs => new Lazy?>(() => exs.Cast().Navigate(Path))); } internal record InstanceExploration_NonCounterexample( @@ -111,9 +107,6 @@ public Task> Transition(CheckStateContext context) => public IExampleSpace InputExampleSpace => NonCounterexampleExploration.ExampleSpace.Map(ex => ex.Input); public IEnumerable Path => NonCounterexampleExploration.Path; - - public IEnumerable?>> ExampleSpaceHistory => Instance.ExampleSpaceHistory.Select( - exs => new Lazy?>(() => exs.Cast().Navigate(Path))); } internal record InstanceExploration_End( diff --git a/src/GalaxyCheck/Runners/Check/AsyncAutomata/ReplayState.cs b/src/GalaxyCheck/Runners/Check/AsyncAutomata/ReplayState.cs index dd944541..e85ae4be 100644 --- a/src/GalaxyCheck/Runners/Check/AsyncAutomata/ReplayState.cs +++ b/src/GalaxyCheck/Runners/Check/AsyncAutomata/ReplayState.cs @@ -65,7 +65,6 @@ private static CheckStateTransition HandleReplayedCounterexample( { var counterexampleContext = new CounterexampleContext( counterexample.ExampleSpace, - GetNavigatedExampleSpaceHistory(instance, replayDecoded.ExampleSpacePath), replayDecoded.GenParameters, replayDecoded.ExampleSpacePath, counterexample.Exception); @@ -83,10 +82,5 @@ private static CheckStateTransition HandleError(CheckStateContext context) "parameter and run the property again. This is probably due to the generator setup changing."), context); } - - private static IEnumerable?>> GetNavigatedExampleSpaceHistory( - IGenInstance> instance, - IEnumerable path) => - instance.ExampleSpaceHistory.Select(exs => new Lazy?>(() => exs.Cast().Navigate(path))); } } diff --git a/src/GalaxyCheck/Runners/Check/Automata/CheckStateAggregator.cs b/src/GalaxyCheck/Runners/Check/Automata/CheckStateAggregator.cs index e7e4572f..79404d2f 100644 --- a/src/GalaxyCheck/Runners/Check/Automata/CheckStateAggregator.cs +++ b/src/GalaxyCheck/Runners/Check/Automata/CheckStateAggregator.cs @@ -89,9 +89,7 @@ private static bool isTransitionDiscard(CheckStateTransition transition) = { return new CheckIteration( Value: state.InputExampleSpace.Current.Value, - PresentationalValue: - state.TestExampleSpace.Current.Value.PresentedInput ?? - PresentationInferrer.InferValue(state.ExampleSpaceHistory), + PresentedInput: state.TestExampleSpace.Current.Value.PresentedInput, ExampleSpace: state.InputExampleSpace, Parameters: state.CounterexampleContext.ReplayParameters, Path: state.CounterexampleContext.ReplayPath, @@ -103,9 +101,7 @@ private static bool isTransitionDiscard(CheckStateTransition transition) = { return new CheckIteration( Value: state.InputExampleSpace.Current.Value, - PresentationalValue: - state.TestExampleSpace.Current.Value.PresentedInput ?? - PresentationInferrer.InferValue(state.ExampleSpaceHistory), + PresentedInput: state.TestExampleSpace.Current.Value.PresentedInput, ExampleSpace: state.InputExampleSpace, Parameters: state.Instance.ReplayParameters, Path: state.NonCounterexampleExploration.Path, diff --git a/src/GalaxyCheck/Runners/Check/Automata/CheckStateContext.cs b/src/GalaxyCheck/Runners/Check/Automata/CheckStateContext.cs index c15b2f36..b3a47b83 100644 --- a/src/GalaxyCheck/Runners/Check/Automata/CheckStateContext.cs +++ b/src/GalaxyCheck/Runners/Check/Automata/CheckStateContext.cs @@ -125,7 +125,6 @@ public CheckStateContext WithNextGenParameters(GenParameters genParameters) = internal record CounterexampleContext( IExampleSpace> TestExampleSpace, - IEnumerable?>> ExampleSpaceHistory, GenParameters ReplayParameters, IEnumerable ReplayPath, Exception? Exception) @@ -134,14 +133,6 @@ internal record CounterexampleContext( public T Value => ExampleSpace.Current.Value; - public IReadOnlyList PresentationalValue - { - get - { - var test = TestExampleSpace.Current.Value; - var arity = test.PresentedInput?.Count; - return arity > 0 ? test.PresentedInput! : PresentationInferrer.InferValue(ExampleSpaceHistory); - } - } + public IReadOnlyList PresentedInput => TestExampleSpace.Current.Value.PresentedInput; } } diff --git a/src/GalaxyCheck/Runners/Check/Automata/InstanceExplorationStates.cs b/src/GalaxyCheck/Runners/Check/Automata/InstanceExplorationStates.cs index 118976ef..f0849373 100644 --- a/src/GalaxyCheck/Runners/Check/Automata/InstanceExplorationStates.cs +++ b/src/GalaxyCheck/Runners/Check/Automata/InstanceExplorationStates.cs @@ -73,7 +73,6 @@ internal record InstanceExploration_Counterexample( public CounterexampleContext CounterexampleContext => new CounterexampleContext( CounterexampleExploration.ExampleSpace, - ExampleSpaceHistory, Instance.ReplayParameters, CounterexampleExploration.Path, CounterexampleExploration.Exception); @@ -83,9 +82,6 @@ internal record InstanceExploration_Counterexample( public IExampleSpace InputExampleSpace => CounterexampleExploration.ExampleSpace.Map(ex => ex.Input); public IEnumerable Path => CounterexampleExploration.Path; - - public IEnumerable?>> ExampleSpaceHistory => Instance.ExampleSpaceHistory.Select( - exs => new Lazy?>(() => exs.Cast().Navigate(Path))); } internal record InstanceExploration_NonCounterexample( @@ -107,9 +103,6 @@ internal record InstanceExploration_NonCounterexample( public IExampleSpace InputExampleSpace => NonCounterexampleExploration.ExampleSpace.Map(ex => ex.Input); public IEnumerable Path => NonCounterexampleExploration.Path; - - public IEnumerable?>> ExampleSpaceHistory => Instance.ExampleSpaceHistory.Select( - exs => new Lazy?>(() => exs.Cast().Navigate(Path))); } internal record InstanceExploration_End( diff --git a/src/GalaxyCheck/Runners/Check/Automata/ReplayState.cs b/src/GalaxyCheck/Runners/Check/Automata/ReplayState.cs index 25448e0d..4438239b 100644 --- a/src/GalaxyCheck/Runners/Check/Automata/ReplayState.cs +++ b/src/GalaxyCheck/Runners/Check/Automata/ReplayState.cs @@ -64,7 +64,6 @@ private static CheckStateTransition HandleReplayedCounterexample( { var counterexampleContext = new CounterexampleContext( counterexample.ExampleSpace, - GetNavigatedExampleSpaceHistory(instance, replayDecoded.ExampleSpacePath), replayDecoded.GenParameters, replayDecoded.ExampleSpacePath, counterexample.Exception); @@ -82,10 +81,5 @@ private static CheckStateTransition HandleError(CheckStateContext context) "parameter and run the property again. This is probably due to the generator setup changing."), context); } - - private static IEnumerable?>> GetNavigatedExampleSpaceHistory( - IGenInstance> instance, - IEnumerable path) => - instance.ExampleSpaceHistory.Select(exs => new Lazy?>(() => exs.Cast().Navigate(path))); } } diff --git a/src/GalaxyCheck/Runners/Check/PresentationInferrer.cs b/src/GalaxyCheck/Runners/Check/PresentationInferrer.cs deleted file mode 100644 index fc472bd2..00000000 --- a/src/GalaxyCheck/Runners/Check/PresentationInferrer.cs +++ /dev/null @@ -1,66 +0,0 @@ -using GalaxyCheck; -using GalaxyCheck.ExampleSpaces; -using GalaxyCheck.Internal; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace GalaxyCheck.Runners.Check -{ - internal static class PresentationInferrer - { - public static IReadOnlyList InferValue(IEnumerable?>> exampleSpaceHistory) - { - return InferExampleSpace(exampleSpaceHistory)?.Current.Value ?? new object?[] { }; - } - - public static IExampleSpace? InferExampleSpace(IEnumerable?>> exampleSpaceHistory) - { - var (head, tail) = exampleSpaceHistory.Reverse(); - - if (head?.Value == null) - { - return null; - } - - var lastId = head.Value.Current.Id; - - var presentationalExampleSpaces = - from lazyExs in tail - let exs = lazyExs.Value - where exs != null - where exs.Current.Id == lastId - where exs.Current.Value == null || IsTest(exs.Current.Value) == false - select exs; - - return presentationalExampleSpaces.FirstOrDefault()?.Map(UnwrapBinding); - } - - private static bool IsTest(object obj) - { - return obj.GetType().GetInterfaces().Any(t => t.IsGenericType && (t.GetGenericTypeDefinition() == typeof(Test<>) || t.GetGenericTypeDefinition() == typeof(AsyncTest<>))); - } - - private static object?[] UnwrapBinding(object? obj) - { - static object?[] UnwrapBindingRec(object? obj) - { - var type = obj?.GetType(); - - if (type != null && type.IsAnonymousType()) - { - return type.GetProperties().SelectMany(p => UnwrapBindingRec(p.GetValue(obj))).ToArray(); - } - - return new[] { obj }; - } - - if (obj?.GetType().IsAnonymousType() == true) - { - return UnwrapBindingRec(obj); - } - - return new object?[] { obj }; - } - } -} diff --git a/src/GalaxyCheck/Runners/ExampleRenderer.cs b/src/GalaxyCheck/Runners/ExampleRenderer.cs index 49719923..ab811f9b 100644 --- a/src/GalaxyCheck/Runners/ExampleRenderer.cs +++ b/src/GalaxyCheck/Runners/ExampleRenderer.cs @@ -10,11 +10,43 @@ public static class ExampleRenderer { public static IEnumerable Render(IReadOnlyList example) => example.Count switch { - 0 => new string[] { "(no value)" }, - 1 => new string[] { RenderValue(example.Single()) }, - _ => example.Select((value, index) => $"[{index}] = {RenderValue(value)}"), + 0 => RenderNullary(), + 1 => TryUnwrapTuple(example.Single(), out var unwrapped) ? RenderMultiary(unwrapped!) : RenderUnary(example), + _ => RenderMultiary(example), }; + private static string[] RenderNullary() + { + return new string[] { "(no value)" }; + } + + private static string[] RenderUnary(IReadOnlyList example) + { + return new string[] { RenderValue(example.Single()) }; + } + + private static IEnumerable RenderMultiary(IReadOnlyList example) + { + return example.Select((value, index) => $"[{index}] = {RenderValue(value)}"); + } + + private static bool TryUnwrapTuple(object? obj, out IReadOnlyList? unwrapped) + { + if (IsClassTupleInstance(obj)) + { + unwrapped = obj!.GetType().GetProperties().Select(p => p.GetValue(obj)).ToList(); + return true; + } + else if (IsTupleLiteralInstance(obj)) + { + unwrapped = obj!.GetType().GetFields().Where(f => f.Name != "Rest").Select(f => f.GetValue(obj)).ToList(); + return true; + } + + unwrapped = null; + return false; + } + private static string RenderValue(object? obj) { const int DepthLimit = 10; @@ -23,10 +55,12 @@ private static string RenderValue(object? obj) var handler = new CompositeExampleRendererHandler( new List { + new AbbreviationRendererHandler(), new StringExampleRendererHandler(), new PrimitiveExampleRendererHandler(), new EnumerableExampleRendererHandler(elementLimit: BreadthLimit), - new TupleRendererHandler(), + new ClassTupleRendererHandler(), + new TupleLiteralRendererHandler(), new ObjectRendererHandler(propertyLimit: BreadthLimit) }, DepthLimit); @@ -137,40 +171,47 @@ public string Render(object? obj, IExampleRendererHandler renderer, ImmutableLis } } - private class TupleRendererHandler : IExampleRendererHandler + private abstract class BaseTupleRendererHandler : IExampleRendererHandler { - public bool CanRender(object? obj) => - obj is not null && - obj.GetType().GetInterface("System.Runtime.CompilerServices.ITuple") != null; + public abstract bool CanRender(object? obj); public string Render(object? obj, IExampleRendererHandler renderer, ImmutableList path) { - return obj!.GetType().GetFields().Any() - ? RenderTupleLiteral(obj, renderer, path) - : RenderClassTuple(obj, renderer, path); + var renderedElements = GetTupleElements(obj).Select((x) => $"{x.name} = {renderer.Render(x.value, renderer, path)}"); + + return "(" + string.Join(", ", renderedElements) + ")"; } - private static string RenderTupleLiteral(object obj, IExampleRendererHandler renderer, ImmutableList path) - { - var fields = obj!.GetType().GetFields(); + protected abstract IEnumerable<(string name, object? value)> GetTupleElements(object? obj); + } - var fieldsToRender = fields.Where(f => f.Name != "Rest").ToList(); - var hasMoreFields = fields.Any(f => f.Name == "Rest"); + private class ClassTupleRendererHandler : BaseTupleRendererHandler + { + public override bool CanRender(object? obj) => IsClassTupleInstance(obj); - var renderedFields = Enumerable.Concat( - fieldsToRender.Select(f => $"{f.Name} = {renderer.Render(f.GetValue(obj), renderer, path)}"), - hasMoreFields ? new[] { "Rest = ..." } : Enumerable.Empty()); + protected override IEnumerable<(string name, object? value)> GetTupleElements(object? obj) => + obj!.GetType().GetProperties().Select(p => (p.Name, p.GetValue(obj!))); + } - return "(" + string.Join(", ", renderedFields) + ")"; - } + private class TupleLiteralRendererHandler : BaseTupleRendererHandler + { + public override bool CanRender(object? obj) => IsTupleLiteralInstance(obj); - private static string RenderClassTuple(object obj, IExampleRendererHandler renderer, ImmutableList path) + protected override IEnumerable<(string name, object? value)> GetTupleElements(object? obj) { - var properties = obj!.GetType().GetProperties(); + var fields = obj!.GetType().GetFields(); - var renderedProperties = properties.Select(p => $"{p.Name} = {renderer.Render(p.GetValue(obj), renderer, path)}"); + var fieldsToRender = fields.Where(f => f.Name != "Rest").ToList(); + foreach (var field in fields.Where(f => f.Name != "Rest").ToList()) + { + yield return (field.Name, field.GetValue(obj)); + } - return "(" + string.Join(", ", renderedProperties) + ")"; + var hasMoreFields = fields.Any(f => f.Name == "Rest"); + if (hasMoreFields) + { + yield return ("Rest", AbbreviationRendererHandler.AbbreviationSymbol); + } } } @@ -200,5 +241,31 @@ public string Render(object? obj, IExampleRendererHandler renderer, ImmutableLis return "{ " + string.Join(", ", renderedProperties) + " }"; } } + + private class AbbreviationRendererHandler : IExampleRendererHandler + { + public static readonly object AbbreviationSymbol = new object(); + + public bool CanRender(object? obj) => obj == AbbreviationSymbol; + + public string Render(object? obj, IExampleRendererHandler renderer, ImmutableList path) => "..."; + } + + private static bool IsClassTupleInstance(object? value) + { + return + value is not null && + value.GetType().GetInterface("System.Runtime.CompilerServices.ITuple") != null && + value!.GetType().GetFields().Any() == false; + } + + private static bool IsTupleLiteralInstance(object? value) + { + return + value is not null && + value.GetType().GetInterface("System.Runtime.CompilerServices.ITuple") != null && + value!.GetType().GetFields().Any() == true; + } + } } diff --git a/src/GalaxyCheck/Runners/PresentationalSample.cs b/src/GalaxyCheck/Runners/PresentationalSample.cs index af09217d..a4cfff02 100644 --- a/src/GalaxyCheck/Runners/PresentationalSample.cs +++ b/src/GalaxyCheck/Runners/PresentationalSample.cs @@ -90,7 +90,7 @@ private static AsyncTest MuteTestFailure(AsyncTest test) private static SampleWithMetricsResult> ExtractSampleFromCheckResult(CheckResult checkResult) { var values = checkResult.Checks - .Select(check => check.PresentationalValue) + .Select(check => check.PresentedInput) .ToList(); return new SampleWithMetricsResult>( From bf6c34b9f42a8507e84da1e60a345b0fa49c177e Mon Sep 17 00:00:00 2001 From: nth-commit Date: Sat, 13 Aug 2022 22:29:50 +1200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8C=8D=20#365=20Move=20Test/AsyncTest?= =?UTF-8?q?/TestOutput/TestResult=20out=20of=20root=20namespace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReflectedPropertyTests/AboutValidation.cs | 8 ++-- src/GalaxyCheck/Properties/Reflect.cs | 26 ----------- src/GalaxyCheck/Properties/Test.cs | 46 ++++++++++--------- src/GalaxyCheck/Properties/TestFactory.cs | 34 +++++++------- src/GalaxyCheck/Properties/TestOutput.cs | 11 +++-- src/GalaxyCheck/Properties/TestResult.cs | 9 ++-- src/GalaxyCheck/Property.cs | 20 ++++---- src/GalaxyCheck/Runners/Assert.cs | 4 +- src/GalaxyCheck/Runners/Check.cs | 4 +- .../AnalyzeExplorationForCheck.cs | 6 +-- .../Check/AsyncAutomata/CheckStateContext.cs | 8 ++-- .../Check/AsyncAutomata/GenerationStates.cs | 18 ++++---- .../InstanceExplorationStates.cs | 24 +++++----- .../Check/AsyncAutomata/ReplayState.cs | 8 ++-- .../Automata/AnalyzeExplorationForCheck.cs | 6 +-- .../Check/Automata/CheckStateContext.cs | 8 ++-- .../Check/Automata/GenerationStates.cs | 18 ++++---- .../Automata/InstanceExplorationStates.cs | 24 +++++----- .../Runners/Check/Automata/ReplayState.cs | 8 ++-- .../Runners/Check/Sizing/ResizeStrategy.cs | 2 +- .../Check/Sizing/ResizeStrategyAsync.cs | 2 +- .../Runners/PresentationalSample.cs | 4 +- 22 files changed, 140 insertions(+), 158 deletions(-) diff --git a/src/GalaxyCheck.Tests/PropertyTests/ReflectedPropertyTests/AboutValidation.cs b/src/GalaxyCheck.Tests/PropertyTests/ReflectedPropertyTests/AboutValidation.cs index a7e4c142..0ceacf7a 100644 --- a/src/GalaxyCheck.Tests/PropertyTests/ReflectedPropertyTests/AboutValidation.cs +++ b/src/GalaxyCheck.Tests/PropertyTests/ReflectedPropertyTests/AboutValidation.cs @@ -22,19 +22,17 @@ public void AMethodReturningAnUnsupportedTypeThrowsTheGenericUnsupportedExceptio test.Should() .Throw() - .WithMessage($"Return type is not supported by Property.Reflect. Please use one of: GalaxyCheck.IGen`1[GalaxyCheck.Test], GalaxyCheck.Property, System.Boolean, System.Void. Return type was: {typeof(MyType)}."); + .WithMessage($"Return type is not supported by Property.Reflect. Please use one of: GalaxyCheck.Property, System.Boolean, System.Void. Return type was: {typeof(MyType)}."); } private Task TaskMethod() => null!; private Task TaskBoolMethod() => null!; private AsyncProperty AsyncPropertyMethod() => null!; - private IGen IGenAsyncTestMethod() => null!; [Theory] [InlineData(nameof(TaskMethod))] [InlineData(nameof(TaskBoolMethod))] [InlineData(nameof(AsyncPropertyMethod))] - [InlineData(nameof(IGenAsyncTestMethod))] public void AMethodReturningAnUnsupportedTypeSupportedByAsyncThrowsTheMessageWithHint(string methodName) { var method = GetMethod(methodName); @@ -43,7 +41,7 @@ public void AMethodReturningAnUnsupportedTypeSupportedByAsyncThrowsTheMessageWit test.Should() .Throw() - .WithMessage($"Return type is not supported by Property.Reflect. Did you mean to use Property.ReflectAsync? Otherwise, please use one of: GalaxyCheck.IGen`1[GalaxyCheck.Test], GalaxyCheck.Property, System.Boolean, System.Void. Return type was: {method.ReturnType}."); + .WithMessage($"Return type is not supported by Property.Reflect. Did you mean to use Property.ReflectAsync? Otherwise, please use one of: GalaxyCheck.Property, System.Boolean, System.Void. Return type was: {method.ReturnType}."); } private static MethodInfo GetMethod(string name) @@ -72,7 +70,7 @@ public void AMethodReturningAnUnsupportedTypeThrowsTheGenericUnsupportedExceptio test.Should() .Throw() - .WithMessage($"Return type is not supported by Property.ReflectAsync. Please use one of: GalaxyCheck.AsyncProperty, GalaxyCheck.IGen`1[GalaxyCheck.AsyncTest], GalaxyCheck.IGen`1[GalaxyCheck.Test], GalaxyCheck.Property, System.Boolean, System.Threading.Tasks.Task, System.Threading.Tasks.Task`1[System.Boolean], System.Void. Return type was: {typeof(MyType)}."); + .WithMessage($"Return type is not supported by Property.ReflectAsync. Please use one of: GalaxyCheck.AsyncProperty, GalaxyCheck.Property, System.Boolean, System.Threading.Tasks.Task, System.Threading.Tasks.Task`1[System.Boolean], System.Void. Return type was: {typeof(MyType)}."); } } } diff --git a/src/GalaxyCheck/Properties/Reflect.cs b/src/GalaxyCheck/Properties/Reflect.cs index 8a3ad947..075be1f8 100644 --- a/src/GalaxyCheck/Properties/Reflect.cs +++ b/src/GalaxyCheck/Properties/Reflect.cs @@ -92,7 +92,6 @@ private static AsyncReflectedPropertyHandler ToAsyncPropertyHandler(ReflectedPro { typeof(void), ToVoidProperty }, { typeof(bool), ToBooleanProperty }, { typeof(Property), ToReturnedProperty }, - { typeof(IGen), ToPureProperty }, }.ToImmutableDictionary(); private readonly static ImmutableDictionary AsyncMethodPropertyHandlers = @@ -101,7 +100,6 @@ private static AsyncReflectedPropertyHandler ToAsyncPropertyHandler(ReflectedPro { typeof(Task), ToTaskProperty }, { typeof(Task), ToTaskBooleanProperty }, { typeof(AsyncProperty), ToReturnedAsyncProperty }, - { typeof(IGen), ToPureAsyncProperty }, }.ToImmutableDictionary(); private static ReflectedPropertyHandler ToVoidProperty => (methodInfo, target, genFactory, customGens) => @@ -155,18 +153,6 @@ private static AsyncReflectedPropertyHandler ToAsyncPropertyHandler(ReflectedPro } }; - private static ReflectedPropertyHandler ToPureProperty => (methodInfo, target, _, _) => - { - try - { - return new Property((IGen)methodInfo.Invoke(target, new object[] { })!); - } - catch (TargetInvocationException ex) - { - throw ex.InnerException!; - } - }; - private static AsyncReflectedPropertyHandler ToTaskProperty => (methodInfo, target, genFactory, customGens) => { return new AsyncProperty(Gen @@ -217,17 +203,5 @@ private static AsyncReflectedPropertyHandler ToAsyncPropertyHandler(ReflectedPro throw ex.InnerException!; } }; - - private static AsyncReflectedPropertyHandler ToPureAsyncProperty => (methodInfo, target, _, _) => - { - try - { - return new AsyncProperty((IGen)methodInfo.Invoke(target, new object[] { })!); - } - catch (TargetInvocationException ex) - { - throw ex.InnerException!; - } - }; } } diff --git a/src/GalaxyCheck/Properties/Test.cs b/src/GalaxyCheck/Properties/Test.cs index c76bc3da..889ee880 100644 --- a/src/GalaxyCheck/Properties/Test.cs +++ b/src/GalaxyCheck/Properties/Test.cs @@ -6,42 +6,46 @@ namespace GalaxyCheck { - public interface TestInput - { - TInput Input { get; } + public partial class Property + { + public interface TestInput + { + TInput Input { get; } - Lazy Output { get; } + Lazy Output { get; } - IReadOnlyList PresentedInput { get; } - } + IReadOnlyList PresentedInput { get; } + } - public interface Test : TestInput - { - } + public interface Test : TestInput + { + } - public interface Test : Test - { - } + public interface Test : Test + { + } - public interface AsyncTest : TestInput> - { - } + public interface AsyncTest : TestInput> + { + } - public interface AsyncTest : AsyncTest - { + public interface AsyncTest : AsyncTest + { + } } public static partial class Extensions { - public static Test Cast(this Test test) => TestFactory.Create((T)test.Input!, test.Output, test.PresentedInput); + public static Property.Test Cast(this Property.Test test) => TestFactory.Create((T)test.Input!, test.Output, test.PresentedInput); - public static AsyncTest Cast(this AsyncTest test) => TestFactory.Create((T)test.Input!, test.Output, test.PresentedInput); + public static Property.AsyncTest Cast(this Property.AsyncTest test) => TestFactory.Create((T)test.Input!, test.Output, test.PresentedInput); - public static AsyncTest AsAsync(this Test test) => TestFactory.Create( + public static Property.AsyncTest AsAsync(this Property.Test test) => TestFactory.Create( test.Input, - new Lazy>(() => ValueTask.FromResult(test.Output.Value)), + new Lazy>(() => ValueTask.FromResult(test.Output.Value)), test.PresentedInput); } } + #pragma warning disable IDE1006 // Naming Styles diff --git a/src/GalaxyCheck/Properties/TestFactory.cs b/src/GalaxyCheck/Properties/TestFactory.cs index eaa99d9b..5664d6a6 100644 --- a/src/GalaxyCheck/Properties/TestFactory.cs +++ b/src/GalaxyCheck/Properties/TestFactory.cs @@ -6,67 +6,67 @@ namespace GalaxyCheck.Properties { internal static class TestFactory { - private record TestOutputImpl(TestResult Result, Exception? Exception) : TestOutput; + private record TestOutputImpl(Property.TestResult Result, Exception? Exception) : Property.TestOutput; - private record TestImpl(T Input, Lazy Output, IReadOnlyList PresentedInput) : Test; + private record TestImpl(T Input, Lazy Output, IReadOnlyList PresentedInput) : Property.Test; - private record TestImpl(object? Input, Lazy Output, IReadOnlyList PresentedInput) : Test; + private record TestImpl(object? Input, Lazy Output, IReadOnlyList PresentedInput) : Property.Test; - public static Test Create(T input, Lazy output, IReadOnlyList presentedInput) + public static Property.Test Create(T input, Lazy output, IReadOnlyList presentedInput) { return new TestImpl(input, output, presentedInput); } - public static Test Create(T input, Func generateOutput, IReadOnlyList presentedInput) + public static Property.Test Create(T input, Func generateOutput, IReadOnlyList presentedInput) { return new TestImpl(input, AnalyzeBooleanOutput(generateOutput), presentedInput); } - public static Test Create(object[] input, Func generateOutput, IReadOnlyList presentedInput) + public static Property.Test Create(object[] input, Func generateOutput, IReadOnlyList presentedInput) { return new TestImpl(input, AnalyzeBooleanOutput(generateOutput), presentedInput); } - private static Lazy AnalyzeBooleanOutput(Func generateOutput) => new Lazy(() => + private static Lazy AnalyzeBooleanOutput(Func generateOutput) => new Lazy(() => { try { - return new TestOutputImpl(generateOutput() ? TestResult.Succeeded : TestResult.Failed, null); + return new TestOutputImpl(generateOutput() ? Property.TestResult.Succeeded : Property.TestResult.Failed, null); } catch (Exception ex) { - return new TestOutputImpl(TestResult.Failed, ex); + return new TestOutputImpl(Property.TestResult.Failed, ex); } }); - private record AsyncTestImpl(T Input, Lazy> Output, IReadOnlyList PresentedInput) : AsyncTest; + private record AsyncTestImpl(T Input, Lazy> Output, IReadOnlyList PresentedInput) : Property.AsyncTest; - private record AsyncTestImpl(object? Input, Lazy> Output, IReadOnlyList PresentedInput) : AsyncTest; + private record AsyncTestImpl(object? Input, Lazy> Output, IReadOnlyList PresentedInput) : Property.AsyncTest; - public static AsyncTest Create(T input, Lazy> output, IReadOnlyList presentedInput) + public static Property.AsyncTest Create(T input, Lazy> output, IReadOnlyList presentedInput) { return new AsyncTestImpl(input, output, presentedInput); } - public static AsyncTest Create(T input, Func> generateOutput, IReadOnlyList presentedInput) + public static Property.AsyncTest Create(T input, Func> generateOutput, IReadOnlyList presentedInput) { return new AsyncTestImpl(input, AnalyzeBooleanOutput(generateOutput), presentedInput); } - public static AsyncTest Create(object[] input, Func> generateOutput, IReadOnlyList presentedInput) + public static Property.AsyncTest Create(object[] input, Func> generateOutput, IReadOnlyList presentedInput) { return new AsyncTestImpl(input, AnalyzeBooleanOutput(generateOutput), presentedInput); } - private static Lazy> AnalyzeBooleanOutput(Func> generateOutput) => new Lazy>(async () => + private static Lazy> AnalyzeBooleanOutput(Func> generateOutput) => new Lazy>(async () => { try { - return new TestOutputImpl(await generateOutput() ? TestResult.Succeeded : TestResult.Failed, null); + return new TestOutputImpl(await generateOutput() ? Property.TestResult.Succeeded : Property.TestResult.Failed, null); } catch (Exception ex) { - return new TestOutputImpl(TestResult.Failed, ex); + return new TestOutputImpl(Property.TestResult.Failed, ex); } }, isThreadSafe: false); } diff --git a/src/GalaxyCheck/Properties/TestOutput.cs b/src/GalaxyCheck/Properties/TestOutput.cs index c7d911a7..351bbe35 100644 --- a/src/GalaxyCheck/Properties/TestOutput.cs +++ b/src/GalaxyCheck/Properties/TestOutput.cs @@ -2,12 +2,15 @@ namespace GalaxyCheck { + public partial class Property + { #pragma warning disable IDE1006 // Naming Styles - public interface TestOutput + public interface TestOutput #pragma warning restore IDE1006 // Naming Styles - { - TestResult Result { get; } + { + TestResult Result { get; } - Exception? Exception { get; } + Exception? Exception { get; } + } } } diff --git a/src/GalaxyCheck/Properties/TestResult.cs b/src/GalaxyCheck/Properties/TestResult.cs index 745f026d..b8da57d6 100644 --- a/src/GalaxyCheck/Properties/TestResult.cs +++ b/src/GalaxyCheck/Properties/TestResult.cs @@ -1,8 +1,11 @@ namespace GalaxyCheck { - public enum TestResult + public partial class Property { - Succeeded = 1, - Failed = 2 + public enum TestResult + { + Succeeded = 1, + Failed = 2 + } } } diff --git a/src/GalaxyCheck/Property.cs b/src/GalaxyCheck/Property.cs index 0399d303..2aeb55f2 100644 --- a/src/GalaxyCheck/Property.cs +++ b/src/GalaxyCheck/Property.cs @@ -13,16 +13,16 @@ public Property(IGen gen) : this(gen.Select(t => t.Cast())) } } - public class Property : IGen> + public class Property : IGen> { - private readonly IGen> _gen; + private readonly IGen> _gen; - public Property(IGen> gen) + public Property(IGen> gen) { _gen = gen; } - public IGenAdvanced> Advanced => _gen.Advanced; + public IGenAdvanced> Advanced => _gen.Advanced; IGenAdvanced IGen.Advanced => Advanced; @@ -33,25 +33,25 @@ from test in property public class AsyncProperty : AsyncProperty { - public AsyncProperty(IGen> gen) : base(gen) + public AsyncProperty(IGen> gen) : base(gen) { } - public AsyncProperty(IGen gen) : this(gen.Select(t => t.Cast())) + public AsyncProperty(IGen gen) : this(gen.Select(t => t.Cast())) { } } - public class AsyncProperty : IGen> + public class AsyncProperty : IGen> { - private readonly IGen> _gen; + private readonly IGen> _gen; - public AsyncProperty(IGen> gen) + public AsyncProperty(IGen> gen) { _gen = gen; } - public IGenAdvanced> Advanced => _gen.Advanced; + public IGenAdvanced> Advanced => _gen.Advanced; IGenAdvanced IGen.Advanced => Advanced; diff --git a/src/GalaxyCheck/Runners/Assert.cs b/src/GalaxyCheck/Runners/Assert.cs index 46ba9550..9e9bae6d 100644 --- a/src/GalaxyCheck/Runners/Assert.cs +++ b/src/GalaxyCheck/Runners/Assert.cs @@ -10,7 +10,7 @@ namespace GalaxyCheck public static partial class Extensions { public static void Assert( - this IGen> property, + this IGen> property, int? iterations = null, int? seed = null, int? size = null, @@ -25,7 +25,7 @@ public static void Assert( } public static async Task AssertAsync( - this IGen> property, + this IGen> property, int? iterations = null, int? seed = null, int? size = null, diff --git a/src/GalaxyCheck/Runners/Check.cs b/src/GalaxyCheck/Runners/Check.cs index 51894288..a0065477 100644 --- a/src/GalaxyCheck/Runners/Check.cs +++ b/src/GalaxyCheck/Runners/Check.cs @@ -15,7 +15,7 @@ namespace GalaxyCheck public static partial class Extensions { public static CheckResult Check( - this IGen> property, + this IGen> property, int? iterations = null, int? seed = null, int? size = null, @@ -60,7 +60,7 @@ public static CheckResult Check( } public static async Task> CheckAsync( - this IGen> property, + this IGen> property, int? iterations = null, int? seed = null, int? size = null, diff --git a/src/GalaxyCheck/Runners/Check/AsyncAutomata/AnalyzeExplorationForCheck.cs b/src/GalaxyCheck/Runners/Check/AsyncAutomata/AnalyzeExplorationForCheck.cs index d4bb485a..a1c991c9 100644 --- a/src/GalaxyCheck/Runners/Check/AsyncAutomata/AnalyzeExplorationForCheck.cs +++ b/src/GalaxyCheck/Runners/Check/AsyncAutomata/AnalyzeExplorationForCheck.cs @@ -4,13 +4,13 @@ namespace GalaxyCheck.Runners.Check.AsyncAutomata { internal static class AnalyzeExplorationForCheck { - public static AnalyzeExplorationAsync> CheckTestAsync() => async (example) => + public static AnalyzeExplorationAsync> CheckTestAsync() => async (example) => { var testOutput = await example.Value.Output.Value; return testOutput.Result switch { - TestResult.Succeeded => ExplorationOutcome.Success(), - TestResult.Failed => ExplorationOutcome.Fail(testOutput.Exception), + Property.TestResult.Succeeded => ExplorationOutcome.Success(), + Property.TestResult.Failed => ExplorationOutcome.Fail(testOutput.Exception), _ => throw new Exception("Fatal: Unhandled case") }; }; diff --git a/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateContext.cs b/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateContext.cs index 7777cd9c..5a65bd71 100644 --- a/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateContext.cs +++ b/src/GalaxyCheck/Runners/Check/AsyncAutomata/CheckStateContext.cs @@ -9,7 +9,7 @@ namespace GalaxyCheck.Runners.Check.AsyncAutomata { internal record CheckStateContext { - public IGen> Property { get; private init; } + public IGen> Property { get; private init; } public int RequestedIterations { get; private init; } @@ -36,7 +36,7 @@ internal record CheckStateContext public bool DeepCheck { get; private init; } private CheckStateContext( - IGen> property, + IGen> property, int requestedIterations, int shrinkLimit, int completedIterationsUntilCounterexample, @@ -60,7 +60,7 @@ private CheckStateContext( } public CheckStateContext( - IGen> property, + IGen> property, int requestedIterations, int shrinkLimit, GenParameters initialParameters, @@ -124,7 +124,7 @@ public CheckStateContext WithNextGenParameters(GenParameters genParameters) = } internal record CounterexampleContext( - IExampleSpace> TestExampleSpace, + IExampleSpace> TestExampleSpace, GenParameters ReplayParameters, IEnumerable ReplayPath, Exception? Exception) diff --git a/src/GalaxyCheck/Runners/Check/AsyncAutomata/GenerationStates.cs b/src/GalaxyCheck/Runners/Check/AsyncAutomata/GenerationStates.cs index c8d66dee..8969af6a 100644 --- a/src/GalaxyCheck/Runners/Check/AsyncAutomata/GenerationStates.cs +++ b/src/GalaxyCheck/Runners/Check/AsyncAutomata/GenerationStates.cs @@ -30,7 +30,7 @@ public async Task> Transition(CheckStateContext conte } } - internal record Generation_HoldingNextIteration(IEnumerable>> Iterations) : CheckState + internal record Generation_HoldingNextIteration(IEnumerable>> Iterations) : CheckState { public Task> Transition(CheckStateContext context) { @@ -48,7 +48,7 @@ public Task> Transition(CheckStateContext context) } } - internal record Generation_Instance(IGenInstance> Iteration) : CheckState + internal record Generation_Instance(IGenInstance> Iteration) : CheckState { public Task> Transition(CheckStateContext context) => Task.FromResult( new CheckStateTransition( @@ -57,8 +57,8 @@ public Task> Transition(CheckStateContext context) => } internal record Generation_Discard( - IEnumerable>> NextIterations, - IGenDiscard> Iteration) : CheckState + IEnumerable>> NextIterations, + IGenDiscard> Iteration) : CheckState { public Task> Transition(CheckStateContext context) => Task.FromResult( new CheckStateTransition( @@ -75,7 +75,7 @@ public Task> Transition(CheckStateContext context) => } internal record Generation_End( - IGenInstance> Instance, + IGenInstance> Instance, CounterexampleContext? CounterexampleContext, bool WasDiscard, bool WasLateDiscard, @@ -89,7 +89,7 @@ public Task> Transition(CheckStateContext context) => private static CheckStateTransition TransitionFromDiscard( CheckStateContext context, - IGenInstance> instance, + IGenInstance> instance, bool wasLateDiscard) => new CheckStateTransition( new Generation_Begin(), context @@ -98,7 +98,7 @@ private static CheckStateTransition TransitionFromDiscard( private static CheckStateTransition NextStateWithoutCounterexample( CheckStateContext context, - IGenInstance> instance) + IGenInstance> instance) { var nextContext = context .IncrementCompletedIterations() @@ -109,7 +109,7 @@ private static CheckStateTransition NextStateWithoutCounterexample( private static CheckStateTransition NextStateWithCounterexample( CheckStateContext context, - IGenInstance> instance, + IGenInstance> instance, CounterexampleContext counterexampleContext, bool wasReplay) { @@ -132,7 +132,7 @@ private static CheckStateTransition NextStateWithCounterexample( private static TerminationReason? TryTerminate( CheckStateContext state, CounterexampleContext counterexampleContext, - IGenInstance> instance, + IGenInstance> instance, bool wasReplay) { if (wasReplay) diff --git a/src/GalaxyCheck/Runners/Check/AsyncAutomata/InstanceExplorationStates.cs b/src/GalaxyCheck/Runners/Check/AsyncAutomata/InstanceExplorationStates.cs index e47387d9..2cdfee8c 100644 --- a/src/GalaxyCheck/Runners/Check/AsyncAutomata/InstanceExplorationStates.cs +++ b/src/GalaxyCheck/Runners/Check/AsyncAutomata/InstanceExplorationStates.cs @@ -11,7 +11,7 @@ namespace GalaxyCheck.Runners.Check.AsyncAutomata { internal static class InstanceExplorationStates { - internal record InstanceExploration_Begin(IGenInstance> Instance) : CheckState + internal record InstanceExploration_Begin(IGenInstance> Instance) : CheckState { public Task> Transition(CheckStateContext context) { @@ -24,8 +24,8 @@ public Task> Transition(CheckStateContext context) } internal record InstanceExploration_HoldingNextExplorationStage( - IGenInstance> Instance, - IAsyncEnumerable>> Explorations, + IGenInstance> Instance, + IAsyncEnumerable>> Explorations, CounterexampleContext? CounterexampleContext, bool IsFirstExplorationStage) : CheckState { @@ -61,9 +61,9 @@ public async Task> Transition(CheckStateContext conte } internal record InstanceExploration_Counterexample( - IGenInstance> Instance, - IAsyncEnumerable>> NextExplorations, - ExplorationStage>.Counterexample CounterexampleExploration) : CheckState + IGenInstance> Instance, + IAsyncEnumerable>> NextExplorations, + ExplorationStage>.Counterexample CounterexampleExploration) : CheckState { public Task> Transition(CheckStateContext context) => Task.FromResult( new CheckStateTransition( @@ -80,7 +80,7 @@ public Task> Transition(CheckStateContext context) => CounterexampleExploration.Path, CounterexampleExploration.Exception); - public IExampleSpace> TestExampleSpace => CounterexampleExploration.ExampleSpace; + public IExampleSpace> TestExampleSpace => CounterexampleExploration.ExampleSpace; public IExampleSpace InputExampleSpace => CounterexampleExploration.ExampleSpace.Map(ex => ex.Input); @@ -88,9 +88,9 @@ public Task> Transition(CheckStateContext context) => } internal record InstanceExploration_NonCounterexample( - IGenInstance> Instance, - IAsyncEnumerable>> NextExplorations, - ExplorationStage>.NonCounterexample NonCounterexampleExploration, + IGenInstance> Instance, + IAsyncEnumerable>> NextExplorations, + ExplorationStage>.NonCounterexample NonCounterexampleExploration, CounterexampleContext? PreviousCounterexampleContext) : CheckState { public Task> Transition(CheckStateContext context) => Task.FromResult( @@ -102,7 +102,7 @@ public Task> Transition(CheckStateContext context) => IsFirstExplorationStage: false), context)); - public IExampleSpace> TestExampleSpace => NonCounterexampleExploration.ExampleSpace; + public IExampleSpace> TestExampleSpace => NonCounterexampleExploration.ExampleSpace; public IExampleSpace InputExampleSpace => NonCounterexampleExploration.ExampleSpace.Map(ex => ex.Input); @@ -110,7 +110,7 @@ public Task> Transition(CheckStateContext context) => } internal record InstanceExploration_End( - IGenInstance> Instance, + IGenInstance> Instance, CounterexampleContext? CounterexampleContext, bool WasDiscard, bool WasReplay) : CheckState diff --git a/src/GalaxyCheck/Runners/Check/AsyncAutomata/ReplayState.cs b/src/GalaxyCheck/Runners/Check/AsyncAutomata/ReplayState.cs index e85ae4be..4644a9be 100644 --- a/src/GalaxyCheck/Runners/Check/AsyncAutomata/ReplayState.cs +++ b/src/GalaxyCheck/Runners/Check/AsyncAutomata/ReplayState.cs @@ -33,7 +33,7 @@ public Task> Transition(CheckStateContext context) onDiscard: _ => Task.FromResult(HandleError(context))); } - private static async Task> HandleInstance(CheckStateContext ctx, IGenInstance> instance, Replay replayDecoded) + private static async Task> HandleInstance(CheckStateContext ctx, IGenInstance> instance, Replay replayDecoded) { var exampleSpace = instance.ExampleSpace.Navigate(replayDecoded.ExampleSpacePath); if (exampleSpace == null) @@ -50,7 +50,7 @@ private static async Task> HandleInstance(CheckStateCont private static CheckStateTransition HandleReplayedNonCounterexample( CheckStateContext context, - IGenInstance> instance) + IGenInstance> instance) { return new CheckStateTransition( new GenerationStates.Generation_End(instance, null, false, false, true), @@ -59,9 +59,9 @@ private static CheckStateTransition HandleReplayedNonCounterexample( private static CheckStateTransition HandleReplayedCounterexample( CheckStateContext context, - IGenInstance> instance, + IGenInstance> instance, Replay replayDecoded, - ExplorationStage>.Counterexample counterexample) + ExplorationStage>.Counterexample counterexample) { var counterexampleContext = new CounterexampleContext( counterexample.ExampleSpace, diff --git a/src/GalaxyCheck/Runners/Check/Automata/AnalyzeExplorationForCheck.cs b/src/GalaxyCheck/Runners/Check/Automata/AnalyzeExplorationForCheck.cs index 8e8f897f..f4b6f00f 100644 --- a/src/GalaxyCheck/Runners/Check/Automata/AnalyzeExplorationForCheck.cs +++ b/src/GalaxyCheck/Runners/Check/Automata/AnalyzeExplorationForCheck.cs @@ -4,13 +4,13 @@ namespace GalaxyCheck.Runners.Check.Automata { internal static class AnalyzeExplorationForCheck { - public static AnalyzeExploration> CheckTest() => (example) => + public static AnalyzeExploration> CheckTest() => (example) => { var testOutput = example.Value.Output.Value; return testOutput.Result switch { - TestResult.Succeeded => ExplorationOutcome.Success(), - TestResult.Failed => ExplorationOutcome.Fail(testOutput.Exception), + Property.TestResult.Succeeded => ExplorationOutcome.Success(), + Property.TestResult.Failed => ExplorationOutcome.Fail(testOutput.Exception), _ => throw new Exception("Fatal: Unhandled case") }; }; diff --git a/src/GalaxyCheck/Runners/Check/Automata/CheckStateContext.cs b/src/GalaxyCheck/Runners/Check/Automata/CheckStateContext.cs index b3a47b83..bc94656d 100644 --- a/src/GalaxyCheck/Runners/Check/Automata/CheckStateContext.cs +++ b/src/GalaxyCheck/Runners/Check/Automata/CheckStateContext.cs @@ -9,7 +9,7 @@ namespace GalaxyCheck.Runners.Check.Automata { internal record CheckStateContext { - public IGen> Property { get; private init; } + public IGen> Property { get; private init; } public int RequestedIterations { get; private init; } @@ -36,7 +36,7 @@ internal record CheckStateContext public bool DeepCheck { get; private init; } private CheckStateContext( - IGen> property, + IGen> property, int requestedIterations, int shrinkLimit, int completedIterationsUntilCounterexample, @@ -60,7 +60,7 @@ private CheckStateContext( } public CheckStateContext( - IGen> property, + IGen> property, int requestedIterations, int shrinkLimit, GenParameters initialParameters, @@ -124,7 +124,7 @@ public CheckStateContext WithNextGenParameters(GenParameters genParameters) = } internal record CounterexampleContext( - IExampleSpace> TestExampleSpace, + IExampleSpace> TestExampleSpace, GenParameters ReplayParameters, IEnumerable ReplayPath, Exception? Exception) diff --git a/src/GalaxyCheck/Runners/Check/Automata/GenerationStates.cs b/src/GalaxyCheck/Runners/Check/Automata/GenerationStates.cs index d2f013a0..573804ee 100644 --- a/src/GalaxyCheck/Runners/Check/Automata/GenerationStates.cs +++ b/src/GalaxyCheck/Runners/Check/Automata/GenerationStates.cs @@ -27,7 +27,7 @@ public CheckStateTransition Transition(CheckStateContext context) } } - internal record Generation_HoldingNextIteration(IEnumerable>> Iterations) : CheckState + internal record Generation_HoldingNextIteration(IEnumerable>> Iterations) : CheckState { public CheckStateTransition Transition(CheckStateContext context) { @@ -45,7 +45,7 @@ public CheckStateTransition Transition(CheckStateContext context) } } - internal record Generation_Instance(IGenInstance> Iteration) : CheckState + internal record Generation_Instance(IGenInstance> Iteration) : CheckState { public CheckStateTransition Transition(CheckStateContext context) => new CheckStateTransition( new InstanceExplorationStates.InstanceExploration_Begin(Iteration), @@ -53,8 +53,8 @@ internal record Generation_Instance(IGenInstance> Iteration) : CheckS } internal record Generation_Discard( - IEnumerable>> NextIterations, - IGenDiscard> Iteration) : CheckState + IEnumerable>> NextIterations, + IGenDiscard> Iteration) : CheckState { public CheckStateTransition Transition(CheckStateContext context) => new CheckStateTransition( new Generation_HoldingNextIteration(NextIterations), @@ -69,7 +69,7 @@ internal record Generation_Error(string Description) : CheckState } internal record Generation_End( - IGenInstance> Instance, + IGenInstance> Instance, CounterexampleContext? CounterexampleContext, bool WasDiscard, bool WasLateDiscard, @@ -83,7 +83,7 @@ public CheckStateTransition Transition(CheckStateContext context) => WasDi private static CheckStateTransition TransitionFromDiscard( CheckStateContext context, - IGenInstance> instance, + IGenInstance> instance, bool wasLateDiscard) => new CheckStateTransition( new Generation_Begin(), context @@ -92,7 +92,7 @@ private static CheckStateTransition TransitionFromDiscard( private static CheckStateTransition NextStateWithoutCounterexample( CheckStateContext context, - IGenInstance> instance) + IGenInstance> instance) { var nextContext = context .IncrementCompletedIterations() @@ -103,7 +103,7 @@ private static CheckStateTransition NextStateWithoutCounterexample( private static CheckStateTransition NextStateWithCounterexample( CheckStateContext context, - IGenInstance> instance, + IGenInstance> instance, CounterexampleContext counterexampleContext, bool wasReplay) { @@ -126,7 +126,7 @@ private static CheckStateTransition NextStateWithCounterexample( private static TerminationReason? TryTerminate( CheckStateContext state, CounterexampleContext counterexampleContext, - IGenInstance> instance, + IGenInstance> instance, bool wasReplay) { if (wasReplay) diff --git a/src/GalaxyCheck/Runners/Check/Automata/InstanceExplorationStates.cs b/src/GalaxyCheck/Runners/Check/Automata/InstanceExplorationStates.cs index f0849373..1527835e 100644 --- a/src/GalaxyCheck/Runners/Check/Automata/InstanceExplorationStates.cs +++ b/src/GalaxyCheck/Runners/Check/Automata/InstanceExplorationStates.cs @@ -10,7 +10,7 @@ namespace GalaxyCheck.Runners.Check.Automata { internal static class InstanceExplorationStates { - internal record InstanceExploration_Begin(IGenInstance> Instance) : CheckState + internal record InstanceExploration_Begin(IGenInstance> Instance) : CheckState { public CheckStateTransition Transition(CheckStateContext context) { @@ -23,8 +23,8 @@ public CheckStateTransition Transition(CheckStateContext context) } internal record InstanceExploration_HoldingNextExplorationStage( - IGenInstance> Instance, - IEnumerable>> Explorations, + IGenInstance> Instance, + IEnumerable>> Explorations, CounterexampleContext? CounterexampleContext, bool IsFirstExplorationStage) : CheckState { @@ -59,9 +59,9 @@ public CheckStateTransition Transition(CheckStateContext context) } internal record InstanceExploration_Counterexample( - IGenInstance> Instance, - IEnumerable>> NextExplorations, - ExplorationStage>.Counterexample CounterexampleExploration) : CheckState + IGenInstance> Instance, + IEnumerable>> NextExplorations, + ExplorationStage>.Counterexample CounterexampleExploration) : CheckState { public CheckStateTransition Transition(CheckStateContext context) => new CheckStateTransition( new InstanceExploration_HoldingNextExplorationStage( @@ -77,7 +77,7 @@ internal record InstanceExploration_Counterexample( CounterexampleExploration.Path, CounterexampleExploration.Exception); - public IExampleSpace> TestExampleSpace => CounterexampleExploration.ExampleSpace; + public IExampleSpace> TestExampleSpace => CounterexampleExploration.ExampleSpace; public IExampleSpace InputExampleSpace => CounterexampleExploration.ExampleSpace.Map(ex => ex.Input); @@ -85,9 +85,9 @@ internal record InstanceExploration_Counterexample( } internal record InstanceExploration_NonCounterexample( - IGenInstance> Instance, - IEnumerable>> NextExplorations, - ExplorationStage>.NonCounterexample NonCounterexampleExploration, + IGenInstance> Instance, + IEnumerable>> NextExplorations, + ExplorationStage>.NonCounterexample NonCounterexampleExploration, CounterexampleContext? PreviousCounterexampleContext) : CheckState { public CheckStateTransition Transition(CheckStateContext context) => new CheckStateTransition( @@ -98,7 +98,7 @@ internal record InstanceExploration_NonCounterexample( IsFirstExplorationStage: false), context); - public IExampleSpace> TestExampleSpace => NonCounterexampleExploration.ExampleSpace; + public IExampleSpace> TestExampleSpace => NonCounterexampleExploration.ExampleSpace; public IExampleSpace InputExampleSpace => NonCounterexampleExploration.ExampleSpace.Map(ex => ex.Input); @@ -106,7 +106,7 @@ internal record InstanceExploration_NonCounterexample( } internal record InstanceExploration_End( - IGenInstance> Instance, + IGenInstance> Instance, CounterexampleContext? CounterexampleContext, bool WasDiscard, bool WasReplay) : CheckState diff --git a/src/GalaxyCheck/Runners/Check/Automata/ReplayState.cs b/src/GalaxyCheck/Runners/Check/Automata/ReplayState.cs index 4438239b..d25eac6e 100644 --- a/src/GalaxyCheck/Runners/Check/Automata/ReplayState.cs +++ b/src/GalaxyCheck/Runners/Check/Automata/ReplayState.cs @@ -32,7 +32,7 @@ public CheckStateTransition Transition(CheckStateContext context) onDiscard: _ => HandleError(context)); } - private static CheckStateTransition HandleInstance(CheckStateContext ctx, IGenInstance> instance, Replay replayDecoded) + private static CheckStateTransition HandleInstance(CheckStateContext ctx, IGenInstance> instance, Replay replayDecoded) { var exampleSpace = instance.ExampleSpace.Navigate(replayDecoded.ExampleSpacePath); if (exampleSpace == null) @@ -49,7 +49,7 @@ private static CheckStateTransition HandleInstance(CheckStateContext ctx, private static CheckStateTransition HandleReplayedNonCounterexample( CheckStateContext context, - IGenInstance> instance) + IGenInstance> instance) { return new CheckStateTransition( new GenerationStates.Generation_End(instance, null, false, false, true), @@ -58,9 +58,9 @@ private static CheckStateTransition HandleReplayedNonCounterexample( private static CheckStateTransition HandleReplayedCounterexample( CheckStateContext context, - IGenInstance> instance, + IGenInstance> instance, Replay replayDecoded, - ExplorationStage>.Counterexample counterexample) + ExplorationStage>.Counterexample counterexample) { var counterexampleContext = new CounterexampleContext( counterexample.ExampleSpace, diff --git a/src/GalaxyCheck/Runners/Check/Sizing/ResizeStrategy.cs b/src/GalaxyCheck/Runners/Check/Sizing/ResizeStrategy.cs index e5334137..a34c1cf2 100644 --- a/src/GalaxyCheck/Runners/Check/Sizing/ResizeStrategy.cs +++ b/src/GalaxyCheck/Runners/Check/Sizing/ResizeStrategy.cs @@ -9,5 +9,5 @@ namespace GalaxyCheck.Runners.Check.Sizing internal record ResizeStrategyInformation( CheckStateContext CheckStateContext, CounterexampleContext? CounterexampleContext, - IGenInstance> Iteration); + IGenInstance> Iteration); } diff --git a/src/GalaxyCheck/Runners/Check/Sizing/ResizeStrategyAsync.cs b/src/GalaxyCheck/Runners/Check/Sizing/ResizeStrategyAsync.cs index bb34ae12..924ab9b6 100644 --- a/src/GalaxyCheck/Runners/Check/Sizing/ResizeStrategyAsync.cs +++ b/src/GalaxyCheck/Runners/Check/Sizing/ResizeStrategyAsync.cs @@ -9,5 +9,5 @@ namespace GalaxyCheck.Runners.Check.Sizing internal record ResizeStrategyInformationAsync( CheckStateContext CheckStateContext, CounterexampleContext? CounterexampleContext, - IGenInstance> Iteration); + IGenInstance> Iteration); } diff --git a/src/GalaxyCheck/Runners/PresentationalSample.cs b/src/GalaxyCheck/Runners/PresentationalSample.cs index a4cfff02..6075dcc1 100644 --- a/src/GalaxyCheck/Runners/PresentationalSample.cs +++ b/src/GalaxyCheck/Runners/PresentationalSample.cs @@ -74,13 +74,13 @@ internal static class PresentationalSampleHelpers return ExtractSampleFromCheckResult(checkResult); } - private static Test MuteTestFailure(Test test) + private static Property.Test MuteTestFailure(Property.Test test) { return TestFactory.Create(test.Input, () => true, test.PresentedInput); } - private static AsyncTest MuteTestFailure(AsyncTest test) + private static Property.AsyncTest MuteTestFailure(Property.AsyncTest test) { // Create a test that always passes using the same input. We don't care if a property passes or fails when // we're sampling the input.