From 88b0b4ab8fd6febd1540f4445f1ae79307630323 Mon Sep 17 00:00:00 2001 From: Tyson Williams Date: Fri, 26 Nov 2021 10:27:26 -0600 Subject: [PATCH 1/3] Use .NET SDK 5.0.403 on GitHub --- .github/workflows/master.yml | 2 +- .github/workflows/pull_request.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index c2fef56b..8a4969ec 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.1.403 + dotnet-version: 5.0.403 - name: Install dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 944ea087..448f62e3 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -18,7 +18,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.1.403 + dotnet-version: 5.0.403 - name: Install dependencies run: dotnet restore - name: Build From b0ada751312157c9eb83514ff4b431a38f786b1d Mon Sep 17 00:00:00 2001 From: Tyson Williams Date: Fri, 26 Nov 2021 10:38:59 -0600 Subject: [PATCH 2/3] Change tests to target .NET 5 --- tests/Hedgehog.Benchmarks/Hedgehog.Benchmarks.fsproj | 2 +- tests/Hedgehog.Linq.Tests/Hedgehog.Linq.Tests.csproj | 2 +- tests/Hedgehog.Tests/Hedgehog.Tests.fsproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Hedgehog.Benchmarks/Hedgehog.Benchmarks.fsproj b/tests/Hedgehog.Benchmarks/Hedgehog.Benchmarks.fsproj index ca7b2cc3..65beb592 100644 --- a/tests/Hedgehog.Benchmarks/Hedgehog.Benchmarks.fsproj +++ b/tests/Hedgehog.Benchmarks/Hedgehog.Benchmarks.fsproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net5.0 diff --git a/tests/Hedgehog.Linq.Tests/Hedgehog.Linq.Tests.csproj b/tests/Hedgehog.Linq.Tests/Hedgehog.Linq.Tests.csproj index 4e09fda8..f024f94c 100644 --- a/tests/Hedgehog.Linq.Tests/Hedgehog.Linq.Tests.csproj +++ b/tests/Hedgehog.Linq.Tests/Hedgehog.Linq.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 8.0 Library diff --git a/tests/Hedgehog.Tests/Hedgehog.Tests.fsproj b/tests/Hedgehog.Tests/Hedgehog.Tests.fsproj index 3f3c22ab..f25dea5d 100644 --- a/tests/Hedgehog.Tests/Hedgehog.Tests.fsproj +++ b/tests/Hedgehog.Tests/Hedgehog.Tests.fsproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 Exe false From ee95ed08dc54fec7c7bf6b467f914ae3f7a18797 Mon Sep 17 00:00:00 2001 From: Tyson Williams Date: Fri, 26 Nov 2021 10:05:18 -0600 Subject: [PATCH 3/3] Add BindReturn to property CE --- CHANGELOG.md | 4 ++++ src/Hedgehog/Property.fs | 6 ++++++ tests/Hedgehog.Benchmarks/Program.fs | 2 ++ tests/Hedgehog.Tests/GenTests.fs | 2 ++ tests/Hedgehog.Tests/PropertyTests.fs | 2 ++ tests/Hedgehog.Tests/ShrinkTests.fs | 1 + 6 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81d6b2d4..803435cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## Version ? - Rename `Property.failOnFalse` to `Property.falseToFailure` ([#384][384], [@TysonMN][TysonMN]) +- Add `BindReturn` to the `property` CE ([#364][364], [@TysonMN][TysonMN]) + - A breaking change. Previously, returning a `bool` from a `property` CE (after using `let!`) caused the CE to have return type `Property`. Now this results in a return type of `Property`. The previous behavior can now be expressed by piping the `Property` instance into `Property.falseToFailure`. ## Version 0.11.1 (2021-11-19) @@ -188,6 +190,8 @@ https://github.com/hedgehogqa/fsharp-hedgehog/pull/381 [380]: https://github.com/hedgehogqa/fsharp-hedgehog/pull/380 +[364]: + https://github.com/hedgehogqa/fsharp-hedgehog/pull/364 [363]: https://github.com/hedgehogqa/fsharp-hedgehog/pull/363 [362]: diff --git a/src/Hedgehog/Property.fs b/src/Hedgehog/Property.fs index 5f239072..aadf1640 100644 --- a/src/Hedgehog/Property.fs +++ b/src/Hedgehog/Property.fs @@ -310,6 +310,12 @@ module PropertyBuilder = member __.Return(b : bool) : Property = Property.ofBool b + member __.BindReturn(m : Gen<'a>, f: 'a -> 'b) = + m + |> Gen.map (fun a -> (Journal.empty, Success a)) + |> Property.ofGen + |> Property.map f + member __.ReturnFrom(m : Property<'a>) : Property<'a> = m diff --git a/tests/Hedgehog.Benchmarks/Program.fs b/tests/Hedgehog.Benchmarks/Program.fs index 08973ded..11c1fe2a 100644 --- a/tests/Hedgehog.Benchmarks/Program.fs +++ b/tests/Hedgehog.Benchmarks/Program.fs @@ -15,6 +15,7 @@ type Benchmarks () = let! i = Gen.int32 (Range.constant 0 10000) return i >= 0 } + |> Property.falseToFailure |> Property.check [] @@ -23,6 +24,7 @@ type Benchmarks () = let! i = Gen.string (Range.constant 0 100) Gen.ascii return i.Length >= 0 } + |> Property.falseToFailure |> Property.check [] diff --git a/tests/Hedgehog.Tests/GenTests.fs b/tests/Hedgehog.Tests/GenTests.fs index 05a49487..e4f4a4b0 100644 --- a/tests/Hedgehog.Tests/GenTests.fs +++ b/tests/Hedgehog.Tests/GenTests.fs @@ -82,6 +82,7 @@ let genTests = testList "Gen tests" [ let! _ = Gen.int64 (Range.exponentialBounded ()) return true } + |> Property.falseToFailure |> Property.check fableIgnore "uint64 can create exponentially bounded integer" <| fun _ -> @@ -89,6 +90,7 @@ let genTests = testList "Gen tests" [ let! _ = Gen.uint64 (Range.exponentialBounded ()) return true } + |> Property.falseToFailure |> Property.check testCase "apply is chainable" <| fun _ -> diff --git a/tests/Hedgehog.Tests/PropertyTests.fs b/tests/Hedgehog.Tests/PropertyTests.fs index afa047b9..40947a41 100644 --- a/tests/Hedgehog.Tests/PropertyTests.fs +++ b/tests/Hedgehog.Tests/PropertyTests.fs @@ -11,6 +11,7 @@ let propertyTests = testList "Property tests" [ let! xs = Range.singleton 0 |> Gen.int32 |> Gen.list (Range.singleton 5) |> Gen.map ResizeArray return false } + |> Property.falseToFailure |> Property.renderWith (PropertyConfig.withShrinks 0 PropertyConfig.defaultConfig) Expect.isNotMatch report "\.\.\." "Abbreviation (...) found" @@ -57,6 +58,7 @@ let propertyTests = testList "Property tests" [ let! opt = Gen.constant () |> Gen.option return opt |> Option.isSome } + |> Property.falseToFailure |> Property.report |> Report.render |> ignore diff --git a/tests/Hedgehog.Tests/ShrinkTests.fs b/tests/Hedgehog.Tests/ShrinkTests.fs index 3057be53..fee6a2ce 100644 --- a/tests/Hedgehog.Tests/ShrinkTests.fs +++ b/tests/Hedgehog.Tests/ShrinkTests.fs @@ -207,6 +207,7 @@ let shrinkTests = testList "Shrink tests" [ let! actual = Range.linear 1 1_000_000 |> Gen.int32 return actual < 500_000 } + |> Property.falseToFailure |> Property.reportWith propConfig match report.Status with | Failed failureData ->