diff --git a/CHANGELOG.md b/CHANGELOG.md index a8fc1337..17525b6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Version 0.14.0 +- No longer targeting .NET Framework ([#417][417], [@LyndonGingerich][LyndonGingerich]) +- The runtime of `Property.recheck` is now about the same as `Property.check`. Previously, it was about ten times slower. ([#433][433], [@TysonMN][TysonMN]) +- The error message given when a deadend is reached during rechecking is improved to say that the cause is a change in generators. ([#436][436], [@TysonMN][TysonMN]) +- The implementation of `Property.falseToFailure` is now better. As a result, `Property.recheckBool` now only tests the shrunken input. ([#437][437], [@TysonMN][TysonMN]) + ## Version 0.13.0 (2022-07-23) - Fix bug in `Property.recheck` where the result is always `Failed`. ([#415][415], [@TysonMN][TysonMN]) @@ -199,6 +205,12 @@ [LyndonGingerich] https://github.com/LyndonGingerich +[436]: + https://github.com/hedgehogqa/fsharp-hedgehog/pull/436 +[433]: + https://github.com/hedgehogqa/fsharp-hedgehog/pull/433 +[417]: + https://github.com/hedgehogqa/fsharp-hedgehog/pull/417 [416]: https://github.com/hedgehogqa/fsharp-hedgehog/pull/416 [415]: diff --git a/src/Hedgehog/Property.fs b/src/Hedgehog/Property.fs index 632bbabd..ebd3eaf2 100644 --- a/src/Hedgehog/Property.fs +++ b/src/Hedgehog/Property.fs @@ -2,6 +2,9 @@ namespace Hedgehog open System +type internal TestReturnedFalseException() = + inherit System.Exception("Expected 'true' but was 'false'.") + [] type Property<'a> = @@ -95,7 +98,7 @@ module Property = |> ofGen let falseToFailure p = - p |> bind ofBool + p |> map (fun b -> if not b then raise (TestReturnedFalseException())) let internal printValue (value) : string = // sprintf "%A" is not prepared for printing ResizeArray<_> (C# List) so we prepare the value instead diff --git a/tests/Hedgehog.Tests/PropertyTests.fs b/tests/Hedgehog.Tests/PropertyTests.fs index 9ab6d624..848644c8 100644 --- a/tests/Hedgehog.Tests/PropertyTests.fs +++ b/tests/Hedgehog.Tests/PropertyTests.fs @@ -94,6 +94,34 @@ let propertyTests = testList "Property tests" [ //render.Contains "actual: 1" =! true // comment out for now since it causes the Fable test to fail + testCase "recheckBool only tests shrunken input" <| fun () -> + let mutable count = 0 + let prop = + property { + let! i = Range.constant 0 1_000_000 |> Gen.int32 + count <- count + 1 + return i = 0 + } + + let report1 = Property.reportBool prop + match report1.Status with + | OK -> failwith "Initial report should be Failed, not OK" + | GaveUp -> failwith "Initial report should be Failed, not GaveUp" + | Failed failure1 -> + count <- 0 + let report2 = + Property.reportRecheckBool + (RecheckData.serialize failure1.RecheckInfo.Value.Data) + prop + match report2.Status with + | OK -> failwith "Recheck report should be Failed, not OK" + | GaveUp -> failwith "Recheck report should be Failed, not GaveUp" + | Failed _ -> + let render = Report.render report2 + count =! 1 + //render.Contains "actual: 1" =! true // comment out for now since it causes the Fable test to fail + + testCase "recheck passes after code is fixed" <| fun () -> let mutable b = false let prop = @@ -151,5 +179,4 @@ let propertyTests = testList "Property tests" [ .Replace(")", "") actual =! "1,0" - ]